Skip to content

Instantly share code, notes, and snippets.

@calvinclaus
Created April 22, 2017 13:15
Show Gist options
  • Save calvinclaus/1385f89362072586f204e821b982d0a1 to your computer and use it in GitHub Desktop.
Save calvinclaus/1385f89362072586f204e821b982d0a1 to your computer and use it in GitHub Desktop.
package at.ac.tuwien.inso.sepm.ticketline.server.unittest.customer;
import at.ac.tuwien.inso.sepm.ticketline.server.entity.Customer;
import at.ac.tuwien.inso.sepm.ticketline.server.service.CustomerService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CustomerUnitTest {
private final static Logger LOGGER = LoggerFactory.getLogger(CustomerUnitTest.class);
@Autowired
private CustomerService customerService;
private static final String CUSTOMER_NAME = "Maximilian Muster";
@Test
public void createValidCustomer() {
Customer cust = new Customer();
cust.setName(CUSTOMER_NAME);
customerService.save(cust);
List<Customer> list = customerService.findAll();
assertTrue(list.contains(cust));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment