diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java index 724a06c3..60f5b935 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java @@ -9,7 +9,6 @@ import org.hostsharing.hsadminng.service.ContactService; import org.hostsharing.hsadminng.service.dto.ContactDTO; import org.hostsharing.hsadminng.service.mapper.ContactMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.ContactCriteria; import org.hostsharing.hsadminng.service.ContactQueryService; import org.junit.Before; @@ -368,7 +367,7 @@ public class ContactResourceIntTest { @Transactional public void getAllContactsByRoleIsEqualToSomething() throws Exception { // Initialize the database - CustomerContact role = CustomerContactResourceIntTest.createEntity(em); + CustomerContact role = CustomerContactResourceIntTest.createDefaultEntity(em); em.persist(role); em.flush(); contact.addRole(role); diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java index 04097ed1..5a884fe3 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java @@ -10,7 +10,6 @@ import org.hostsharing.hsadminng.service.CustomerContactService; import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria; import org.hostsharing.hsadminng.service.CustomerContactQueryService; import org.junit.Before; @@ -84,6 +83,7 @@ public class CustomerContactResourceIntTest { @Before public void setup() { + MockitoAnnotations.initMocks(this); final CustomerContactResource customerContactResource = new CustomerContactResource(customerContactService, customerContactQueryService); this.restCustomerContactMockMvc = MockMvcBuilders.standaloneSetup(customerContactResource) @@ -95,12 +95,12 @@ public class CustomerContactResourceIntTest { } /** - * Create an entity for this test. + * Create a CustomerContaact entity for the given Customer for testing purposes. * * This is a static method, as tests for other entities might also need it, * if they test an entity which requires the current entity. */ - public static CustomerContact createEntity(EntityManager em) { + public static CustomerContact crateEnitity(final EntityManager em, Customer customer) { CustomerContact customerContact = new CustomerContact() .role(DEFAULT_ROLE); // Add required entity @@ -109,16 +109,35 @@ public class CustomerContactResourceIntTest { em.flush(); customerContact.setContact(contact); // Add required entity - Customer customer = CustomerResourceIntTest.createEntity(em); em.persist(customer); em.flush(); customerContact.setCustomer(customer); return customerContact; } + /** + * Create an arbitrary CustomerContact entity for tests. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static CustomerContact createDefaultEntity(EntityManager em) { + return crateEnitity(em, CustomerResourceIntTest.createEntity(em)); + } + + /** + * Create another arbitrary CustomerContact entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static CustomerContact createAnotherEntity(EntityManager em) { + return crateEnitity(em, CustomerResourceIntTest.createAnotherEntity(em)); + } + @Before public void initTest() { - customerContact = createEntity(em); + customerContact = createDefaultEntity(em); } @Test @@ -264,12 +283,11 @@ public class CustomerContactResourceIntTest { defaultCustomerContactShouldNotBeFound("contactId.equals=" + (contactId + 1)); } - @Test @Transactional public void getAllCustomerContactsByCustomerIsEqualToSomething() throws Exception { // Initialize the database - Customer customer = CustomerResourceIntTest.createEntity(em); + Customer customer = CustomerResourceIntTest.createAnotherEntity(em); em.persist(customer); em.flush(); customerContact.setCustomer(customer); diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java index 6aa493eb..909ae662 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java @@ -48,10 +48,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. public class CustomerResourceIntTest { private static final Integer DEFAULT_NUMBER = 10000; - private static final Integer UPDATED_NUMBER = 10001; + private static final Integer ANOTHER_NUMBER = 10001; + private static final Integer UPDATED_NUMBER = 10002; - private static final String DEFAULT_PREFIX = "lzv"; - private static final String UPDATED_PREFIX = "zf"; + private static final String DEFAULT_PREFIX = "def"; + private static final String ANOTHER_PREFIX = "old"; + private static final String UPDATED_PREFIX = "new"; @Autowired private CustomerRepository customerRepository; @@ -97,7 +99,7 @@ public class CustomerResourceIntTest { } /** - * Create an entity for this test. + * Create an entity for tests. * * This is a static method, as tests for other entities might also need it, * if they test an entity which requires the current entity. @@ -109,6 +111,19 @@ public class CustomerResourceIntTest { return customer; } + /** + * Create another entity for tests. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Customer createAnotherEntity(EntityManager em) { + Customer customer = new Customer() + .number(ANOTHER_NUMBER) + .prefix(ANOTHER_PREFIX); + return customer; + } + @Before public void initTest() { customer = createEntity(em); @@ -350,7 +365,7 @@ public class CustomerResourceIntTest { @Transactional public void getAllCustomersByRoleIsEqualToSomething() throws Exception { // Initialize the database - CustomerContact role = CustomerContactResourceIntTest.createEntity(em); + CustomerContact role = CustomerContactResourceIntTest.createAnotherEntity(em); em.persist(role); em.flush(); customer.addRole(role); diff --git a/src/test/resources/config/application.yml b/src/test/resources/config/application.yml index 47b64299..0c0e3237 100644 --- a/src/test/resources/config/application.yml +++ b/src/test/resources/config/application.yml @@ -21,7 +21,7 @@ spring: type: simple datasource: type: com.zaxxer.hikari.HikariDataSource - url: jdbc:h2:mem:hsadminNg;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + url: jdbc:h2:mem:hsadminNg;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE name: username: password: