using IntTests.createEntity() as generated by JHipster with required fields

This commit is contained in:
Michael Hoennig 2019-04-12 17:20:48 +02:00
parent 3fa514c982
commit 73969f5a40
4 changed files with 24 additions and 25 deletions

View File

@ -106,10 +106,8 @@ public class AssetResourceIntTest {
* This is a static method, as tests for other entities might also need it, * This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity. * if they test an entity which requires the current entity.
*/ */
public static Asset createEntity(EntityManager em, Membership membership) { public static Asset createEntity(EntityManager em) {
em.persist(membership);
Asset asset = new Asset() Asset asset = new Asset()
.member(membership)
.date(DEFAULT_DATE) .date(DEFAULT_DATE)
.action(DEFAULT_ACTION) .action(DEFAULT_ACTION)
.amount(DEFAULT_AMOUNT) .amount(DEFAULT_AMOUNT)
@ -124,7 +122,7 @@ public class AssetResourceIntTest {
@Before @Before
public void initTest() { public void initTest() {
asset = createEntity(em, MembershipResourceIntTest.createEntity(em, CustomerResourceIntTest.createEntity(em))); asset = createEntity(em);
} }
@Test @Test
@ -447,7 +445,7 @@ public class AssetResourceIntTest {
@Transactional @Transactional
public void getAllAssetsByMemberIsEqualToSomething() throws Exception { public void getAllAssetsByMemberIsEqualToSomething() throws Exception {
// Initialize the database // Initialize the database
Membership member = MembershipResourceIntTest.createEntity(em, CustomerResourceIntTest.createAnotherEntity(em)); Membership member = MembershipResourceIntTest.createEntity(em);
em.persist(member); em.persist(member);
em.flush(); em.flush();
asset.setMember(member); asset.setMember(member);

View File

@ -44,20 +44,20 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
public class CustomerResourceIntTest { public class CustomerResourceIntTest {
private static final Integer DEFAULT_NUMBER = 10000; private static final Integer DEFAULT_NUMBER = 10000;
private static final Integer ANOTHER_NUMBER = 10001; private static final Integer UPDATED_NUMBER = 10001;
private static final Integer UPDATED_NUMBER = 10002; private static final Integer OTHER_NUMBER_BASE = 11000;
private static final String DEFAULT_PREFIX = "def"; private static final String DEFAULT_PREFIX = "def";
private static final String ANOTHER_PREFIX = "old";
private static final String UPDATED_PREFIX = "new"; private static final String UPDATED_PREFIX = "new";
private static final String OTHER_PREFIX_BASE = "o";
private static final String DEFAULT_NAME = "Default GmbH"; private static final String DEFAULT_NAME = "Default GmbH";
private static final String UPDATED_NAME = "Updated Default GmbH"; private static final String UPDATED_NAME = "Updated Default GmbH";
private static final String ANOTHER_NAME = "Another Corp."; private static final String OTHER_NAME_BASE = "Other Corp.";
private static final String DEFAULT_CONTRACTUAL_ADDRESS = "Default Address"; private static final String DEFAULT_CONTRACTUAL_ADDRESS = "Default Address";
private static final String UPDATED_CONTRACTUAL_ADDRESS = "Updated Address"; private static final String UPDATED_CONTRACTUAL_ADDRESS = "Updated Address";
private static final String ANOTHER_CONTRACTUAL_ADDRESS = "Another Address"; private static final String OTHER_CONTRACTUAL_ADDRESS_BASE = "Other Street ";
private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA"; private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA";
private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB"; private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB";
@ -68,6 +68,8 @@ public class CustomerResourceIntTest {
private static final String DEFAULT_BILLING_SALUTATION = "AAAAAAAAAA"; private static final String DEFAULT_BILLING_SALUTATION = "AAAAAAAAAA";
private static final String UPDATED_BILLING_SALUTATION = "BBBBBBBBBB"; private static final String UPDATED_BILLING_SALUTATION = "BBBBBBBBBB";
private static int otherCounter = 0;
@Autowired @Autowired
private CustomerRepository customerRepository; private CustomerRepository customerRepository;
@ -137,10 +139,11 @@ public class CustomerResourceIntTest {
*/ */
public static Customer createAnotherEntity(EntityManager em) { public static Customer createAnotherEntity(EntityManager em) {
Customer customer = new Customer() Customer customer = new Customer()
.number(ANOTHER_NUMBER) .number(OTHER_NUMBER_BASE + otherCounter)
.prefix(ANOTHER_PREFIX) .prefix(OTHER_PREFIX_BASE + String.format("%02d", otherCounter))
.name(ANOTHER_NAME) .name(OTHER_NAME_BASE + otherCounter)
.contractualAddress(ANOTHER_CONTRACTUAL_ADDRESS); .contractualAddress(OTHER_CONTRACTUAL_ADDRESS_BASE + otherCounter);
++otherCounter;
return customer; return customer;
} }
@ -614,7 +617,7 @@ public class CustomerResourceIntTest {
@Transactional @Transactional
public void getAllCustomersByMembershipIsEqualToSomething() throws Exception { public void getAllCustomersByMembershipIsEqualToSomething() throws Exception {
// Initialize the database // Initialize the database
Membership membership = MembershipResourceIntTest.createEntity(em, customer); Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership); em.persist(membership);
em.flush(); em.flush();
customer.addMembership(membership); customer.addMembership(membership);

View File

@ -102,14 +102,12 @@ public class MembershipResourceIntTest {
* This is a static method, as tests for other entities might also need it, * This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity. * if they test an entity which requires the current entity.
*/ */
public static Membership createEntity(final EntityManager em, final Customer customer) { public static Membership createEntity(final EntityManager em) {
em.persist(customer);
Membership membership = new Membership() Membership membership = new Membership()
.customer(customer)
.sinceDate(DEFAULT_SINCE_DATE) .sinceDate(DEFAULT_SINCE_DATE)
.untilDate(DEFAULT_UNTIL_DATE); .untilDate(DEFAULT_UNTIL_DATE);
// Add required entity // Add required entity
Customer customer = CustomerResourceIntTest.createEntity(em); Customer customer = CustomerResourceIntTest.createAnotherEntity(em);
em.persist(customer); em.persist(customer);
em.flush(); em.flush();
membership.setCustomer(customer); membership.setCustomer(customer);
@ -118,7 +116,7 @@ public class MembershipResourceIntTest {
@Before @Before
public void initTest() { public void initTest() {
membership = createEntity(em, CustomerResourceIntTest.createEntity(em)); membership = createEntity(em);
} }
@Test @Test
@ -365,11 +363,11 @@ public class MembershipResourceIntTest {
@Transactional @Transactional
public void getAllMembershipsByAssetIsEqualToSomething() throws Exception { public void getAllMembershipsByAssetIsEqualToSomething() throws Exception {
// Initialize the database // Initialize the database
Asset asset = AssetResourceIntTest.createEntity(em, membership); Asset asset = AssetResourceIntTest.createEntity(em);
membership.addAsset(asset);
em.persist(membership);
em.persist(asset); em.persist(asset);
em.flush(); em.flush();
membership.addAsset(asset);
membershipRepository.flush();
Long assetId = asset.getId(); Long assetId = asset.getId();
// Get all the membershipList where asset equals to assetId // Get all the membershipList where asset equals to assetId

View File

@ -119,7 +119,7 @@ public class ShareResourceIntTest {
@Before @Before
public void initTest() { public void initTest() {
share = createEntity(em, MembershipResourceIntTest.createEntity(em, CustomerResourceIntTest.createEntity(em))); share = createEntity(em, MembershipResourceIntTest.createEntity(em));
} }
@Test @Test
@ -470,7 +470,7 @@ public class ShareResourceIntTest {
@Transactional @Transactional
public void getAllSharesByMemberIsEqualToSomething() throws Exception { public void getAllSharesByMemberIsEqualToSomething() throws Exception {
// Initialize the database // Initialize the database
Membership member = MembershipResourceIntTest.createEntity(em, CustomerResourceIntTest.createAnotherEntity(em)); Membership member = MembershipResourceIntTest.createEntity(em);
em.persist(member); em.persist(member);
em.flush(); em.flush();
share.setMember(member); share.setMember(member);