Fixed tests after merge.
This commit is contained in:
parent
5ac1277e7e
commit
7c7d79c870
@ -16,6 +16,6 @@ import org.springframework.stereotype.Repository;
|
||||
public interface MembershipRepository extends JpaRepository<Membership, Long>, JpaSpecificationExecutor<Membership> {
|
||||
|
||||
@Query("SELECT CASE WHEN COUNT(m)> 0 THEN TRUE ELSE FALSE END " +
|
||||
" FROM Membership m WHERE m.customer.id=:customerId AND m.memberUntil IS NULL")
|
||||
" FROM Membership m WHERE m.customer.id=:customerId AND m.memberUntilDate IS NULL")
|
||||
boolean hasUncancelledMembershipForCustomer(@Param("customerId") final long customerId);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class MembershipValidator {
|
||||
private MembershipRepository membershipRepository;
|
||||
|
||||
public void validate(final MembershipDTO membershipDTO) {
|
||||
if (membershipDTO.getMemberUntil() != null && !membershipDTO.getMemberUntil().isAfter(membershipDTO.getMemberFrom())) {
|
||||
if (membershipDTO.getMemberUntilDate() != null && !membershipDTO.getMemberUntilDate().isAfter(membershipDTO.getMemberFromDate())) {
|
||||
throw new BadRequestAlertException("Invalid untilDate", Membership.ENTITY_NAME, "untilDateMustBeAfterSinceDate");
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ import java.time.LocalDate;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* A DTO for the Membership entity.
|
||||
@ -29,6 +30,12 @@ public class MembershipDTO implements Serializable {
|
||||
|
||||
private String customerPrefix;
|
||||
|
||||
public MembershipDTO with(
|
||||
Consumer<MembershipDTO> builderFunction) {
|
||||
builderFunction.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import org.apache.commons.lang3.RandomUtils;
|
||||
import org.hostsharing.hsadminng.HsadminNgApp;
|
||||
import org.hostsharing.hsadminng.domain.Customer;
|
||||
import org.hostsharing.hsadminng.domain.Membership;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.CustomerKind;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.VatRegion;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -72,6 +74,8 @@ public class MembershipRepositoryIntTest {
|
||||
customer.setReference(RandomUtils.nextInt(10001, 19999));
|
||||
customer.setName(RandomStringUtils.randomAlphabetic(10));
|
||||
customer.setContractualAddress(RandomStringUtils.randomAlphabetic(10));
|
||||
customer.setKind(CustomerKind.NATURAL);
|
||||
customer.setVatRegion(VatRegion.DOMESTIC);
|
||||
customerRepository.save(customer);
|
||||
return customer;
|
||||
}
|
||||
@ -80,11 +84,11 @@ public class MembershipRepositoryIntTest {
|
||||
final Customer customer = createCustomer();
|
||||
final Membership membership = new Membership();
|
||||
membership.setCustomer(customer);
|
||||
membership.setMemberFrom(LocalDate.parse(from));
|
||||
membership.setMemberFromDate(LocalDate.parse(from));
|
||||
if (to != null) {
|
||||
membership.setMemberUntil(LocalDate.parse(to));
|
||||
membership.setMemberUntilDate(LocalDate.parse(to));
|
||||
}
|
||||
membership.setDocumentDate(membership.getMemberFrom().minusDays(7));
|
||||
membership.setAdmissionDocumentDate(membership.getMemberFromDate().minusDays(7));
|
||||
membershipRepository.save(membership);
|
||||
return customer;
|
||||
}
|
||||
|
@ -101,12 +101,12 @@ public class MembershipValidatorUnitTest {
|
||||
|
||||
|
||||
GivenMembershipValidationTestCase since(final String sinceDate) {
|
||||
membershipDto.setMemberFrom(LocalDate.parse(sinceDate));
|
||||
membershipDto.setMemberFromDate(LocalDate.parse(sinceDate));
|
||||
return this;
|
||||
}
|
||||
|
||||
public GivenMembershipValidationTestCase until(final String untilDate) {
|
||||
membershipDto.setMemberUntil(LocalDate.parse(untilDate));
|
||||
membershipDto.setMemberUntilDate(LocalDate.parse(untilDate));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,26 @@ public class AssetResourceIntTest {
|
||||
return asset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a persistent entity related to the given persistent membership 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 Asset createPersistentEntity(EntityManager em, final Membership membership) {
|
||||
Asset asset = new Asset()
|
||||
.documentDate(DEFAULT_DOCUMENT_DATE)
|
||||
.valueDate(DEFAULT_VALUE_DATE)
|
||||
.action(DEFAULT_ACTION)
|
||||
.amount(DEFAULT_AMOUNT)
|
||||
.remark(DEFAULT_REMARK);
|
||||
// Add required entity
|
||||
asset.setMembership(membership);
|
||||
membership.addAsset(asset);
|
||||
em.persist(asset);
|
||||
em.flush();
|
||||
return asset;
|
||||
}
|
||||
@Before
|
||||
public void initTest() {
|
||||
asset = createEntity(em);
|
||||
@ -542,9 +562,7 @@ public class AssetResourceIntTest {
|
||||
@Transactional
|
||||
public void getAllAssetsByMembershipIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
Membership membership = MembershipResourceIntTest.createEntity(em);
|
||||
em.persist(membership);
|
||||
em.flush();
|
||||
Membership membership = MembershipResourceIntTest.createPersistentEntity(em, CustomerResourceIntTest.createPersistentEntity(em));
|
||||
asset.setMembership(membership);
|
||||
assetRepository.saveAndFlush(asset);
|
||||
Long membershipId = membership.getId();
|
||||
@ -626,17 +644,17 @@ public class AssetResourceIntTest {
|
||||
restAssetMockMvc.perform(put("/api/assets")
|
||||
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
|
||||
.andExpect(status().isOk());
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
// Validate the Asset in the database
|
||||
List<Asset> assetList = assetRepository.findAll();
|
||||
assertThat(assetList).hasSize(databaseSizeBeforeUpdate);
|
||||
Asset testAsset = assetList.get(assetList.size() - 1);
|
||||
assertThat(testAsset.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
|
||||
assertThat(testAsset.getValueDate()).isEqualTo(UPDATED_VALUE_DATE);
|
||||
assertThat(testAsset.getAction()).isEqualTo(UPDATED_ACTION);
|
||||
assertThat(testAsset.getAmount()).isEqualTo(UPDATED_AMOUNT);
|
||||
assertThat(testAsset.getRemark()).isEqualTo(UPDATED_REMARK);
|
||||
assertThat(testAsset.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
|
||||
assertThat(testAsset.getValueDate()).isEqualTo(DEFAULT_VALUE_DATE);
|
||||
assertThat(testAsset.getAction()).isEqualByComparingTo(DEFAULT_ACTION);
|
||||
assertThat(testAsset.getAmount()).isEqualByComparingTo(DEFAULT_AMOUNT);
|
||||
assertThat(testAsset.getRemark()).isEqualTo(DEFAULT_REMARK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -669,11 +687,11 @@ public class AssetResourceIntTest {
|
||||
// Delete the asset
|
||||
restAssetMockMvc.perform(delete("/api/assets/{id}", asset.getId())
|
||||
.accept(TestUtil.APPLICATION_JSON_UTF8))
|
||||
.andExpect(status().isOk());
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
// Validate the database is empty
|
||||
// Validate the database still contains the same number of assets
|
||||
List<Asset> assetList = assetRepository.findAll();
|
||||
assertThat(assetList).hasSize(databaseSizeBeforeDelete - 1);
|
||||
assertThat(assetList).hasSize(databaseSizeBeforeDelete);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -81,6 +81,7 @@ public class CustomerResourceIntTest {
|
||||
|
||||
private static final CustomerKind DEFAULT_KIND = CustomerKind.NATURAL;
|
||||
private static final CustomerKind UPDATED_KIND = CustomerKind.LEGAL;
|
||||
private static final CustomerKind OTHER_KIND = CustomerKind.LEGAL;
|
||||
|
||||
private static final LocalDate DEFAULT_BIRTH_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_BIRTH_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
@ -96,6 +97,7 @@ public class CustomerResourceIntTest {
|
||||
|
||||
private static final VatRegion DEFAULT_VAT_REGION = VatRegion.DOMESTIC;
|
||||
private static final VatRegion UPDATED_VAT_REGION = VatRegion.EU;
|
||||
private static final VatRegion OTHER_VAT_REGION = VatRegion.EU;
|
||||
|
||||
private static final String DEFAULT_VAT_NUMBER = "AAAAAAAAAA";
|
||||
private static final String UPDATED_VAT_NUMBER = "BBBBBBBBBB";
|
||||
|
@ -8,17 +8,10 @@ import org.hostsharing.hsadminng.domain.Share;
|
||||
import org.hostsharing.hsadminng.repository.MembershipRepository;
|
||||
import org.hostsharing.hsadminng.service.MembershipQueryService;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Membership;
|
||||
import org.hostsharing.hsadminng.domain.Share;
|
||||
import org.hostsharing.hsadminng.domain.Asset;
|
||||
import org.hostsharing.hsadminng.domain.Customer;
|
||||
import org.hostsharing.hsadminng.repository.MembershipRepository;
|
||||
import org.hostsharing.hsadminng.service.MembershipService;
|
||||
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
|
||||
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
|
||||
import org.hostsharing.hsadminng.service.dto.MembershipCriteria;
|
||||
import org.hostsharing.hsadminng.service.MembershipQueryService;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -39,14 +32,12 @@ import javax.persistence.EntityManager;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
|
||||
|
||||
|
||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
@ -64,23 +55,18 @@ public class MembershipResourceIntTest {
|
||||
private static final LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
private static final LocalDate UPDATED_DOCUMENT_DATE = DEFAULT_DOCUMENT_DATE.plusDays(1);
|
||||
|
||||
private static final LocalDate DEFAULT_MEMBER_FROM = DEFAULT_DOCUMENT_DATE.plusDays(2);
|
||||
private static final LocalDate UPDATED_MEMBER_FROM = UPDATED_DOCUMENT_DATE.plusDays(8);
|
||||
private static final LocalDate DEFAULT_MEMBER_FROM_DATE = DEFAULT_DOCUMENT_DATE.plusDays(2);
|
||||
private static final LocalDate UPDATED_MEMBER_FROM_DATE = UPDATED_DOCUMENT_DATE.plusDays(8);
|
||||
|
||||
private static final LocalDate DEFAULT_MEMBER_UNTIL_DATE = DEFAULT_MEMBER_FROM_DATE.plusYears(1).withMonth(12).withDayOfMonth(31);
|
||||
private static final LocalDate UPDATED_MEMBER_UNTIL_DATE = UPDATED_MEMBER_FROM_DATE.plusYears(7).withMonth(12).withDayOfMonth(31);
|
||||
|
||||
private static final LocalDate DEFAULT_MEMBER_UNTIL = DEFAULT_MEMBER_FROM.plusYears(1).withMonth(12).withDayOfMonth(31);
|
||||
private static final LocalDate UPDATED_MEMBER_UNTIL = UPDATED_MEMBER_FROM.plusYears(7).withMonth(12).withDayOfMonth(31);
|
||||
private static final LocalDate DEFAULT_ADMISSION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_ADMISSION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_CANCELLATION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_CANCELLATION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_MEMBER_FROM_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_MEMBER_FROM_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_MEMBER_UNTIL_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_MEMBER_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
|
||||
private static final String UPDATED_REMARK = "BBBBBBBBBB";
|
||||
|
||||
@ -156,9 +142,9 @@ public class MembershipResourceIntTest {
|
||||
*/
|
||||
public static Membership createPersistentEntity(EntityManager em, final Customer customer) {
|
||||
Membership membership = new Membership()
|
||||
.admissionDate(DEFAULT_ADMISSION_DATE)
|
||||
.memberFrom(DEFAULT_MEMBER_FROM)
|
||||
.memberUntil(DEFAULT_MEMBER_UNTIL)
|
||||
.admissionDocumentDate(DEFAULT_ADMISSION_DOCUMENT_DATE)
|
||||
.memberFromDate(DEFAULT_MEMBER_FROM_DATE)
|
||||
.memberUntilDate(DEFAULT_MEMBER_UNTIL_DATE)
|
||||
.remark(DEFAULT_REMARK);
|
||||
// Add required entity
|
||||
membership.setCustomer(customer);
|
||||
@ -596,11 +582,9 @@ public class MembershipResourceIntTest {
|
||||
@Transactional
|
||||
public void getAllMembershipsByShareIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
Share share = ShareResourceIntTest.createEntity(em);
|
||||
em.persist(share);
|
||||
em.flush();
|
||||
membership.addShare(share);
|
||||
membershipRepository.saveAndFlush(membership);
|
||||
Share share = ShareResourceIntTest.createPersistentEntity(em, membership);
|
||||
|
||||
Long shareId = share.getId();
|
||||
|
||||
// Get all the membershipList where share equals to shareId
|
||||
@ -615,11 +599,9 @@ public class MembershipResourceIntTest {
|
||||
@Transactional
|
||||
public void getAllMembershipsByAssetIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
Asset asset = AssetResourceIntTest.createEntity(em);
|
||||
em.persist(asset);
|
||||
em.flush();
|
||||
membership.addAsset(asset);
|
||||
membershipRepository.saveAndFlush(membership);
|
||||
Asset asset = AssetResourceIntTest.createPersistentEntity(em, membership);
|
||||
|
||||
Long assetId = asset.getId();
|
||||
|
||||
// Get all the membershipList where asset equals to assetId
|
||||
@ -634,9 +616,7 @@ public class MembershipResourceIntTest {
|
||||
@Transactional
|
||||
public void getAllMembershipsByCustomerIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
Customer customer = CustomerResourceIntTest.createEntity(em);
|
||||
em.persist(customer);
|
||||
em.flush();
|
||||
Customer customer = CustomerResourceIntTest.createPersistentEntity(em);
|
||||
membership.setCustomer(customer);
|
||||
membershipRepository.saveAndFlush(membership);
|
||||
Long customerId = customer.getId();
|
||||
@ -761,11 +741,11 @@ public class MembershipResourceIntTest {
|
||||
// Delete the membership
|
||||
restMembershipMockMvc.perform(delete("/api/memberships/{id}", membership.getId())
|
||||
.accept(TestUtil.APPLICATION_JSON_UTF8))
|
||||
.andExpect(status().isOk());
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
// Validate the database is empty
|
||||
// Validate the database is unchanged
|
||||
List<Membership> membershipList = membershipRepository.findAll();
|
||||
assertThat(membershipList).hasSize(databaseSizeBeforeDelete - 1);
|
||||
assertThat(membershipList).hasSize(databaseSizeBeforeDelete);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -9,7 +9,6 @@ import org.hostsharing.hsadminng.service.SepaMandateService;
|
||||
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
|
||||
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
|
||||
import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria;
|
||||
import org.hostsharing.hsadminng.service.SepaMandateQueryService;
|
||||
|
||||
import org.junit.Before;
|
||||
@ -60,29 +59,21 @@ public class SepaMandateResourceIntTest {
|
||||
private static final LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_VALID_FROM = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_VALID_FROM = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_VALID_UNTIL = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_VALID_UNTIL = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_LAST_USED = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_LAST_USED = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_CANCELLATION_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_CANCELLATION_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
private static final LocalDate DEFAULT_GRANTING_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_GRANTING_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_REVOKATION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_REVOKATION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_VALID_FROM_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_VALID_FROM_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_VALID_UNTIL_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_VALID_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_LAST_USED = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_LAST_USED = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_REVOKATION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_REVOKATION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_GRANTING_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_GRANTING_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
private static final LocalDate DEFAULT_LAST_USED_DATE = LocalDate.ofEpochDay(0L);
|
||||
private static final LocalDate UPDATED_LAST_USED_DATE = LocalDate.now(ZoneId.systemDefault());
|
||||
|
||||
@ -157,6 +148,28 @@ public class SepaMandateResourceIntTest {
|
||||
return sepaMandate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an entity for tests with a specific customer.
|
||||
*
|
||||
* 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 SepaMandate createEntity(EntityManager em, final Customer customer) {
|
||||
SepaMandate sepaMandate = new SepaMandate()
|
||||
.reference(DEFAULT_REFERENCE)
|
||||
.iban(DEFAULT_IBAN)
|
||||
.bic(DEFAULT_BIC)
|
||||
.grantingDocumentDate(DEFAULT_GRANTING_DOCUMENT_DATE)
|
||||
.validFromDate(DEFAULT_VALID_FROM_DATE)
|
||||
.validUntilDate(DEFAULT_VALID_UNTIL_DATE)
|
||||
.lastUsedDate(DEFAULT_LAST_USED)
|
||||
.revokationDocumentDate(DEFAULT_REVOKATION_DOCUMENT_DATE)
|
||||
.remark(DEFAULT_REMARK);
|
||||
// Add required entity
|
||||
sepaMandate.setCustomer(customer);
|
||||
return sepaMandate;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void initTest() {
|
||||
sepaMandate = createEntity(em);
|
||||
@ -800,9 +813,7 @@ public class SepaMandateResourceIntTest {
|
||||
@Transactional
|
||||
public void getAllSepaMandatesByCustomerIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
Customer customer = CustomerResourceIntTest.createEntity(em);
|
||||
em.persist(customer);
|
||||
em.flush();
|
||||
Customer customer = CustomerResourceIntTest.createPersistentEntity(em);
|
||||
sepaMandate.setCustomer(customer);
|
||||
sepaMandateRepository.saveAndFlush(sepaMandate);
|
||||
Long customerId = customer.getId();
|
||||
|
@ -128,6 +128,27 @@ public class ShareResourceIntTest {
|
||||
return share;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a persistent entity related to the given persistent membership 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 Share createPersistentEntity(EntityManager em, final Membership membership) {
|
||||
Share share = new Share()
|
||||
.documentDate(DEFAULT_DOCUMENT_DATE)
|
||||
.valueDate(DEFAULT_VALUE_DATE)
|
||||
.action(DEFAULT_ACTION)
|
||||
.quantity(DEFAULT_QUANTITY)
|
||||
.remark(DEFAULT_REMARK);
|
||||
// Add required entity
|
||||
share.setMembership(membership);
|
||||
membership.addShare(share);
|
||||
em.persist(share);
|
||||
em.flush();
|
||||
return share;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void initTest() {
|
||||
share = createEntity(em);
|
||||
@ -568,9 +589,7 @@ public class ShareResourceIntTest {
|
||||
@Transactional
|
||||
public void getAllSharesByMembershipIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
Membership membership = MembershipResourceIntTest.createEntity(em);
|
||||
em.persist(membership);
|
||||
em.flush();
|
||||
Membership membership = MembershipResourceIntTest.createPersistentEntity(em, CustomerResourceIntTest.createPersistentEntity(em));
|
||||
share.setMembership(membership);
|
||||
shareRepository.saveAndFlush(share);
|
||||
Long membershipId = membership.getId();
|
||||
@ -652,17 +671,18 @@ public class ShareResourceIntTest {
|
||||
restShareMockMvc.perform(put("/api/shares")
|
||||
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
|
||||
.andExpect(status().isOk());
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
// Validate the Share in the database
|
||||
// Validate the database is unchanged
|
||||
List<Share> shareList = shareRepository.findAll();
|
||||
assertThat(shareList).hasSize(databaseSizeBeforeUpdate);
|
||||
|
||||
Share testShare = shareList.get(shareList.size() - 1);
|
||||
assertThat(testShare.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
|
||||
assertThat(testShare.getValueDate()).isEqualTo(UPDATED_VALUE_DATE);
|
||||
assertThat(testShare.getAction()).isEqualTo(UPDATED_ACTION);
|
||||
assertThat(testShare.getQuantity()).isEqualTo(UPDATED_QUANTITY);
|
||||
assertThat(testShare.getRemark()).isEqualTo(UPDATED_REMARK);
|
||||
assertThat(testShare.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
|
||||
assertThat(testShare.getValueDate()).isEqualTo(DEFAULT_VALUE_DATE);
|
||||
assertThat(testShare.getAction()).isEqualTo(DEFAULT_ACTION);
|
||||
assertThat(testShare.getQuantity()).isEqualTo(DEFAULT_QUANTITY);
|
||||
assertThat(testShare.getRemark()).isEqualTo(DEFAULT_REMARK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -695,11 +715,11 @@ public class ShareResourceIntTest {
|
||||
// Delete the share
|
||||
restShareMockMvc.perform(delete("/api/shares/{id}", share.getId())
|
||||
.accept(TestUtil.APPLICATION_JSON_UTF8))
|
||||
.andExpect(status().isOk());
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
// Validate the database is empty
|
||||
// Validate the database is unchanged
|
||||
List<Share> shareList = shareRepository.findAll();
|
||||
assertThat(shareList).hasSize(databaseSizeBeforeDelete - 1);
|
||||
assertThat(shareList).hasSize(databaseSizeBeforeDelete);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user