diff --git a/.jhipster/Asset.json b/.jhipster/Asset.json index cb941126..8da741c9 100644 --- a/.jhipster/Asset.json +++ b/.jhipster/Asset.json @@ -46,10 +46,10 @@ "otherEntityRelationshipName": "asset", "relationshipValidateRules": "required", "relationshipName": "membership", - "otherEntityField": "documentDate" + "otherEntityField": "admissionDocumentDate" } ], - "changelogDate": "20190418143053", + "changelogDate": "20190424123258", "entityTableName": "asset", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/.jhipster/Customer.json b/.jhipster/Customer.json index dd33afe4..2819d558 100644 --- a/.jhipster/Customer.json +++ b/.jhipster/Customer.json @@ -34,6 +34,58 @@ ], "fieldValidateRulesMaxlength": 80 }, + { + "fieldName": "kind", + "fieldType": "CustomerKind", + "fieldValues": "NATURAL,LEGAL", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "birthDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "birthPlace", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 80 + }, + { + "fieldName": "registrationCourt", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 80 + }, + { + "fieldName": "registrationNumber", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 80 + }, + { + "fieldName": "vatRegion", + "fieldType": "VatRegion", + "fieldValues": "DOMESTIC,EU,OTHER", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "vatNumber", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 40 + }, { "fieldName": "contractualSalutation", "fieldType": "String", @@ -90,7 +142,7 @@ "relationshipName": "sepamandate" } ], - "changelogDate": "20190418143050", + "changelogDate": "20190424123255", "entityTableName": "customer", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/.jhipster/Membership.json b/.jhipster/Membership.json index dff081ff..17d9c161 100644 --- a/.jhipster/Membership.json +++ b/.jhipster/Membership.json @@ -2,21 +2,25 @@ "name": "Membership", "fields": [ { - "fieldName": "documentDate", + "fieldName": "admissionDocumentDate", "fieldType": "LocalDate", "fieldValidateRules": [ "required" ] }, { - "fieldName": "memberFrom", + "fieldName": "cancellationDocumentDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "memberFromDate", "fieldType": "LocalDate", "fieldValidateRules": [ "required" ] }, { - "fieldName": "memberUntil", + "fieldName": "memberUntilDate", "fieldType": "LocalDate" }, { @@ -50,7 +54,7 @@ "otherEntityField": "prefix" } ], - "changelogDate": "20190418143051", + "changelogDate": "20190424123256", "entityTableName": "membership", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/.jhipster/SepaMandate.json b/.jhipster/SepaMandate.json index 8e5c7fdf..e04d2c2b 100644 --- a/.jhipster/SepaMandate.json +++ b/.jhipster/SepaMandate.json @@ -28,29 +28,29 @@ "fieldValidateRulesMaxlength": 11 }, { - "fieldName": "documentDate", + "fieldName": "grantingDocumentDate", "fieldType": "LocalDate", "fieldValidateRules": [ "required" ] }, { - "fieldName": "validFrom", + "fieldName": "revokationDocumentDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "validFromDate", "fieldType": "LocalDate", "fieldValidateRules": [ "required" ] }, { - "fieldName": "validUntil", + "fieldName": "validUntilDate", "fieldType": "LocalDate" }, { - "fieldName": "lastUsed", - "fieldType": "LocalDate" - }, - { - "fieldName": "cancellationDate", + "fieldName": "lastUsedDate", "fieldType": "LocalDate" }, { @@ -72,7 +72,7 @@ "otherEntityField": "prefix" } ], - "changelogDate": "20190418143054", + "changelogDate": "20190424123259", "entityTableName": "sepa_mandate", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/.jhipster/Share.json b/.jhipster/Share.json index 5ea62ab2..4416d50f 100644 --- a/.jhipster/Share.json +++ b/.jhipster/Share.json @@ -46,10 +46,10 @@ "otherEntityRelationshipName": "share", "relationshipValidateRules": "required", "relationshipName": "membership", - "otherEntityField": "documentDate" + "otherEntityField": "admissionDocumentDate" } ], - "changelogDate": "20190418143052", + "changelogDate": "20190424123257", "entityTableName": "share", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/README.md b/README.md index 063c4000..836ec401 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,12 @@ Either simply: or with a specific port: SERVER_PORT=8081 ./gradlew bootRun + +== Running JUnit tests with branch coverage + +=== for IntelliJ IDEA + +see: https://confluence.jetbrains.com/display/IDEADEV/IDEA+Coverage+Runner + +Either apply it to specific test configurations or, +better, delete the previous test configurations and amend the JUnit template. diff --git a/build.gradle b/build.gradle index 7efa4725..dcdd80df 100644 --- a/build.gradle +++ b/build.gradle @@ -208,12 +208,29 @@ task cucumberTestReport(type: TestReport) { pitest { targetClasses = ['org.hostsharing.hsadminng.*'] + + excludedClasses = [ + // Unit Testing Spring configurations makes little sense in most cases. + 'org.hostsharing.hsadminng.config.*', + 'org.hostsharing.hsadminng.ApplicationWebXml', + 'org.hostsharing.hsadminng.HsadminNgApp', + + // Unit testing this would need PowerMock and + // blackbox testing of random values has little value. + 'org.hostsharing.hsadminng.service.util.RandomUtil', + + // The following are mostly generated classes, + // as soon as we amend these, consider removing the exclude. + 'org.hostsharing.hsadminng.**Criteria', + 'org.hostsharing.hsadminng.aop.logging.*', + 'org.hostsharing.hsadminng.web.api.*' // API helpers, not the API itself + ] threads = 2 - // Do not set these limit even lower, they are already pretty bad values! - // 83%*78% means that only ~66% of the code is properly covered by automated tests. - mutationThreshold = 78 - coverageThreshold = 83 + // Do not set these limit lower! 90% each might sound good, but keep in mind: + // 90%*90% means that ~81% of the code are properly covered by automated tests. + mutationThreshold = 90 + coverageThreshold = 90 outputFormats = ['XML', 'HTML'] timestampedReports = false diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java index 3149e14c..97410eba 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java @@ -2,17 +2,16 @@ package org.hostsharing.hsadminng.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; import javax.persistence.*; -import javax.validation.constraints.*; - +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.io.Serializable; import java.math.BigDecimal; import java.time.LocalDate; import java.util.Objects; -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; - /** * A Asset. */ @@ -21,6 +20,8 @@ import org.hostsharing.hsadminng.domain.enumeration.AssetAction; public class Asset implements Serializable { private static final long serialVersionUID = 1L; + + public static final String ENTITY_NAME = "asset"; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") @@ -48,8 +49,8 @@ public class Asset implements Serializable { @Column(name = "remark", length = 160) private String remark; - @NotNull @ManyToOne(optional = false) + @NotNull @JsonIgnoreProperties("assets") private Membership membership; diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java index 8f5aa792..b1745ea5 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java @@ -1,9 +1,13 @@ package org.hostsharing.hsadminng.domain; +import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; +import org.hostsharing.hsadminng.domain.enumeration.VatRegion; + import javax.persistence.*; import javax.validation.constraints.*; import java.io.Serializable; +import java.time.LocalDate; import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -39,6 +43,35 @@ public class Customer implements Serializable { @Column(name = "name", length = 80, nullable = false) private String name; + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "kind", nullable = false) + private CustomerKind kind; + + @Column(name = "birth_date") + private LocalDate birthDate; + + @Size(max = 80) + @Column(name = "birth_place", length = 80) + private String birthPlace; + + @Size(max = 80) + @Column(name = "registration_court", length = 80) + private String registrationCourt; + + @Size(max = 80) + @Column(name = "registration_number", length = 80) + private String registrationNumber; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "vat_region", nullable = false) + private VatRegion vatRegion; + + @Size(max = 40) + @Column(name = "vat_number", length = 40) + private String vatNumber; + @Size(max = 80) @Column(name = "contractual_salutation", length = 80) private String contractualSalutation; @@ -120,6 +153,97 @@ public class Customer implements Serializable { this.name = name; } + public CustomerKind getKind() { + return kind; + } + + public Customer kind(CustomerKind kind) { + this.kind = kind; + return this; + } + + public void setKind(CustomerKind kind) { + this.kind = kind; + } + + public LocalDate getBirthDate() { + return birthDate; + } + + public Customer birthDate(LocalDate birthDate) { + this.birthDate = birthDate; + return this; + } + + public void setBirthDate(LocalDate birthDate) { + this.birthDate = birthDate; + } + + public String getBirthPlace() { + return birthPlace; + } + + public Customer birthPlace(String birthPlace) { + this.birthPlace = birthPlace; + return this; + } + + public void setBirthPlace(String birthPlace) { + this.birthPlace = birthPlace; + } + + public String getRegistrationCourt() { + return registrationCourt; + } + + public Customer registrationCourt(String registrationCourt) { + this.registrationCourt = registrationCourt; + return this; + } + + public void setRegistrationCourt(String registrationCourt) { + this.registrationCourt = registrationCourt; + } + + public String getRegistrationNumber() { + return registrationNumber; + } + + public Customer registrationNumber(String registrationNumber) { + this.registrationNumber = registrationNumber; + return this; + } + + public void setRegistrationNumber(String registrationNumber) { + this.registrationNumber = registrationNumber; + } + + public VatRegion getVatRegion() { + return vatRegion; + } + + public Customer vatRegion(VatRegion vatRegion) { + this.vatRegion = vatRegion; + return this; + } + + public void setVatRegion(VatRegion vatRegion) { + this.vatRegion = vatRegion; + } + + public String getVatNumber() { + return vatNumber; + } + + public Customer vatNumber(String vatNumber) { + this.vatNumber = vatNumber; + return this; + } + + public void setVatNumber(String vatNumber) { + this.vatNumber = vatNumber; + } + public String getContractualSalutation() { return contractualSalutation; } @@ -264,6 +388,13 @@ public class Customer implements Serializable { ", reference=" + getReference() + ", prefix='" + getPrefix() + "'" + ", name='" + getName() + "'" + + ", kind='" + getKind() + "'" + + ", birthDate='" + getBirthDate() + "'" + + ", birthPlace='" + getBirthPlace() + "'" + + ", registrationCourt='" + getRegistrationCourt() + "'" + + ", registrationNumber='" + getRegistrationNumber() + "'" + + ", vatRegion='" + getVatRegion() + "'" + + ", vatNumber='" + getVatNumber() + "'" + ", contractualSalutation='" + getContractualSalutation() + "'" + ", contractualAddress='" + getContractualAddress() + "'" + ", billingSalutation='" + getBillingSalutation() + "'" + diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java index 91749ff7..0e6f4b0e 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java @@ -29,15 +29,18 @@ public class Membership implements Serializable { private Long id; @NotNull - @Column(name = "document_date", nullable = false) - private LocalDate documentDate; + @Column(name = "admission_document_date", nullable = false) + private LocalDate admissionDocumentDate; + + @Column(name = "cancellation_document_date") + private LocalDate cancellationDocumentDate; @NotNull - @Column(name = "member_from", nullable = false) - private LocalDate memberFrom; + @Column(name = "member_from_date", nullable = false) + private LocalDate memberFromDate; - @Column(name = "member_until") - private LocalDate memberUntil; + @Column(name = "member_until_date") + private LocalDate memberUntilDate; @Size(max = 160) @Column(name = "remark", length = 160) @@ -69,43 +72,56 @@ public class Membership implements Serializable { this.id = id; } - public LocalDate getDocumentDate() { - return documentDate; + public LocalDate getAdmissionDocumentDate() { + return admissionDocumentDate; } - public Membership documentDate(LocalDate documentDate) { - this.documentDate = documentDate; + public Membership admissionDocumentDate(LocalDate admissionDocumentDate) { + this.admissionDocumentDate = admissionDocumentDate; return this; } - public void setDocumentDate(LocalDate documentDate) { - this.documentDate = documentDate; + public void setAdmissionDocumentDate(LocalDate admissionDocumentDate) { + this.admissionDocumentDate = admissionDocumentDate; } - public LocalDate getMemberFrom() { - return memberFrom; + public LocalDate getCancellationDocumentDate() { + return cancellationDocumentDate; } - public Membership memberFrom(LocalDate memberFrom) { - this.memberFrom = memberFrom; + public Membership cancellationDocumentDate(LocalDate cancellationDocumentDate) { + this.cancellationDocumentDate = cancellationDocumentDate; return this; } - public void setMemberFrom(LocalDate memberFrom) { - this.memberFrom = memberFrom; + public void setCancellationDocumentDate(LocalDate cancellationDocumentDate) { + this.cancellationDocumentDate = cancellationDocumentDate; } - public LocalDate getMemberUntil() { - return memberUntil; + public LocalDate getMemberFromDate() { + return memberFromDate; } - public Membership memberUntil(LocalDate memberUntil) { - this.memberUntil = memberUntil; + public Membership memberFromDate(LocalDate memberFromDate) { + this.memberFromDate = memberFromDate; return this; } - public void setMemberUntil(LocalDate memberUntil) { - this.memberUntil = memberUntil; + public void setMemberFromDate(LocalDate memberFromDate) { + this.memberFromDate = memberFromDate; + } + + public LocalDate getMemberUntilDate() { + return memberUntilDate; + } + + public Membership memberUntilDate(LocalDate memberUntilDate) { + this.memberUntilDate = memberUntilDate; + return this; + } + + public void setMemberUntilDate(LocalDate memberUntilDate) { + this.memberUntilDate = memberUntilDate; } public String getRemark() { @@ -210,9 +226,10 @@ public class Membership implements Serializable { public String toString() { return "Membership{" + "id=" + getId() + - ", documentDate='" + getDocumentDate() + "'" + - ", memberFrom='" + getMemberFrom() + "'" + - ", memberUntil='" + getMemberUntil() + "'" + + ", admissionDocumentDate='" + getAdmissionDocumentDate() + "'" + + ", cancellationDocumentDate='" + getCancellationDocumentDate() + "'" + + ", memberFromDate='" + getMemberFromDate() + "'" + + ", memberUntilDate='" + getMemberUntilDate() + "'" + ", remark='" + getRemark() + "'" + "}"; } diff --git a/src/main/java/org/hostsharing/hsadminng/domain/SepaMandate.java b/src/main/java/org/hostsharing/hsadminng/domain/SepaMandate.java index 3c7741df..6edc6e09 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/SepaMandate.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/SepaMandate.java @@ -4,8 +4,8 @@ package org.hostsharing.hsadminng.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.persistence.*; -import javax.validation.constraints.*; - +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.io.Serializable; import java.time.LocalDate; import java.util.Objects; @@ -38,21 +38,21 @@ public class SepaMandate implements Serializable { private String bic; @NotNull - @Column(name = "document_date", nullable = false) - private LocalDate documentDate; + @Column(name = "granting_document_date", nullable = false) + private LocalDate grantingDocumentDate; + + @Column(name = "revokation_document_date") + private LocalDate revokationDocumentDate; @NotNull - @Column(name = "valid_from", nullable = false) - private LocalDate validFrom; + @Column(name = "valid_from_date", nullable = false) + private LocalDate validFromDate; - @Column(name = "valid_until") - private LocalDate validUntil; + @Column(name = "valid_until_date") + private LocalDate validUntilDate; - @Column(name = "last_used") - private LocalDate lastUsed; - - @Column(name = "cancellation_date") - private LocalDate cancellationDate; + @Column(name = "last_used_date") + private LocalDate lastUsedDate; @Size(max = 160) @Column(name = "remark", length = 160) @@ -111,69 +111,69 @@ public class SepaMandate implements Serializable { this.bic = bic; } - public LocalDate getDocumentDate() { - return documentDate; + public LocalDate getGrantingDocumentDate() { + return grantingDocumentDate; } - public SepaMandate documentDate(LocalDate documentDate) { - this.documentDate = documentDate; + public SepaMandate grantingDocumentDate(LocalDate grantingDocumentDate) { + this.grantingDocumentDate = grantingDocumentDate; return this; } - public void setDocumentDate(LocalDate documentDate) { - this.documentDate = documentDate; + public void setGrantingDocumentDate(LocalDate grantingDocumentDate) { + this.grantingDocumentDate = grantingDocumentDate; } - public LocalDate getValidFrom() { - return validFrom; + public LocalDate getRevokationDocumentDate() { + return revokationDocumentDate; } - public SepaMandate validFrom(LocalDate validFrom) { - this.validFrom = validFrom; + public SepaMandate revokationDocumentDate(LocalDate revokationDocumentDate) { + this.revokationDocumentDate = revokationDocumentDate; return this; } - public void setValidFrom(LocalDate validFrom) { - this.validFrom = validFrom; + public void setRevokationDocumentDate(LocalDate revokationDocumentDate) { + this.revokationDocumentDate = revokationDocumentDate; } - public LocalDate getValidUntil() { - return validUntil; + public LocalDate getValidFromDate() { + return validFromDate; } - public SepaMandate validUntil(LocalDate validUntil) { - this.validUntil = validUntil; + public SepaMandate validFromDate(LocalDate validFromDate) { + this.validFromDate = validFromDate; return this; } - public void setValidUntil(LocalDate validUntil) { - this.validUntil = validUntil; + public void setValidFromDate(LocalDate validFromDate) { + this.validFromDate = validFromDate; } - public LocalDate getLastUsed() { - return lastUsed; + public LocalDate getValidUntilDate() { + return validUntilDate; } - public SepaMandate lastUsed(LocalDate lastUsed) { - this.lastUsed = lastUsed; + public SepaMandate validUntilDate(LocalDate validUntilDate) { + this.validUntilDate = validUntilDate; return this; } - public void setLastUsed(LocalDate lastUsed) { - this.lastUsed = lastUsed; + public void setValidUntilDate(LocalDate validUntilDate) { + this.validUntilDate = validUntilDate; } - public LocalDate getCancellationDate() { - return cancellationDate; + public LocalDate getLastUsedDate() { + return lastUsedDate; } - public SepaMandate cancellationDate(LocalDate cancellationDate) { - this.cancellationDate = cancellationDate; + public SepaMandate lastUsedDate(LocalDate lastUsedDate) { + this.lastUsedDate = lastUsedDate; return this; } - public void setCancellationDate(LocalDate cancellationDate) { - this.cancellationDate = cancellationDate; + public void setLastUsedDate(LocalDate lastUsedDate) { + this.lastUsedDate = lastUsedDate; } public String getRemark() { @@ -230,11 +230,11 @@ public class SepaMandate implements Serializable { ", reference='" + getReference() + "'" + ", iban='" + getIban() + "'" + ", bic='" + getBic() + "'" + - ", documentDate='" + getDocumentDate() + "'" + - ", validFrom='" + getValidFrom() + "'" + - ", validUntil='" + getValidUntil() + "'" + - ", lastUsed='" + getLastUsed() + "'" + - ", cancellationDate='" + getCancellationDate() + "'" + + ", grantingDocumentDate='" + getGrantingDocumentDate() + "'" + + ", revokationDocumentDate='" + getRevokationDocumentDate() + "'" + + ", validFromDate='" + getValidFromDate() + "'" + + ", validUntilDate='" + getValidUntilDate() + "'" + + ", lastUsedDate='" + getLastUsedDate() + "'" + ", remark='" + getRemark() + "'" + "}"; } diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Share.java b/src/main/java/org/hostsharing/hsadminng/domain/Share.java index a1d0e3c2..76923dd2 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Share.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Share.java @@ -2,16 +2,15 @@ package org.hostsharing.hsadminng.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; import javax.persistence.*; -import javax.validation.constraints.*; - +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.io.Serializable; import java.time.LocalDate; import java.util.Objects; -import org.hostsharing.hsadminng.domain.enumeration.ShareAction; - /** * A Share. */ @@ -49,8 +48,8 @@ public class Share implements Serializable { @Column(name = "remark", length = 160) private String remark; - @NotNull @ManyToOne(optional = false) + @NotNull @JsonIgnoreProperties("shares") private Membership membership; diff --git a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerKind.java b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerKind.java new file mode 100644 index 00000000..46092119 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerKind.java @@ -0,0 +1,8 @@ +package org.hostsharing.hsadminng.domain.enumeration; + +/** + * The CustomerKind enumeration. + */ +public enum CustomerKind { + NATURAL, LEGAL +} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/VatRegion.java b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/VatRegion.java new file mode 100644 index 00000000..22bf49ac --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/VatRegion.java @@ -0,0 +1,8 @@ +package org.hostsharing.hsadminng.domain.enumeration; + +/** + * The VatRegion enumeration. + */ +public enum VatRegion { + DOMESTIC, EU, OTHER +} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java index b62fa01e..95810440 100644 --- a/src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java +++ b/src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java @@ -16,6 +16,6 @@ import org.springframework.stereotype.Repository; public interface MembershipRepository extends JpaRepository, JpaSpecificationExecutor { @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); } diff --git a/src/main/java/org/hostsharing/hsadminng/service/AssetService.java b/src/main/java/org/hostsharing/hsadminng/service/AssetService.java index 0b6ab5a9..bc15e0b3 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/AssetService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/AssetService.java @@ -6,7 +6,6 @@ import org.hostsharing.hsadminng.service.dto.AssetDTO; import org.hostsharing.hsadminng.service.mapper.AssetMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -26,10 +25,12 @@ public class AssetService { private final AssetRepository assetRepository; private final AssetMapper assetMapper; + private final AssetValidator assetValidator; - public AssetService(AssetRepository assetRepository, AssetMapper assetMapper) { + public AssetService(AssetRepository assetRepository, AssetMapper assetMapper, AssetValidator assetValidator ) { this.assetRepository = assetRepository; this.assetMapper = assetMapper; + this.assetValidator = assetValidator; } /** @@ -40,6 +41,7 @@ public class AssetService { */ public AssetDTO save(AssetDTO assetDTO) { log.debug("Request to save Asset : {}", assetDTO); + assetValidator.validate(assetDTO); Asset asset = assetMapper.toEntity(assetDTO); asset = assetRepository.save(asset); return assetMapper.toDto(asset); diff --git a/src/main/java/org/hostsharing/hsadminng/service/AssetValidator.java b/src/main/java/org/hostsharing/hsadminng/service/AssetValidator.java new file mode 100644 index 00000000..01da9875 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/AssetValidator.java @@ -0,0 +1,43 @@ +package org.hostsharing.hsadminng.service; + +import org.hostsharing.hsadminng.domain.Asset; +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; +import org.hostsharing.hsadminng.service.dto.AssetDTO; +import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; + +@Service +public class AssetValidator { + public void validate(final AssetDTO assetDTO) { + if (assetDTO.getId() != null) { + throw new BadRequestAlertException("Asset transactions are immutable", Asset.ENTITY_NAME, "assetTransactionImmutable"); + } + + if (assetDTO.getDocumentDate().isAfter(assetDTO.getValueDate())) { + throw new BadRequestAlertException("Document date may not be after value date", Asset.ENTITY_NAME, "documentDateMayNotBeAfterValueDate"); + } + + if ((assetDTO.getAction() == AssetAction.PAYMENT) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) <= 0)) { + throw new BadRequestAlertException("Asset payments require a positive amount", Asset.ENTITY_NAME, "assetPaymentsPositiveAmount"); + } + if ((assetDTO.getAction() == AssetAction.ADOPTION) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) <= 0)) { + throw new BadRequestAlertException("Asset adoptions require a positive amount", Asset.ENTITY_NAME, "assetAdoptionsPositiveAmount"); + } + + if ((assetDTO.getAction() == AssetAction.PAYBACK) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) { + throw new BadRequestAlertException("Asset paybacks require a negative amount", Asset.ENTITY_NAME, "assetPaybacksNegativeAmount"); + } + if ((assetDTO.getAction() == AssetAction.HANDOVER) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) { + throw new BadRequestAlertException("Asset handovers require a negative amount", Asset.ENTITY_NAME, "assetHandoversNegativeAmount"); + } + if ((assetDTO.getAction() == AssetAction.LOSS) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) { + throw new BadRequestAlertException("Asset losses require a negative amount", Asset.ENTITY_NAME, "assetLossesNegativeAmount"); + } + if ((assetDTO.getAction() == AssetAction.CLEARING) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) { + throw new BadRequestAlertException("Asset clearings require a negative amount", Asset.ENTITY_NAME, "assetClearingsNegativeAmount"); + } + + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java index 937322d1..718575f0 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java @@ -1,9 +1,14 @@ package org.hostsharing.hsadminng.service; -import java.util.List; - -import javax.persistence.criteria.JoinType; - +import io.github.jhipster.service.QueryService; +import org.hostsharing.hsadminng.domain.Customer; +import org.hostsharing.hsadminng.domain.Customer_; +import org.hostsharing.hsadminng.domain.Membership_; +import org.hostsharing.hsadminng.domain.SepaMandate_; +import org.hostsharing.hsadminng.repository.CustomerRepository; +import org.hostsharing.hsadminng.service.dto.CustomerCriteria; +import org.hostsharing.hsadminng.service.dto.CustomerDTO; +import org.hostsharing.hsadminng.service.mapper.CustomerMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; @@ -12,14 +17,8 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import io.github.jhipster.service.QueryService; - -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.*; // for static metamodels -import org.hostsharing.hsadminng.repository.CustomerRepository; -import org.hostsharing.hsadminng.service.dto.CustomerCriteria; -import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerMapper; +import javax.persistence.criteria.JoinType; +import java.util.List; /** * Service for executing complex queries for Customer entities in the database. @@ -98,6 +97,27 @@ public class CustomerQueryService extends QueryService { if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Customer_.name)); } + if (criteria.getKind() != null) { + specification = specification.and(buildSpecification(criteria.getKind(), Customer_.kind)); + } + if (criteria.getBirthDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getBirthDate(), Customer_.birthDate)); + } + if (criteria.getBirthPlace() != null) { + specification = specification.and(buildStringSpecification(criteria.getBirthPlace(), Customer_.birthPlace)); + } + if (criteria.getRegistrationCourt() != null) { + specification = specification.and(buildStringSpecification(criteria.getRegistrationCourt(), Customer_.registrationCourt)); + } + if (criteria.getRegistrationNumber() != null) { + specification = specification.and(buildStringSpecification(criteria.getRegistrationNumber(), Customer_.registrationNumber)); + } + if (criteria.getVatRegion() != null) { + specification = specification.and(buildSpecification(criteria.getVatRegion(), Customer_.vatRegion)); + } + if (criteria.getVatNumber() != null) { + specification = specification.and(buildStringSpecification(criteria.getVatNumber(), Customer_.vatNumber)); + } if (criteria.getContractualSalutation() != null) { specification = specification.and(buildStringSpecification(criteria.getContractualSalutation(), Customer_.contractualSalutation)); } diff --git a/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java index 8ab0bb2f..adb07608 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java @@ -1,9 +1,11 @@ package org.hostsharing.hsadminng.service; -import java.util.List; - -import javax.persistence.criteria.JoinType; - +import io.github.jhipster.service.QueryService; +import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.repository.MembershipRepository; +import org.hostsharing.hsadminng.service.dto.MembershipCriteria; +import org.hostsharing.hsadminng.service.dto.MembershipDTO; +import org.hostsharing.hsadminng.service.mapper.MembershipMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; @@ -12,14 +14,8 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import io.github.jhipster.service.QueryService; - -import org.hostsharing.hsadminng.domain.Membership; -import org.hostsharing.hsadminng.domain.*; // for static metamodels -import org.hostsharing.hsadminng.repository.MembershipRepository; -import org.hostsharing.hsadminng.service.dto.MembershipCriteria; -import org.hostsharing.hsadminng.service.dto.MembershipDTO; -import org.hostsharing.hsadminng.service.mapper.MembershipMapper; +import javax.persistence.criteria.JoinType; +import java.util.List; /** * Service for executing complex queries for Membership entities in the database. @@ -89,14 +85,17 @@ public class MembershipQueryService extends QueryService { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Membership_.id)); } - if (criteria.getDocumentDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), Membership_.documentDate)); + if (criteria.getAdmissionDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getAdmissionDocumentDate(), Membership_.admissionDocumentDate)); } - if (criteria.getMemberFrom() != null) { - specification = specification.and(buildRangeSpecification(criteria.getMemberFrom(), Membership_.memberFrom)); + if (criteria.getCancellationDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getCancellationDocumentDate(), Membership_.cancellationDocumentDate)); } - if (criteria.getMemberUntil() != null) { - specification = specification.and(buildRangeSpecification(criteria.getMemberUntil(), Membership_.memberUntil)); + if (criteria.getMemberFromDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getMemberFromDate(), Membership_.memberFromDate)); + } + if (criteria.getMemberUntilDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getMemberUntilDate(), Membership_.memberUntilDate)); } if (criteria.getRemark() != null) { specification = specification.and(buildStringSpecification(criteria.getRemark(), Membership_.remark)); diff --git a/src/main/java/org/hostsharing/hsadminng/service/MembershipValidator.java b/src/main/java/org/hostsharing/hsadminng/service/MembershipValidator.java index 359a417b..f14e7dad 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/MembershipValidator.java +++ b/src/main/java/org/hostsharing/hsadminng/service/MembershipValidator.java @@ -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"); } diff --git a/src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java index 1e31c8b4..3789d8d1 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java @@ -1,9 +1,13 @@ package org.hostsharing.hsadminng.service; -import java.util.List; - -import javax.persistence.criteria.JoinType; - +import io.github.jhipster.service.QueryService; +import org.hostsharing.hsadminng.domain.Customer_; +import org.hostsharing.hsadminng.domain.SepaMandate; +import org.hostsharing.hsadminng.domain.SepaMandate_; +import org.hostsharing.hsadminng.repository.SepaMandateRepository; +import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria; +import org.hostsharing.hsadminng.service.dto.SepaMandateDTO; +import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; @@ -12,14 +16,8 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import io.github.jhipster.service.QueryService; - -import org.hostsharing.hsadminng.domain.SepaMandate; -import org.hostsharing.hsadminng.domain.*; // for static metamodels -import org.hostsharing.hsadminng.repository.SepaMandateRepository; -import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria; -import org.hostsharing.hsadminng.service.dto.SepaMandateDTO; -import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper; +import javax.persistence.criteria.JoinType; +import java.util.List; /** * Service for executing complex queries for SepaMandate entities in the database. @@ -98,20 +96,20 @@ public class SepaMandateQueryService extends QueryService { if (criteria.getBic() != null) { specification = specification.and(buildStringSpecification(criteria.getBic(), SepaMandate_.bic)); } - if (criteria.getDocumentDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), SepaMandate_.documentDate)); + if (criteria.getGrantingDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getGrantingDocumentDate(), SepaMandate_.grantingDocumentDate)); } - if (criteria.getValidFrom() != null) { - specification = specification.and(buildRangeSpecification(criteria.getValidFrom(), SepaMandate_.validFrom)); + if (criteria.getRevokationDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getRevokationDocumentDate(), SepaMandate_.revokationDocumentDate)); } - if (criteria.getValidUntil() != null) { - specification = specification.and(buildRangeSpecification(criteria.getValidUntil(), SepaMandate_.validUntil)); + if (criteria.getValidFromDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidFromDate(), SepaMandate_.validFromDate)); } - if (criteria.getLastUsed() != null) { - specification = specification.and(buildRangeSpecification(criteria.getLastUsed(), SepaMandate_.lastUsed)); + if (criteria.getValidUntilDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidUntilDate(), SepaMandate_.validUntilDate)); } - if (criteria.getCancellationDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getCancellationDate(), SepaMandate_.cancellationDate)); + if (criteria.getLastUsedDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getLastUsedDate(), SepaMandate_.lastUsedDate)); } if (criteria.getRemark() != null) { specification = specification.and(buildStringSpecification(criteria.getRemark(), SepaMandate_.remark)); diff --git a/src/main/java/org/hostsharing/hsadminng/service/ShareService.java b/src/main/java/org/hostsharing/hsadminng/service/ShareService.java index 76552c01..f144bf9b 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/ShareService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/ShareService.java @@ -1,7 +1,6 @@ package org.hostsharing.hsadminng.service; import org.hostsharing.hsadminng.domain.Share; -import org.hostsharing.hsadminng.domain.enumeration.ShareAction; import org.hostsharing.hsadminng.repository.ShareRepository; import org.hostsharing.hsadminng.service.dto.ShareDTO; import org.hostsharing.hsadminng.service.mapper.ShareMapper; @@ -28,9 +27,12 @@ public class ShareService { private final ShareMapper shareMapper; - public ShareService(ShareRepository shareRepository, ShareMapper shareMapper) { + private final ShareValidator shareValidator; + + public ShareService(ShareRepository shareRepository, ShareMapper shareMapper, ShareValidator shareValidator) { this.shareRepository = shareRepository; this.shareMapper = shareMapper; + this.shareValidator = shareValidator; } /** @@ -42,16 +44,8 @@ public class ShareService { public ShareDTO save(ShareDTO shareDTO) { log.debug("Request to save Share : {}", shareDTO); - if (shareDTO.getId() != null) { - throw new BadRequestAlertException("Share transactions are immutable", Share.ENTITY_NAME, "shareTransactionImmutable"); - } + shareValidator.validate(shareDTO); - if((shareDTO.getAction() == ShareAction.SUBSCRIPTION) && (shareDTO.getQuantity() <= 0)) { - throw new BadRequestAlertException("Share subscriptions require a positive quantity", Share.ENTITY_NAME, "shareSubscriptionPositivQuantity"); - } - if((shareDTO.getAction() == ShareAction.CANCELLATION) && (shareDTO.getQuantity() >= 0)) { - throw new BadRequestAlertException("Share cancellations require a negative quantity", Share.ENTITY_NAME, "shareCancellationNegativeQuantity"); - } Share share = shareMapper.toEntity(shareDTO); share = shareRepository.save(share); return shareMapper.toDto(share); diff --git a/src/main/java/org/hostsharing/hsadminng/service/ShareValidator.java b/src/main/java/org/hostsharing/hsadminng/service/ShareValidator.java new file mode 100644 index 00000000..44479a86 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/ShareValidator.java @@ -0,0 +1,30 @@ +package org.hostsharing.hsadminng.service; + +import org.hostsharing.hsadminng.domain.Share; +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; +import org.hostsharing.hsadminng.service.dto.ShareDTO; +import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; +import org.springframework.stereotype.Service; + +@Service +public class ShareValidator { + + public void validate(final ShareDTO shareDTO) { + if (shareDTO.getId() != null) { + throw new BadRequestAlertException("Share transactions are immutable", Share.ENTITY_NAME, "shareTransactionImmutable"); + } + + if (shareDTO.getDocumentDate().isAfter(shareDTO.getValueDate())) { + throw new BadRequestAlertException("Document date may not be after value date", Share.ENTITY_NAME, "documentDateMayNotBeAfterValueDate"); + } + + if ((shareDTO.getAction() == ShareAction.SUBSCRIPTION) && (shareDTO.getQuantity() <= 0)) { + throw new BadRequestAlertException("Share subscriptions require a positive quantity", Share.ENTITY_NAME, "shareSubscriptionPositiveQuantity"); + } + + if ((shareDTO.getAction() == ShareAction.CANCELLATION) && (shareDTO.getQuantity() >= 0)) { + throw new BadRequestAlertException("Share cancellations require a negative quantity", Share.ENTITY_NAME, "shareCancellationNegativeQuantity"); + } + + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java index 2ed0d828..b79ea4f1 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java @@ -1,10 +1,13 @@ package org.hostsharing.hsadminng.service.dto; -import java.time.LocalDate; -import javax.validation.constraints.*; + +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.io.Serializable; import java.math.BigDecimal; +import java.time.LocalDate; import java.util.Objects; -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; /** * A DTO for the Asset entity. @@ -31,7 +34,7 @@ public class AssetDTO implements Serializable { private Long membershipId; - private String membershipDocumentDate; + private String membershipAdmissionDocumentDate; public Long getId() { return id; @@ -89,12 +92,12 @@ public class AssetDTO implements Serializable { this.membershipId = membershipId; } - public String getMembershipDocumentDate() { - return membershipDocumentDate; + public String getMembershipAdmissionDocumentDate() { + return membershipAdmissionDocumentDate; } - public void setMembershipDocumentDate(String membershipDocumentDate) { - this.membershipDocumentDate = membershipDocumentDate; + public void setMembershipAdmissionDocumentDate(String membershipAdmissionDocumentDate) { + this.membershipAdmissionDocumentDate = membershipAdmissionDocumentDate; } @Override @@ -128,7 +131,7 @@ public class AssetDTO implements Serializable { ", amount=" + getAmount() + ", remark='" + getRemark() + "'" + ", membership=" + getMembershipId() + - ", membership='" + getMembershipDocumentDate() + "'" + + ", membership='" + getMembershipAdmissionDocumentDate() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java index 60d82e58..50fc2a0e 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java @@ -1,14 +1,11 @@ package org.hostsharing.hsadminng.service.dto; +import io.github.jhipster.service.filter.*; +import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; +import org.hostsharing.hsadminng.domain.enumeration.VatRegion; + import java.io.Serializable; import java.util.Objects; -import io.github.jhipster.service.filter.BooleanFilter; -import io.github.jhipster.service.filter.DoubleFilter; -import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.FloatFilter; -import io.github.jhipster.service.filter.IntegerFilter; -import io.github.jhipster.service.filter.LongFilter; -import io.github.jhipster.service.filter.StringFilter; /** * Criteria class for the Customer entity. This class is used in CustomerResource to @@ -19,6 +16,16 @@ import io.github.jhipster.service.filter.StringFilter; * fix type specific filters. */ public class CustomerCriteria implements Serializable { + /** + * Class for filtering CustomerKind + */ + public static class CustomerKindFilter extends Filter { + } + /** + * Class for filtering VatRegion + */ + public static class VatRegionFilter extends Filter { + } private static final long serialVersionUID = 1L; @@ -30,6 +37,20 @@ public class CustomerCriteria implements Serializable { private StringFilter name; + private CustomerKindFilter kind; + + private LocalDateFilter birthDate; + + private StringFilter birthPlace; + + private StringFilter registrationCourt; + + private StringFilter registrationNumber; + + private VatRegionFilter vatRegion; + + private StringFilter vatNumber; + private StringFilter contractualSalutation; private StringFilter contractualAddress; @@ -76,6 +97,62 @@ public class CustomerCriteria implements Serializable { this.name = name; } + public CustomerKindFilter getKind() { + return kind; + } + + public void setKind(CustomerKindFilter kind) { + this.kind = kind; + } + + public LocalDateFilter getBirthDate() { + return birthDate; + } + + public void setBirthDate(LocalDateFilter birthDate) { + this.birthDate = birthDate; + } + + public StringFilter getBirthPlace() { + return birthPlace; + } + + public void setBirthPlace(StringFilter birthPlace) { + this.birthPlace = birthPlace; + } + + public StringFilter getRegistrationCourt() { + return registrationCourt; + } + + public void setRegistrationCourt(StringFilter registrationCourt) { + this.registrationCourt = registrationCourt; + } + + public StringFilter getRegistrationNumber() { + return registrationNumber; + } + + public void setRegistrationNumber(StringFilter registrationNumber) { + this.registrationNumber = registrationNumber; + } + + public VatRegionFilter getVatRegion() { + return vatRegion; + } + + public void setVatRegion(VatRegionFilter vatRegion) { + this.vatRegion = vatRegion; + } + + public StringFilter getVatNumber() { + return vatNumber; + } + + public void setVatNumber(StringFilter vatNumber) { + this.vatNumber = vatNumber; + } + public StringFilter getContractualSalutation() { return contractualSalutation; } @@ -147,6 +224,13 @@ public class CustomerCriteria implements Serializable { Objects.equals(reference, that.reference) && Objects.equals(prefix, that.prefix) && Objects.equals(name, that.name) && + Objects.equals(kind, that.kind) && + Objects.equals(birthDate, that.birthDate) && + Objects.equals(birthPlace, that.birthPlace) && + Objects.equals(registrationCourt, that.registrationCourt) && + Objects.equals(registrationNumber, that.registrationNumber) && + Objects.equals(vatRegion, that.vatRegion) && + Objects.equals(vatNumber, that.vatNumber) && Objects.equals(contractualSalutation, that.contractualSalutation) && Objects.equals(contractualAddress, that.contractualAddress) && Objects.equals(billingSalutation, that.billingSalutation) && @@ -163,6 +247,13 @@ public class CustomerCriteria implements Serializable { reference, prefix, name, + kind, + birthDate, + birthPlace, + registrationCourt, + registrationNumber, + vatRegion, + vatNumber, contractualSalutation, contractualAddress, billingSalutation, @@ -180,6 +271,13 @@ public class CustomerCriteria implements Serializable { (reference != null ? "reference=" + reference + ", " : "") + (prefix != null ? "prefix=" + prefix + ", " : "") + (name != null ? "name=" + name + ", " : "") + + (kind != null ? "kind=" + kind + ", " : "") + + (birthDate != null ? "birthDate=" + birthDate + ", " : "") + + (birthPlace != null ? "birthPlace=" + birthPlace + ", " : "") + + (registrationCourt != null ? "registrationCourt=" + registrationCourt + ", " : "") + + (registrationNumber != null ? "registrationNumber=" + registrationNumber + ", " : "") + + (vatRegion != null ? "vatRegion=" + vatRegion + ", " : "") + + (vatNumber != null ? "vatNumber=" + vatNumber + ", " : "") + (contractualSalutation != null ? "contractualSalutation=" + contractualSalutation + ", " : "") + (contractualAddress != null ? "contractualAddress=" + contractualAddress + ", " : "") + (billingSalutation != null ? "billingSalutation=" + billingSalutation + ", " : "") + diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java index bae6ca25..ceefc0b9 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java @@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; +import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; +import org.hostsharing.hsadminng.domain.enumeration.VatRegion; import org.hostsharing.hsadminng.service.accessfilter.*; import org.springframework.boot.jackson.JsonComponent; import org.springframework.context.ApplicationContext; @@ -13,6 +15,7 @@ import org.springframework.context.ApplicationContext; import javax.validation.constraints.*; import java.io.IOException; import java.io.Serializable; +import java.time.LocalDate; import java.util.Objects; /** @@ -41,6 +44,26 @@ public class CustomerDTO implements Serializable { @AccessFor(init = Role.ADMIN, read = Role.ANY_CUSTOMER_USER) private String name; + @NotNull + private CustomerKind kind; + + private LocalDate birthDate; + + @Size(max = 80) + private String birthPlace; + + @Size(max = 80) + private String registrationCourt; + + @Size(max = 80) + private String registrationNumber; + + @NotNull + private VatRegion vatRegion; + + @Size(max = 40) + private String vatNumber; + @Size(max = 80) @AccessFor(init = Role.ADMIN, update = Role.CONTRACTUAL_CONTACT, read = Role.ANY_CUSTOMER_CONTACT) private String contractualSalutation; @@ -94,6 +117,62 @@ public class CustomerDTO implements Serializable { this.name = name; } + public CustomerKind getKind() { + return kind; + } + + public void setKind(CustomerKind kind) { + this.kind = kind; + } + + public LocalDate getBirthDate() { + return birthDate; + } + + public void setBirthDate(LocalDate birthDate) { + this.birthDate = birthDate; + } + + public String getBirthPlace() { + return birthPlace; + } + + public void setBirthPlace(String birthPlace) { + this.birthPlace = birthPlace; + } + + public String getRegistrationCourt() { + return registrationCourt; + } + + public void setRegistrationCourt(String registrationCourt) { + this.registrationCourt = registrationCourt; + } + + public String getRegistrationNumber() { + return registrationNumber; + } + + public void setRegistrationNumber(String registrationNumber) { + this.registrationNumber = registrationNumber; + } + + public VatRegion getVatRegion() { + return vatRegion; + } + + public void setVatRegion(VatRegion vatRegion) { + this.vatRegion = vatRegion; + } + + public String getVatNumber() { + return vatNumber; + } + + public void setVatNumber(String vatNumber) { + this.vatNumber = vatNumber; + } + public String getContractualSalutation() { return contractualSalutation; } @@ -162,6 +241,13 @@ public class CustomerDTO implements Serializable { ", reference=" + getReference() + ", prefix='" + getPrefix() + "'" + ", name='" + getName() + "'" + + ", kind='" + getKind() + "'" + + ", birthDate='" + getBirthDate() + "'" + + ", birthPlace='" + getBirthPlace() + "'" + + ", registrationCourt='" + getRegistrationCourt() + "'" + + ", registrationNumber='" + getRegistrationNumber() + "'" + + ", vatRegion='" + getVatRegion() + "'" + + ", vatNumber='" + getVatNumber() + "'" + ", contractualSalutation='" + getContractualSalutation() + "'" + ", contractualAddress='" + getContractualAddress() + "'" + ", billingSalutation='" + getBillingSalutation() + "'" + diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java index be8308bc..14d42ed3 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java @@ -1,15 +1,12 @@ package org.hostsharing.hsadminng.service.dto; +import io.github.jhipster.service.filter.Filter; +import io.github.jhipster.service.filter.LocalDateFilter; +import io.github.jhipster.service.filter.LongFilter; +import io.github.jhipster.service.filter.StringFilter; + import java.io.Serializable; import java.util.Objects; -import io.github.jhipster.service.filter.BooleanFilter; -import io.github.jhipster.service.filter.DoubleFilter; -import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.FloatFilter; -import io.github.jhipster.service.filter.IntegerFilter; -import io.github.jhipster.service.filter.LongFilter; -import io.github.jhipster.service.filter.StringFilter; -import io.github.jhipster.service.filter.LocalDateFilter; /** * Criteria class for the Membership entity. This class is used in MembershipResource to @@ -25,11 +22,13 @@ public class MembershipCriteria implements Serializable { private LongFilter id; - private LocalDateFilter documentDate; + private LocalDateFilter admissionDocumentDate; - private LocalDateFilter memberFrom; + private LocalDateFilter cancellationDocumentDate; - private LocalDateFilter memberUntil; + private LocalDateFilter memberFromDate; + + private LocalDateFilter memberUntilDate; private StringFilter remark; @@ -47,28 +46,36 @@ public class MembershipCriteria implements Serializable { this.id = id; } - public LocalDateFilter getDocumentDate() { - return documentDate; + public LocalDateFilter getAdmissionDocumentDate() { + return admissionDocumentDate; } - public void setDocumentDate(LocalDateFilter documentDate) { - this.documentDate = documentDate; + public void setAdmissionDocumentDate(LocalDateFilter admissionDocumentDate) { + this.admissionDocumentDate = admissionDocumentDate; } - public LocalDateFilter getMemberFrom() { - return memberFrom; + public LocalDateFilter getCancellationDocumentDate() { + return cancellationDocumentDate; } - public void setMemberFrom(LocalDateFilter memberFrom) { - this.memberFrom = memberFrom; + public void setCancellationDocumentDate(LocalDateFilter cancellationDocumentDate) { + this.cancellationDocumentDate = cancellationDocumentDate; } - public LocalDateFilter getMemberUntil() { - return memberUntil; + public LocalDateFilter getMemberFromDate() { + return memberFromDate; } - public void setMemberUntil(LocalDateFilter memberUntil) { - this.memberUntil = memberUntil; + public void setMemberFromDate(LocalDateFilter memberFromDate) { + this.memberFromDate = memberFromDate; + } + + public LocalDateFilter getMemberUntilDate() { + return memberUntilDate; + } + + public void setMemberUntilDate(LocalDateFilter memberUntilDate) { + this.memberUntilDate = memberUntilDate; } public StringFilter getRemark() { @@ -115,9 +122,10 @@ public class MembershipCriteria implements Serializable { final MembershipCriteria that = (MembershipCriteria) o; return Objects.equals(id, that.id) && - Objects.equals(documentDate, that.documentDate) && - Objects.equals(memberFrom, that.memberFrom) && - Objects.equals(memberUntil, that.memberUntil) && + Objects.equals(admissionDocumentDate, that.admissionDocumentDate) && + Objects.equals(cancellationDocumentDate, that.cancellationDocumentDate) && + Objects.equals(memberFromDate, that.memberFromDate) && + Objects.equals(memberUntilDate, that.memberUntilDate) && Objects.equals(remark, that.remark) && Objects.equals(shareId, that.shareId) && Objects.equals(assetId, that.assetId) && @@ -128,9 +136,10 @@ public class MembershipCriteria implements Serializable { public int hashCode() { return Objects.hash( id, - documentDate, - memberFrom, - memberUntil, + admissionDocumentDate, + cancellationDocumentDate, + memberFromDate, + memberUntilDate, remark, shareId, assetId, @@ -142,9 +151,10 @@ public class MembershipCriteria implements Serializable { public String toString() { return "MembershipCriteria{" + (id != null ? "id=" + id + ", " : "") + - (documentDate != null ? "documentDate=" + documentDate + ", " : "") + - (memberFrom != null ? "memberFrom=" + memberFrom + ", " : "") + - (memberUntil != null ? "memberUntil=" + memberUntil + ", " : "") + + (admissionDocumentDate != null ? "admissionDocumentDate=" + admissionDocumentDate + ", " : "") + + (cancellationDocumentDate != null ? "cancellationDocumentDate=" + cancellationDocumentDate + ", " : "") + + (memberFromDate != null ? "memberFromDate=" + memberFromDate + ", " : "") + + (memberUntilDate != null ? "memberUntilDate=" + memberUntilDate + ", " : "") + (remark != null ? "remark=" + remark + ", " : "") + (shareId != null ? "shareId=" + shareId + ", " : "") + (assetId != null ? "assetId=" + assetId + ", " : "") + diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java index 141614d9..17b9efb9 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java @@ -24,14 +24,17 @@ public class MembershipDTO implements Serializable { @NotNull @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) - private LocalDate documentDate; + private LocalDate admissionDocumentDate; + + @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) + private LocalDate cancellationDocumentDate; @NotNull @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) - private LocalDate memberFrom; + private LocalDate memberFromDate; @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) - private LocalDate memberUntil; + private LocalDate memberUntilDate; @Size(max = 160) @AccessFor(init = Role.ADMIN, read = Role.SUPPORTER) @@ -58,28 +61,36 @@ public class MembershipDTO implements Serializable { this.id = id; } - public LocalDate getDocumentDate() { - return documentDate; + public LocalDate getAdmissionDocumentDate() { + return admissionDocumentDate; } - public void setDocumentDate(LocalDate documentDate) { - this.documentDate = documentDate; + public void setAdmissionDocumentDate(LocalDate admissionDocumentDate) { + this.admissionDocumentDate = admissionDocumentDate; } - public LocalDate getMemberFrom() { - return memberFrom; + public LocalDate getCancellationDocumentDate() { + return cancellationDocumentDate; } - public void setMemberFrom(LocalDate memberFrom) { - this.memberFrom = memberFrom; + public void setCancellationDocumentDate(LocalDate cancellationDocumentDate) { + this.cancellationDocumentDate = cancellationDocumentDate; } - public LocalDate getMemberUntil() { - return memberUntil; + public LocalDate getMemberFromDate() { + return memberFromDate; } - public void setMemberUntil(LocalDate memberUntil) { - this.memberUntil = memberUntil; + public void setMemberFromDate(LocalDate memberFromDate) { + this.memberFromDate = memberFromDate; + } + + public LocalDate getMemberUntilDate() { + return memberUntilDate; + } + + public void setMemberUntilDate(LocalDate memberUntilDate) { + this.memberUntilDate = memberUntilDate; } public String getRemark() { @@ -131,9 +142,10 @@ public class MembershipDTO implements Serializable { public String toString() { return "MembershipDTO{" + "id=" + getId() + - ", documentDate='" + getDocumentDate() + "'" + - ", memberFrom='" + getMemberFrom() + "'" + - ", memberUntil='" + getMemberUntil() + "'" + + ", admissionDocumentDate='" + getAdmissionDocumentDate() + "'" + + ", cancellationDocumentDate='" + getCancellationDocumentDate() + "'" + + ", memberFromDate='" + getMemberFromDate() + "'" + + ", memberUntilDate='" + getMemberUntilDate() + "'" + ", remark='" + getRemark() + "'" + ", customer=" + getCustomerId() + ", customer='" + getCustomerPrefix() + "'" + diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateCriteria.java index ce429df5..5196db49 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateCriteria.java @@ -1,15 +1,12 @@ package org.hostsharing.hsadminng.service.dto; +import io.github.jhipster.service.filter.Filter; +import io.github.jhipster.service.filter.LocalDateFilter; +import io.github.jhipster.service.filter.LongFilter; +import io.github.jhipster.service.filter.StringFilter; + import java.io.Serializable; import java.util.Objects; -import io.github.jhipster.service.filter.BooleanFilter; -import io.github.jhipster.service.filter.DoubleFilter; -import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.FloatFilter; -import io.github.jhipster.service.filter.IntegerFilter; -import io.github.jhipster.service.filter.LongFilter; -import io.github.jhipster.service.filter.StringFilter; -import io.github.jhipster.service.filter.LocalDateFilter; /** * Criteria class for the SepaMandate entity. This class is used in SepaMandateResource to @@ -31,15 +28,15 @@ public class SepaMandateCriteria implements Serializable { private StringFilter bic; - private LocalDateFilter documentDate; + private LocalDateFilter grantingDocumentDate; - private LocalDateFilter validFrom; + private LocalDateFilter revokationDocumentDate; - private LocalDateFilter validUntil; + private LocalDateFilter validFromDate; - private LocalDateFilter lastUsed; + private LocalDateFilter validUntilDate; - private LocalDateFilter cancellationDate; + private LocalDateFilter lastUsedDate; private StringFilter remark; @@ -77,44 +74,44 @@ public class SepaMandateCriteria implements Serializable { this.bic = bic; } - public LocalDateFilter getDocumentDate() { - return documentDate; + public LocalDateFilter getGrantingDocumentDate() { + return grantingDocumentDate; } - public void setDocumentDate(LocalDateFilter documentDate) { - this.documentDate = documentDate; + public void setGrantingDocumentDate(LocalDateFilter grantingDocumentDate) { + this.grantingDocumentDate = grantingDocumentDate; } - public LocalDateFilter getValidFrom() { - return validFrom; + public LocalDateFilter getRevokationDocumentDate() { + return revokationDocumentDate; } - public void setValidFrom(LocalDateFilter validFrom) { - this.validFrom = validFrom; + public void setRevokationDocumentDate(LocalDateFilter revokationDocumentDate) { + this.revokationDocumentDate = revokationDocumentDate; } - public LocalDateFilter getValidUntil() { - return validUntil; + public LocalDateFilter getValidFromDate() { + return validFromDate; } - public void setValidUntil(LocalDateFilter validUntil) { - this.validUntil = validUntil; + public void setValidFromDate(LocalDateFilter validFromDate) { + this.validFromDate = validFromDate; } - public LocalDateFilter getLastUsed() { - return lastUsed; + public LocalDateFilter getValidUntilDate() { + return validUntilDate; } - public void setLastUsed(LocalDateFilter lastUsed) { - this.lastUsed = lastUsed; + public void setValidUntilDate(LocalDateFilter validUntilDate) { + this.validUntilDate = validUntilDate; } - public LocalDateFilter getCancellationDate() { - return cancellationDate; + public LocalDateFilter getLastUsedDate() { + return lastUsedDate; } - public void setCancellationDate(LocalDateFilter cancellationDate) { - this.cancellationDate = cancellationDate; + public void setLastUsedDate(LocalDateFilter lastUsedDate) { + this.lastUsedDate = lastUsedDate; } public StringFilter getRemark() { @@ -148,11 +145,11 @@ public class SepaMandateCriteria implements Serializable { Objects.equals(reference, that.reference) && Objects.equals(iban, that.iban) && Objects.equals(bic, that.bic) && - Objects.equals(documentDate, that.documentDate) && - Objects.equals(validFrom, that.validFrom) && - Objects.equals(validUntil, that.validUntil) && - Objects.equals(lastUsed, that.lastUsed) && - Objects.equals(cancellationDate, that.cancellationDate) && + Objects.equals(grantingDocumentDate, that.grantingDocumentDate) && + Objects.equals(revokationDocumentDate, that.revokationDocumentDate) && + Objects.equals(validFromDate, that.validFromDate) && + Objects.equals(validUntilDate, that.validUntilDate) && + Objects.equals(lastUsedDate, that.lastUsedDate) && Objects.equals(remark, that.remark) && Objects.equals(customerId, that.customerId); } @@ -164,11 +161,11 @@ public class SepaMandateCriteria implements Serializable { reference, iban, bic, - documentDate, - validFrom, - validUntil, - lastUsed, - cancellationDate, + grantingDocumentDate, + revokationDocumentDate, + validFromDate, + validUntilDate, + lastUsedDate, remark, customerId ); @@ -181,11 +178,11 @@ public class SepaMandateCriteria implements Serializable { (reference != null ? "reference=" + reference + ", " : "") + (iban != null ? "iban=" + iban + ", " : "") + (bic != null ? "bic=" + bic + ", " : "") + - (documentDate != null ? "documentDate=" + documentDate + ", " : "") + - (validFrom != null ? "validFrom=" + validFrom + ", " : "") + - (validUntil != null ? "validUntil=" + validUntil + ", " : "") + - (lastUsed != null ? "lastUsed=" + lastUsed + ", " : "") + - (cancellationDate != null ? "cancellationDate=" + cancellationDate + ", " : "") + + (grantingDocumentDate != null ? "grantingDocumentDate=" + grantingDocumentDate + ", " : "") + + (revokationDocumentDate != null ? "revokationDocumentDate=" + revokationDocumentDate + ", " : "") + + (validFromDate != null ? "validFromDate=" + validFromDate + ", " : "") + + (validUntilDate != null ? "validUntilDate=" + validUntilDate + ", " : "") + + (lastUsedDate != null ? "lastUsedDate=" + lastUsedDate + ", " : "") + (remark != null ? "remark=" + remark + ", " : "") + (customerId != null ? "customerId=" + customerId + ", " : "") + "}"; diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java index c763f352..914b22b9 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java @@ -1,7 +1,9 @@ package org.hostsharing.hsadminng.service.dto; -import java.time.LocalDate; -import javax.validation.constraints.*; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.io.Serializable; +import java.time.LocalDate; import java.util.Objects; /** @@ -22,16 +24,16 @@ public class SepaMandateDTO implements Serializable { private String bic; @NotNull - private LocalDate documentDate; + private LocalDate grantingDocumentDate; + + private LocalDate revokationDocumentDate; @NotNull - private LocalDate validFrom; + private LocalDate validFromDate; - private LocalDate validUntil; + private LocalDate validUntilDate; - private LocalDate lastUsed; - - private LocalDate cancellationDate; + private LocalDate lastUsedDate; @Size(max = 160) private String remark; @@ -73,44 +75,44 @@ public class SepaMandateDTO implements Serializable { this.bic = bic; } - public LocalDate getDocumentDate() { - return documentDate; + public LocalDate getGrantingDocumentDate() { + return grantingDocumentDate; } - public void setDocumentDate(LocalDate documentDate) { - this.documentDate = documentDate; + public void setGrantingDocumentDate(LocalDate grantingDocumentDate) { + this.grantingDocumentDate = grantingDocumentDate; } - public LocalDate getValidFrom() { - return validFrom; + public LocalDate getRevokationDocumentDate() { + return revokationDocumentDate; } - public void setValidFrom(LocalDate validFrom) { - this.validFrom = validFrom; + public void setRevokationDocumentDate(LocalDate revokationDocumentDate) { + this.revokationDocumentDate = revokationDocumentDate; } - public LocalDate getValidUntil() { - return validUntil; + public LocalDate getValidFromDate() { + return validFromDate; } - public void setValidUntil(LocalDate validUntil) { - this.validUntil = validUntil; + public void setValidFromDate(LocalDate validFromDate) { + this.validFromDate = validFromDate; } - public LocalDate getLastUsed() { - return lastUsed; + public LocalDate getValidUntilDate() { + return validUntilDate; } - public void setLastUsed(LocalDate lastUsed) { - this.lastUsed = lastUsed; + public void setValidUntilDate(LocalDate validUntilDate) { + this.validUntilDate = validUntilDate; } - public LocalDate getCancellationDate() { - return cancellationDate; + public LocalDate getLastUsedDate() { + return lastUsedDate; } - public void setCancellationDate(LocalDate cancellationDate) { - this.cancellationDate = cancellationDate; + public void setLastUsedDate(LocalDate lastUsedDate) { + this.lastUsedDate = lastUsedDate; } public String getRemark() { @@ -165,11 +167,11 @@ public class SepaMandateDTO implements Serializable { ", reference='" + getReference() + "'" + ", iban='" + getIban() + "'" + ", bic='" + getBic() + "'" + - ", documentDate='" + getDocumentDate() + "'" + - ", validFrom='" + getValidFrom() + "'" + - ", validUntil='" + getValidUntil() + "'" + - ", lastUsed='" + getLastUsed() + "'" + - ", cancellationDate='" + getCancellationDate() + "'" + + ", grantingDocumentDate='" + getGrantingDocumentDate() + "'" + + ", revokationDocumentDate='" + getRevokationDocumentDate() + "'" + + ", validFromDate='" + getValidFromDate() + "'" + + ", validUntilDate='" + getValidUntilDate() + "'" + + ", lastUsedDate='" + getLastUsedDate() + "'" + ", remark='" + getRemark() + "'" + ", customer=" + getCustomerId() + ", customer='" + getCustomerPrefix() + "'" + diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java index b9e79209..b7d8f54f 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java @@ -1,12 +1,5 @@ package org.hostsharing.hsadminng.service.dto; -import org.hostsharing.hsadminng.domain.enumeration.ShareAction; -import org.hostsharing.hsadminng.service.MembershipService; -import org.hostsharing.hsadminng.service.accessfilter.AccessFor; -import org.hostsharing.hsadminng.service.accessfilter.ParentId; -import org.hostsharing.hsadminng.service.accessfilter.Role; -import org.hostsharing.hsadminng.service.accessfilter.SelfId; - import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.io.Serializable; @@ -24,10 +17,12 @@ public class ShareDTO implements Serializable { @NotNull @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) + @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) private LocalDate documentDate; @NotNull @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) + @AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}) private LocalDate valueDate; @NotNull @@ -47,7 +42,7 @@ public class ShareDTO implements Serializable { private Long membershipId; @AccessFor(init = Role.ADMIN, read = Role.SUPPORTER) - private String membershipDocumentDate; + private String membershipAdmissionDocumentDate; public Long getId() { return id; @@ -105,12 +100,12 @@ public class ShareDTO implements Serializable { this.membershipId = membershipId; } - public String getMembershipDocumentDate() { - return membershipDocumentDate; + public String getMembershipAdmissionDocumentDate() { + return membershipAdmissionDocumentDate; } - public void setMembershipDocumentDate(String membershipDocumentDate) { - this.membershipDocumentDate = membershipDocumentDate; + public void setMembershipAdmissionDocumentDate(String membershipAdmissionDocumentDate) { + this.membershipAdmissionDocumentDate = membershipAdmissionDocumentDate; } @Override @@ -144,7 +139,7 @@ public class ShareDTO implements Serializable { ", quantity=" + getQuantity() + ", remark='" + getRemark() + "'" + ", membership=" + getMembershipId() + - ", membership='" + getMembershipDocumentDate() + "'" + + ", membership='" + getMembershipAdmissionDocumentDate() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java index d43fc5c0..1d686822 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java @@ -1,9 +1,9 @@ package org.hostsharing.hsadminng.service.mapper; -import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.domain.Asset; import org.hostsharing.hsadminng.service.dto.AssetDTO; - -import org.mapstruct.*; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; /** * Mapper for the entity Asset and its DTO AssetDTO. @@ -12,7 +12,7 @@ import org.mapstruct.*; public interface AssetMapper extends EntityMapper { @Mapping(source = "membership.id", target = "membershipId") - @Mapping(source = "membership.documentDate", target = "membershipDocumentDate") + @Mapping(source = "membership.admissionDocumentDate", target = "membershipAdmissionDocumentDate") AssetDTO toDto(Asset asset); @Mapping(source = "membershipId", target = "membership") diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java index 6867130d..3f367ce6 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java @@ -1,9 +1,9 @@ package org.hostsharing.hsadminng.service.mapper; -import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.domain.Share; import org.hostsharing.hsadminng.service.dto.ShareDTO; - -import org.mapstruct.*; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; /** * Mapper for the entity Share and its DTO ShareDTO. @@ -12,7 +12,7 @@ import org.mapstruct.*; public interface ShareMapper extends EntityMapper { @Mapping(source = "membership.id", target = "membershipId") - @Mapping(source = "membership.documentDate", target = "membershipDocumentDate") + @Mapping(source = "membership.admissionDocumentDate", target = "membershipAdmissionDocumentDate") ShareDTO toDto(Share share); @Mapping(source = "membershipId", target = "membership") diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java index 3e142f28..c82ad9a1 100644 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java +++ b/src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java @@ -1,25 +1,24 @@ package org.hostsharing.hsadminng.web.rest; + +import io.github.jhipster.web.util.ResponseUtil; +import org.hostsharing.hsadminng.service.AssetQueryService; import org.hostsharing.hsadminng.service.AssetService; +import org.hostsharing.hsadminng.service.dto.AssetCriteria; +import org.hostsharing.hsadminng.service.dto.AssetDTO; import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; import org.hostsharing.hsadminng.web.rest.util.HeaderUtil; import org.hostsharing.hsadminng.web.rest.util.PaginationUtil; -import org.hostsharing.hsadminng.service.dto.AssetDTO; -import org.hostsharing.hsadminng.service.dto.AssetCriteria; -import org.hostsharing.hsadminng.service.AssetQueryService; -import io.github.jhipster.web.util.ResponseUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.net.URI; import java.net.URISyntaxException; - import java.util.List; import java.util.Optional; @@ -74,13 +73,8 @@ public class AssetResource { @PutMapping("/assets") public ResponseEntity updateAsset(@Valid @RequestBody AssetDTO assetDTO) throws URISyntaxException { log.debug("REST request to update Asset : {}", assetDTO); - if (assetDTO.getId() == null) { - throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); - } - AssetDTO result = assetService.save(assetDTO); - return ResponseEntity.ok() - .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, assetDTO.getId().toString())) - .body(result); + // TODO mhoennig: Rather completely remove the endpoint? + throw new BadRequestAlertException("Assets are immutable", ENTITY_NAME, "assetTransactionImmutable"); } /** @@ -132,7 +126,7 @@ public class AssetResource { @DeleteMapping("/assets/{id}") public ResponseEntity deleteAsset(@PathVariable Long id) { log.debug("REST request to delete Asset : {}", id); - assetService.delete(id); - return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + // TODO mhoennig: Rather completely remove the endpoint? + throw new BadRequestAlertException("Asset are immutable", ENTITY_NAME, "assetTransactionImmutable"); } } diff --git a/src/main/jdl/customer.jdl b/src/main/jdl/customer.jdl index 9af8c485..3cb5a6ba 100644 --- a/src/main/jdl/customer.jdl +++ b/src/main/jdl/customer.jdl @@ -3,10 +3,28 @@ dto all with mapstruct service all with serviceClass paginate all with infinite-scroll +enum CustomerKind { + NATURAL, + LEGAL +} + +enum VatRegion { + DOMESTIC, + EU, + OTHER +} + entity Customer { reference Integer required unique min(10000) max(99999), prefix String required maxlength(3) unique pattern(/[a-z][a-z0-9]+/), name String required maxlength(80), + kind CustomerKind required, + birthDate LocalDate, + birthPlace String maxlength(80), + registrationCourt String maxlength(80), + registrationNumber String maxlength(80), + vatRegion VatRegion required, + vatNumber String maxlength(40), contractualSalutation String maxlength(80), contractualAddress String required maxlength(400), billingSalutation String maxlength(80), @@ -15,9 +33,10 @@ entity Customer { } entity Membership { - documentDate LocalDate required, - memberFrom LocalDate required, - memberUntil LocalDate, + admissionDocumentDate LocalDate required, + cancellationDocumentDate LocalDate, + memberFromDate LocalDate required, + memberUntilDate LocalDate, remark String maxlength(160) } @@ -55,17 +74,17 @@ entity SepaMandate { reference String maxlength(40) unique required, iban String maxlength(34), bic String maxlength(11), - documentDate LocalDate required, - validFrom LocalDate required, - validUntil LocalDate, - lastUsed LocalDate, - cancellationDate LocalDate, + grantingDocumentDate LocalDate required, + revokationDocumentDate LocalDate, + validFromDate LocalDate required, + validUntilDate LocalDate, + lastUsedDate LocalDate, remark String maxlength(160) } relationship OneToMany { Customer{membership} to Membership{customer(prefix) required}, Customer{sepamandate} to SepaMandate{customer(prefix) required}, - Membership{share} to Share{membership(documentDate) required}, - Membership{asset} to Asset{membership(documentDate) required} + Membership{share} to Share{membership(admissionDocumentDate) required}, + Membership{asset} to Asset{membership(admissionDocumentDate) required} } diff --git a/src/main/resources/config/liquibase/changelog/20190424123255_added_entity_Customer.xml b/src/main/resources/config/liquibase/changelog/20190424123255_added_entity_Customer.xml new file mode 100644 index 00000000..e98a308e --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123255_added_entity_Customer.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424123256_added_entity_Membership.xml b/src/main/resources/config/liquibase/changelog/20190424123256_added_entity_Membership.xml new file mode 100644 index 00000000..9a001791 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123256_added_entity_Membership.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424123256_added_entity_constraints_Membership.xml b/src/main/resources/config/liquibase/changelog/20190424123256_added_entity_constraints_Membership.xml new file mode 100644 index 00000000..55aca3e8 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123256_added_entity_constraints_Membership.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424123257_added_entity_Share.xml b/src/main/resources/config/liquibase/changelog/20190424123257_added_entity_Share.xml new file mode 100644 index 00000000..122ac4eb --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123257_added_entity_Share.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424123257_added_entity_constraints_Share.xml b/src/main/resources/config/liquibase/changelog/20190424123257_added_entity_constraints_Share.xml new file mode 100644 index 00000000..615a4136 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123257_added_entity_constraints_Share.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424123258_added_entity_Asset.xml b/src/main/resources/config/liquibase/changelog/20190424123258_added_entity_Asset.xml new file mode 100644 index 00000000..5a39564a --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123258_added_entity_Asset.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424123258_added_entity_constraints_Asset.xml b/src/main/resources/config/liquibase/changelog/20190424123258_added_entity_constraints_Asset.xml new file mode 100644 index 00000000..7b986be0 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123258_added_entity_constraints_Asset.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424123259_added_entity_SepaMandate.xml b/src/main/resources/config/liquibase/changelog/20190424123259_added_entity_SepaMandate.xml new file mode 100644 index 00000000..e3cf003e --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123259_added_entity_SepaMandate.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190424123259_added_entity_constraints_SepaMandate.xml b/src/main/resources/config/liquibase/changelog/20190424123259_added_entity_constraints_SepaMandate.xml new file mode 100644 index 00000000..1a84bc33 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123259_added_entity_constraints_SepaMandate.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index 201616d6..f191c087 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -5,15 +5,15 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> - - - - - + + + + + - - - - + + + + diff --git a/src/main/webapp/app/entities/asset/asset-detail.component.html b/src/main/webapp/app/entities/asset/asset-detail.component.html index c259a165..93f2e7f5 100644 --- a/src/main/webapp/app/entities/asset/asset-detail.component.html +++ b/src/main/webapp/app/entities/asset/asset-detail.component.html @@ -28,7 +28,7 @@
Membership
diff --git a/src/main/webapp/app/entities/asset/asset-update.component.html b/src/main/webapp/app/entities/asset/asset-update.component.html index cc48af42..3b3a5c43 100644 --- a/src/main/webapp/app/entities/asset/asset-update.component.html +++ b/src/main/webapp/app/entities/asset/asset-update.component.html @@ -89,7 +89,7 @@
diff --git a/src/main/webapp/app/entities/asset/asset.component.html b/src/main/webapp/app/entities/asset/asset.component.html index 8fac5e46..2b918714 100644 --- a/src/main/webapp/app/entities/asset/asset.component.html +++ b/src/main/webapp/app/entities/asset/asset.component.html @@ -20,7 +20,7 @@ Action Amount Remark - Membership + Membership @@ -34,7 +34,7 @@ {{asset.remark}} diff --git a/src/main/webapp/app/entities/customer/customer-detail.component.html b/src/main/webapp/app/entities/customer/customer-detail.component.html index a3d1343c..93c22ade 100644 --- a/src/main/webapp/app/entities/customer/customer-detail.component.html +++ b/src/main/webapp/app/entities/customer/customer-detail.component.html @@ -17,6 +17,34 @@
{{customer.name}}
+
Kind
+
+ {{customer.kind}} +
+
Birth Date
+
+ {{customer.birthDate}} +
+
Birth Place
+
+ {{customer.birthPlace}} +
+
Registration Court
+
+ {{customer.registrationCourt}} +
+
Registration Number
+
+ {{customer.registrationNumber}} +
+
Vat Region
+
+ {{customer.vatRegion}} +
+
Vat Number
+
+ {{customer.vatNumber}} +
Contractual Salutation
{{customer.contractualSalutation}} diff --git a/src/main/webapp/app/entities/customer/customer-update.component.html b/src/main/webapp/app/entities/customer/customer-update.component.html index de0d7818..0a498111 100644 --- a/src/main/webapp/app/entities/customer/customer-update.component.html +++ b/src/main/webapp/app/entities/customer/customer-update.component.html @@ -66,6 +66,87 @@
+
+ + +
+ + This field is required. + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + This field cannot be longer than 80 characters. + +
+
+
+ + +
+ + This field cannot be longer than 80 characters. + +
+
+
+ + +
+ + This field cannot be longer than 80 characters. + +
+
+
+ + +
+ + This field is required. + +
+
+
+ + +
+ + This field cannot be longer than 40 characters. + +
+
Reference Prefix Name + Kind + Birth Date + Birth Place + Registration Court + Registration Number + Vat Region + Vat Number Contractual Salutation Contractual Address Billing Salutation @@ -32,6 +39,13 @@ {{customer.reference}} {{customer.prefix}} {{customer.name}} + {{customer.kind}} + {{customer.birthDate | date:'mediumDate'}} + {{customer.birthPlace}} + {{customer.registrationCourt}} + {{customer.registrationNumber}} + {{customer.vatRegion}} + {{customer.vatNumber}} {{customer.contractualSalutation}} {{customer.contractualAddress}} {{customer.billingSalutation}} diff --git a/src/main/webapp/app/entities/customer/customer.component.ts b/src/main/webapp/app/entities/customer/customer.component.ts index bd1f3e49..3f95501d 100644 --- a/src/main/webapp/app/entities/customer/customer.component.ts +++ b/src/main/webapp/app/entities/customer/customer.component.ts @@ -1,8 +1,7 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; -import { Subscription, Subject } from 'rxjs'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; -import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; +import { Subscription } from 'rxjs'; +import { JhiAlertService, JhiEventManager, JhiParseLinks } from 'ng-jhipster'; import { ICustomer } from 'app/shared/model/customer.model'; import { AccountService } from 'app/core'; @@ -24,9 +23,6 @@ export class CustomerComponent implements OnInit, OnDestroy { predicate: any; reverse: any; totalItems: number; - filterValue: any; - filterValueChanged = new Subject(); - subscription: Subscription; constructor( protected customerService: CustomerService, @@ -43,25 +39,11 @@ export class CustomerComponent implements OnInit, OnDestroy { }; this.predicate = 'id'; this.reverse = true; - this.resetFilter(); - } - - resetFilter() { - this.filterValue = { - number: null, - prefix: null - }; - this.loadAll(); } loadAll() { - const criteria = { - ...(this.filterValue.number && { 'number.equals': this.filterValue.number }), - ...(this.filterValue.prefix && { 'prefix.contains': this.filterValue.prefix }) - }; this.customerService .query({ - ...criteria, page: this.page, size: this.itemsPerPage, sort: this.sort() @@ -72,10 +54,6 @@ export class CustomerComponent implements OnInit, OnDestroy { ); } - filter($event) { - this.filterValueChanged.next($event.target.value); - } - reset() { this.page = 0; this.customers = []; @@ -93,15 +71,6 @@ export class CustomerComponent implements OnInit, OnDestroy { this.currentAccount = account; }); this.registerChangeInCustomers(); - - this.subscription = this.filterValueChanged - .pipe( - debounceTime(500), - distinctUntilChanged((previous: any, current: any) => previous === current) - ) - .subscribe(() => { - this.loadAll(); - }); } ngOnDestroy() { @@ -127,8 +96,6 @@ export class CustomerComponent implements OnInit, OnDestroy { protected paginateCustomers(data: ICustomer[], headers: HttpHeaders) { this.links = this.parseLinks.parse(headers.get('link')); this.totalItems = parseInt(headers.get('X-Total-Count'), 10); - this.page = 0; - this.customers = []; for (let i = 0; i < data.length; i++) { this.customers.push(data[i]); } diff --git a/src/main/webapp/app/entities/customer/customer.service.ts b/src/main/webapp/app/entities/customer/customer.service.ts index 20710286..7b6951ce 100644 --- a/src/main/webapp/app/entities/customer/customer.service.ts +++ b/src/main/webapp/app/entities/customer/customer.service.ts @@ -1,6 +1,9 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; +import * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { map } from 'rxjs/operators'; import { SERVER_API_URL } from 'app/app.constants'; import { createRequestOption } from 'app/shared'; @@ -16,23 +19,56 @@ export class CustomerService { constructor(protected http: HttpClient) {} create(customer: ICustomer): Observable { - return this.http.post(this.resourceUrl, customer, { observe: 'response' }); + const copy = this.convertDateFromClient(customer); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } update(customer: ICustomer): Observable { - return this.http.put(this.resourceUrl, customer, { observe: 'response' }); + const copy = this.convertDateFromClient(customer); + return this.http + .put(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } find(id: number): Observable { - return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + return this.http + .get(`${this.resourceUrl}/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } query(req?: any): Observable { const options = createRequestOption(req); - return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + return this.http + .get(this.resourceUrl, { params: options, observe: 'response' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); } delete(id: number): Observable> { return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); } + + protected convertDateFromClient(customer: ICustomer): ICustomer { + const copy: ICustomer = Object.assign({}, customer, { + birthDate: customer.birthDate != null && customer.birthDate.isValid() ? customer.birthDate.format(DATE_FORMAT) : null + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.birthDate = res.body.birthDate != null ? moment(res.body.birthDate) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((customer: ICustomer) => { + customer.birthDate = customer.birthDate != null ? moment(customer.birthDate) : null; + }); + } + return res; + } } diff --git a/src/main/webapp/app/entities/membership/membership-detail.component.html b/src/main/webapp/app/entities/membership/membership-detail.component.html index 8a0ce659..3115c10a 100644 --- a/src/main/webapp/app/entities/membership/membership-detail.component.html +++ b/src/main/webapp/app/entities/membership/membership-detail.component.html @@ -5,17 +5,21 @@
-
Document Date
+
Admission Document Date
- {{membership.documentDate}} + {{membership.admissionDocumentDate}}
-
Member From
+
Cancellation Document Date
- {{membership.memberFrom}} + {{membership.cancellationDocumentDate}}
-
Member Until
+
Member From Date
- {{membership.memberUntil}} + {{membership.memberFromDate}} +
+
Member Until Date
+
+ {{membership.memberUntilDate}}
Remark
diff --git a/src/main/webapp/app/entities/membership/membership-update.component.html b/src/main/webapp/app/entities/membership/membership-update.component.html index 37274e9c..118a6127 100644 --- a/src/main/webapp/app/entities/membership/membership-update.component.html +++ b/src/main/webapp/app/entities/membership/membership-update.component.html @@ -10,44 +10,54 @@ [(ngModel)]="membership.id" readonly />
- +
- - +
-
+
+ [hidden]="!editForm.controls.admissionDocumentDate?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
- +
- - - - -
-
- - This field is required. - -
-
-
- -
- - + + +
+
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ +
+ + +
diff --git a/src/main/webapp/app/entities/membership/membership-update.component.ts b/src/main/webapp/app/entities/membership/membership-update.component.ts index 1f68bfc2..74140751 100644 --- a/src/main/webapp/app/entities/membership/membership-update.component.ts +++ b/src/main/webapp/app/entities/membership/membership-update.component.ts @@ -1,9 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { filter, map } from 'rxjs/operators'; -import * as moment from 'moment'; import { JhiAlertService } from 'ng-jhipster'; import { IMembership } from 'app/shared/model/membership.model'; import { MembershipService } from './membership.service'; @@ -19,9 +18,10 @@ export class MembershipUpdateComponent implements OnInit { isSaving: boolean; customers: ICustomer[]; - documentDateDp: any; - memberFromDp: any; - memberUntilDp: any; + admissionDocumentDateDp: any; + cancellationDocumentDateDp: any; + memberFromDateDp: any; + memberUntilDateDp: any; constructor( protected jhiAlertService: JhiAlertService, diff --git a/src/main/webapp/app/entities/membership/membership.component.html b/src/main/webapp/app/entities/membership/membership.component.html index 6852205f..82375faf 100644 --- a/src/main/webapp/app/entities/membership/membership.component.html +++ b/src/main/webapp/app/entities/membership/membership.component.html @@ -15,9 +15,10 @@ ID - Document Date - Member From - Member Until + Admission Document Date + Cancellation Document Date + Member From Date + Member Until Date Remark Customer @@ -26,9 +27,10 @@ {{membership.id}} - {{membership.documentDate | date:'mediumDate'}} - {{membership.memberFrom | date:'mediumDate'}} - {{membership.memberUntil | date:'mediumDate'}} + {{membership.admissionDocumentDate | date:'mediumDate'}} + {{membership.cancellationDocumentDate | date:'mediumDate'}} + {{membership.memberFromDate | date:'mediumDate'}} + {{membership.memberUntilDate | date:'mediumDate'}} {{membership.remark}}
diff --git a/src/main/webapp/app/entities/membership/membership.service.ts b/src/main/webapp/app/entities/membership/membership.service.ts index c0fb3e77..586846eb 100644 --- a/src/main/webapp/app/entities/membership/membership.service.ts +++ b/src/main/webapp/app/entities/membership/membership.service.ts @@ -51,20 +51,33 @@ export class MembershipService { protected convertDateFromClient(membership: IMembership): IMembership { const copy: IMembership = Object.assign({}, membership, { - documentDate: - membership.documentDate != null && membership.documentDate.isValid() ? membership.documentDate.format(DATE_FORMAT) : null, - memberFrom: membership.memberFrom != null && membership.memberFrom.isValid() ? membership.memberFrom.format(DATE_FORMAT) : null, - memberUntil: - membership.memberUntil != null && membership.memberUntil.isValid() ? membership.memberUntil.format(DATE_FORMAT) : null + admissionDocumentDate: + membership.admissionDocumentDate != null && membership.admissionDocumentDate.isValid() + ? membership.admissionDocumentDate.format(DATE_FORMAT) + : null, + cancellationDocumentDate: + membership.cancellationDocumentDate != null && membership.cancellationDocumentDate.isValid() + ? membership.cancellationDocumentDate.format(DATE_FORMAT) + : null, + memberFromDate: + membership.memberFromDate != null && membership.memberFromDate.isValid() + ? membership.memberFromDate.format(DATE_FORMAT) + : null, + memberUntilDate: + membership.memberUntilDate != null && membership.memberUntilDate.isValid() + ? membership.memberUntilDate.format(DATE_FORMAT) + : null }); return copy; } protected convertDateFromServer(res: EntityResponseType): EntityResponseType { if (res.body) { - res.body.documentDate = res.body.documentDate != null ? moment(res.body.documentDate) : null; - res.body.memberFrom = res.body.memberFrom != null ? moment(res.body.memberFrom) : null; - res.body.memberUntil = res.body.memberUntil != null ? moment(res.body.memberUntil) : null; + res.body.admissionDocumentDate = res.body.admissionDocumentDate != null ? moment(res.body.admissionDocumentDate) : null; + res.body.cancellationDocumentDate = + res.body.cancellationDocumentDate != null ? moment(res.body.cancellationDocumentDate) : null; + res.body.memberFromDate = res.body.memberFromDate != null ? moment(res.body.memberFromDate) : null; + res.body.memberUntilDate = res.body.memberUntilDate != null ? moment(res.body.memberUntilDate) : null; } return res; } @@ -72,9 +85,12 @@ export class MembershipService { protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { if (res.body) { res.body.forEach((membership: IMembership) => { - membership.documentDate = membership.documentDate != null ? moment(membership.documentDate) : null; - membership.memberFrom = membership.memberFrom != null ? moment(membership.memberFrom) : null; - membership.memberUntil = membership.memberUntil != null ? moment(membership.memberUntil) : null; + membership.admissionDocumentDate = + membership.admissionDocumentDate != null ? moment(membership.admissionDocumentDate) : null; + membership.cancellationDocumentDate = + membership.cancellationDocumentDate != null ? moment(membership.cancellationDocumentDate) : null; + membership.memberFromDate = membership.memberFromDate != null ? moment(membership.memberFromDate) : null; + membership.memberUntilDate = membership.memberUntilDate != null ? moment(membership.memberUntilDate) : null; }); } return res; diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.html b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.html index 5b87977f..af5b3bf5 100644 --- a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.html +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.html @@ -17,25 +17,25 @@
{{sepaMandate.bic}}
-
Document Date
+
Granting Document Date
- {{sepaMandate.documentDate}} + {{sepaMandate.grantingDocumentDate}}
-
Valid From
+
Revokation Document Date
- {{sepaMandate.validFrom}} + {{sepaMandate.revokationDocumentDate}}
-
Valid Until
+
Valid From Date
- {{sepaMandate.validUntil}} + {{sepaMandate.validFromDate}}
-
Last Used
+
Valid Until Date
- {{sepaMandate.lastUsed}} + {{sepaMandate.validUntilDate}}
-
Cancellation Date
+
Last Used Date
- {{sepaMandate.cancellationDate}} + {{sepaMandate.lastUsedDate}}
Remark
diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.html b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.html index c4803427..507750c8 100644 --- a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.html +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.html @@ -47,64 +47,64 @@
- +
- - +
-
+
+ [hidden]="!editForm.controls.grantingDocumentDate?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
- +
- + - +
-
+
+
+ +
+ + + + +
+
+ [hidden]="!editForm.controls.validFromDate?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
- +
- - +
- +
- - - -
-
-
- -
- - - +
diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts index ba809340..8efa2127 100644 --- a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts @@ -1,9 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { filter, map } from 'rxjs/operators'; -import * as moment from 'moment'; import { JhiAlertService } from 'ng-jhipster'; import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; import { SepaMandateService } from './sepa-mandate.service'; @@ -19,11 +18,11 @@ export class SepaMandateUpdateComponent implements OnInit { isSaving: boolean; customers: ICustomer[]; - documentDateDp: any; - validFromDp: any; - validUntilDp: any; - lastUsedDp: any; - cancellationDateDp: any; + grantingDocumentDateDp: any; + revokationDocumentDateDp: any; + validFromDateDp: any; + validUntilDateDp: any; + lastUsedDateDp: any; constructor( protected jhiAlertService: JhiAlertService, diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html index 21976ea7..2fca9893 100644 --- a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html @@ -18,11 +18,11 @@ Reference Iban Bic - Document Date - Valid From - Valid Until - Last Used - Cancellation Date + Granting Document Date + Revokation Document Date + Valid From Date + Valid Until Date + Last Used Date Remark Customer @@ -34,11 +34,11 @@ {{sepaMandate.reference}} {{sepaMandate.iban}} {{sepaMandate.bic}} - {{sepaMandate.documentDate | date:'mediumDate'}} - {{sepaMandate.validFrom | date:'mediumDate'}} - {{sepaMandate.validUntil | date:'mediumDate'}} - {{sepaMandate.lastUsed | date:'mediumDate'}} - {{sepaMandate.cancellationDate | date:'mediumDate'}} + {{sepaMandate.grantingDocumentDate | date:'mediumDate'}} + {{sepaMandate.revokationDocumentDate | date:'mediumDate'}} + {{sepaMandate.validFromDate | date:'mediumDate'}} + {{sepaMandate.validUntilDate | date:'mediumDate'}} + {{sepaMandate.lastUsedDate | date:'mediumDate'}} {{sepaMandate.remark}}
diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts index 17a9584a..0cf01c0a 100644 --- a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts @@ -51,29 +51,35 @@ export class SepaMandateService { protected convertDateFromClient(sepaMandate: ISepaMandate): ISepaMandate { const copy: ISepaMandate = Object.assign({}, sepaMandate, { - documentDate: - sepaMandate.documentDate != null && sepaMandate.documentDate.isValid() - ? sepaMandate.documentDate.format(DATE_FORMAT) + grantingDocumentDate: + sepaMandate.grantingDocumentDate != null && sepaMandate.grantingDocumentDate.isValid() + ? sepaMandate.grantingDocumentDate.format(DATE_FORMAT) : null, - validFrom: sepaMandate.validFrom != null && sepaMandate.validFrom.isValid() ? sepaMandate.validFrom.format(DATE_FORMAT) : null, - validUntil: - sepaMandate.validUntil != null && sepaMandate.validUntil.isValid() ? sepaMandate.validUntil.format(DATE_FORMAT) : null, - lastUsed: sepaMandate.lastUsed != null && sepaMandate.lastUsed.isValid() ? sepaMandate.lastUsed.format(DATE_FORMAT) : null, - cancellationDate: - sepaMandate.cancellationDate != null && sepaMandate.cancellationDate.isValid() - ? sepaMandate.cancellationDate.format(DATE_FORMAT) - : null + revokationDocumentDate: + sepaMandate.revokationDocumentDate != null && sepaMandate.revokationDocumentDate.isValid() + ? sepaMandate.revokationDocumentDate.format(DATE_FORMAT) + : null, + validFromDate: + sepaMandate.validFromDate != null && sepaMandate.validFromDate.isValid() + ? sepaMandate.validFromDate.format(DATE_FORMAT) + : null, + validUntilDate: + sepaMandate.validUntilDate != null && sepaMandate.validUntilDate.isValid() + ? sepaMandate.validUntilDate.format(DATE_FORMAT) + : null, + lastUsedDate: + sepaMandate.lastUsedDate != null && sepaMandate.lastUsedDate.isValid() ? sepaMandate.lastUsedDate.format(DATE_FORMAT) : null }); return copy; } protected convertDateFromServer(res: EntityResponseType): EntityResponseType { if (res.body) { - res.body.documentDate = res.body.documentDate != null ? moment(res.body.documentDate) : null; - res.body.validFrom = res.body.validFrom != null ? moment(res.body.validFrom) : null; - res.body.validUntil = res.body.validUntil != null ? moment(res.body.validUntil) : null; - res.body.lastUsed = res.body.lastUsed != null ? moment(res.body.lastUsed) : null; - res.body.cancellationDate = res.body.cancellationDate != null ? moment(res.body.cancellationDate) : null; + res.body.grantingDocumentDate = res.body.grantingDocumentDate != null ? moment(res.body.grantingDocumentDate) : null; + res.body.revokationDocumentDate = res.body.revokationDocumentDate != null ? moment(res.body.revokationDocumentDate) : null; + res.body.validFromDate = res.body.validFromDate != null ? moment(res.body.validFromDate) : null; + res.body.validUntilDate = res.body.validUntilDate != null ? moment(res.body.validUntilDate) : null; + res.body.lastUsedDate = res.body.lastUsedDate != null ? moment(res.body.lastUsedDate) : null; } return res; } @@ -81,11 +87,13 @@ export class SepaMandateService { protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { if (res.body) { res.body.forEach((sepaMandate: ISepaMandate) => { - sepaMandate.documentDate = sepaMandate.documentDate != null ? moment(sepaMandate.documentDate) : null; - sepaMandate.validFrom = sepaMandate.validFrom != null ? moment(sepaMandate.validFrom) : null; - sepaMandate.validUntil = sepaMandate.validUntil != null ? moment(sepaMandate.validUntil) : null; - sepaMandate.lastUsed = sepaMandate.lastUsed != null ? moment(sepaMandate.lastUsed) : null; - sepaMandate.cancellationDate = sepaMandate.cancellationDate != null ? moment(sepaMandate.cancellationDate) : null; + sepaMandate.grantingDocumentDate = + sepaMandate.grantingDocumentDate != null ? moment(sepaMandate.grantingDocumentDate) : null; + sepaMandate.revokationDocumentDate = + sepaMandate.revokationDocumentDate != null ? moment(sepaMandate.revokationDocumentDate) : null; + sepaMandate.validFromDate = sepaMandate.validFromDate != null ? moment(sepaMandate.validFromDate) : null; + sepaMandate.validUntilDate = sepaMandate.validUntilDate != null ? moment(sepaMandate.validUntilDate) : null; + sepaMandate.lastUsedDate = sepaMandate.lastUsedDate != null ? moment(sepaMandate.lastUsedDate) : null; }); } return res; diff --git a/src/main/webapp/app/entities/share/share-detail.component.html b/src/main/webapp/app/entities/share/share-detail.component.html index 505a8591..bd3df716 100644 --- a/src/main/webapp/app/entities/share/share-detail.component.html +++ b/src/main/webapp/app/entities/share/share-detail.component.html @@ -28,7 +28,7 @@
Membership
diff --git a/src/main/webapp/app/entities/share/share-update.component.html b/src/main/webapp/app/entities/share/share-update.component.html index 34d6853c..4f077e99 100644 --- a/src/main/webapp/app/entities/share/share-update.component.html +++ b/src/main/webapp/app/entities/share/share-update.component.html @@ -85,7 +85,7 @@
diff --git a/src/main/webapp/app/entities/share/share.component.html b/src/main/webapp/app/entities/share/share.component.html index 81c23e25..d42d00e1 100644 --- a/src/main/webapp/app/entities/share/share.component.html +++ b/src/main/webapp/app/entities/share/share.component.html @@ -20,7 +20,7 @@ Action Quantity Remark - Membership + Membership @@ -34,7 +34,7 @@ {{share.remark}} diff --git a/src/main/webapp/app/shared/model/asset.model.ts b/src/main/webapp/app/shared/model/asset.model.ts index 7964c1f7..f5b8f1d1 100644 --- a/src/main/webapp/app/shared/model/asset.model.ts +++ b/src/main/webapp/app/shared/model/asset.model.ts @@ -16,7 +16,7 @@ export interface IAsset { action?: AssetAction; amount?: number; remark?: string; - membershipDocumentDate?: string; + membershipAdmissionDocumentDate?: string; membershipId?: number; } @@ -28,7 +28,7 @@ export class Asset implements IAsset { public action?: AssetAction, public amount?: number, public remark?: string, - public membershipDocumentDate?: string, + public membershipAdmissionDocumentDate?: string, public membershipId?: number ) {} } diff --git a/src/main/webapp/app/shared/model/customer.model.ts b/src/main/webapp/app/shared/model/customer.model.ts index 1970b289..884bbce9 100644 --- a/src/main/webapp/app/shared/model/customer.model.ts +++ b/src/main/webapp/app/shared/model/customer.model.ts @@ -1,11 +1,30 @@ +import { Moment } from 'moment'; import { IMembership } from 'app/shared/model/membership.model'; import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; +export const enum CustomerKind { + NATURAL = 'NATURAL', + LEGAL = 'LEGAL' +} + +export const enum VatRegion { + DOMESTIC = 'DOMESTIC', + EU = 'EU', + OTHER = 'OTHER' +} + export interface ICustomer { id?: number; reference?: number; prefix?: string; name?: string; + kind?: CustomerKind; + birthDate?: Moment; + birthPlace?: string; + registrationCourt?: string; + registrationNumber?: string; + vatRegion?: VatRegion; + vatNumber?: string; contractualSalutation?: string; contractualAddress?: string; billingSalutation?: string; @@ -21,6 +40,13 @@ export class Customer implements ICustomer { public reference?: number, public prefix?: string, public name?: string, + public kind?: CustomerKind, + public birthDate?: Moment, + public birthPlace?: string, + public registrationCourt?: string, + public registrationNumber?: string, + public vatRegion?: VatRegion, + public vatNumber?: string, public contractualSalutation?: string, public contractualAddress?: string, public billingSalutation?: string, diff --git a/src/main/webapp/app/shared/model/membership.model.ts b/src/main/webapp/app/shared/model/membership.model.ts index 57418782..27bc7e7a 100644 --- a/src/main/webapp/app/shared/model/membership.model.ts +++ b/src/main/webapp/app/shared/model/membership.model.ts @@ -4,9 +4,10 @@ import { IAsset } from 'app/shared/model/asset.model'; export interface IMembership { id?: number; - documentDate?: Moment; - memberFrom?: Moment; - memberUntil?: Moment; + admissionDocumentDate?: Moment; + cancellationDocumentDate?: Moment; + memberFromDate?: Moment; + memberUntilDate?: Moment; remark?: string; shares?: IShare[]; assets?: IAsset[]; @@ -17,9 +18,10 @@ export interface IMembership { export class Membership implements IMembership { constructor( public id?: number, - public documentDate?: Moment, - public memberFrom?: Moment, - public memberUntil?: Moment, + public admissionDocumentDate?: Moment, + public cancellationDocumentDate?: Moment, + public memberFromDate?: Moment, + public memberUntilDate?: Moment, public remark?: string, public shares?: IShare[], public assets?: IAsset[], diff --git a/src/main/webapp/app/shared/model/sepa-mandate.model.ts b/src/main/webapp/app/shared/model/sepa-mandate.model.ts index feccc941..5edb606f 100644 --- a/src/main/webapp/app/shared/model/sepa-mandate.model.ts +++ b/src/main/webapp/app/shared/model/sepa-mandate.model.ts @@ -5,11 +5,11 @@ export interface ISepaMandate { reference?: string; iban?: string; bic?: string; - documentDate?: Moment; - validFrom?: Moment; - validUntil?: Moment; - lastUsed?: Moment; - cancellationDate?: Moment; + grantingDocumentDate?: Moment; + revokationDocumentDate?: Moment; + validFromDate?: Moment; + validUntilDate?: Moment; + lastUsedDate?: Moment; remark?: string; customerPrefix?: string; customerId?: number; @@ -21,11 +21,11 @@ export class SepaMandate implements ISepaMandate { public reference?: string, public iban?: string, public bic?: string, - public documentDate?: Moment, - public validFrom?: Moment, - public validUntil?: Moment, - public lastUsed?: Moment, - public cancellationDate?: Moment, + public grantingDocumentDate?: Moment, + public revokationDocumentDate?: Moment, + public validFromDate?: Moment, + public validUntilDate?: Moment, + public lastUsedDate?: Moment, public remark?: string, public customerPrefix?: string, public customerId?: number diff --git a/src/main/webapp/app/shared/model/share.model.ts b/src/main/webapp/app/shared/model/share.model.ts index 5338867a..215243a7 100644 --- a/src/main/webapp/app/shared/model/share.model.ts +++ b/src/main/webapp/app/shared/model/share.model.ts @@ -12,7 +12,7 @@ export interface IShare { action?: ShareAction; quantity?: number; remark?: string; - membershipDocumentDate?: string; + membershipAdmissionDocumentDate?: string; membershipId?: number; } @@ -24,7 +24,7 @@ export class Share implements IShare { public action?: ShareAction, public quantity?: number, public remark?: string, - public membershipDocumentDate?: string, + public membershipAdmissionDocumentDate?: string, public membershipId?: number ) {} } diff --git a/src/main/webapp/i18n/de/asset.json b/src/main/webapp/i18n/de/asset.json index ff6df7e7..dee8fe54 100644 --- a/src/main/webapp/i18n/de/asset.json +++ b/src/main/webapp/i18n/de/asset.json @@ -2,25 +2,25 @@ "hsadminNgApp": { "asset": { "home": { - "title": "Assets", - "createLabel": "Asset erstellen", - "createOrEditLabel": "Asset erstellen oder bearbeiten" + "title": "Geschäftsguthaben-Transaktionen", + "createLabel": "Geschäftsguthaben-Transaktion erfassen", + "createOrEditLabel": "Geschäftsguthaben-Transaktion erfassen oder bearbeiten" }, - "created": "Asset erstellt mit ID {{ param }}", - "updated": "Asset aktualisiert mit ID {{ param }}", - "deleted": "Asset gelöscht mit ID {{ param }}", + "created": "Geschäftsguthaben-Transaktion erfasst mit ID {{ param }}", + "updated": "Geschäftsguthaben-Transaktion aktualisiert mit ID {{ param }}", + "deleted": "Geschäftsguthaben-Transaktion gelöscht mit ID {{ param }}", "delete": { - "question": "Soll Asset {{ id }} wirklich dauerhaft gelöscht werden?" + "question": "Soll die Geschäftsguthaben-Transaktion {{ id }} wirklich dauerhaft gelöscht werden?" }, "detail": { - "title": "Asset" + "title": "Geschäftsguthaben-Transaktion" }, - "documentDate": "Document Date", - "valueDate": "Value Date", - "action": "Action", - "amount": "Amount", - "remark": "Remark", - "membership": "Membership" + "documentDate": "Belegdatum", + "valueDate": "Buchungsdatum", + "action": "Transaktion", + "amount": "Betrag", + "remark": "Bemerkung", + "membership": "zugehörige Mitgliedschaft" } } } diff --git a/src/main/webapp/i18n/de/assetAction.json b/src/main/webapp/i18n/de/assetAction.json index d3f1ca77..e89d58f3 100644 --- a/src/main/webapp/i18n/de/assetAction.json +++ b/src/main/webapp/i18n/de/assetAction.json @@ -2,12 +2,12 @@ "hsadminNgApp": { "AssetAction": { "null": "", - "PAYMENT": "PAYMENT", - "HANDOVER": "HANDOVER", - "ADOPTION": "ADOPTION", - "LOSS": "LOSS", - "CLEARING": "CLEARING", - "PAYBACK": "PAYBACK" + "PAYMENT": "Einzahlung", + "HANDOVER": "Übertragung", + "ADOPTION": "Übernahme", + "LOSS": "Verlust", + "CLEARING": "Verrechnung", + "PAYBACK": "Auszahlung" } } } diff --git a/src/main/webapp/i18n/de/custom-error.json b/src/main/webapp/i18n/de/custom-error.json index 89c3fffc..1a6870e2 100644 --- a/src/main/webapp/i18n/de/custom-error.json +++ b/src/main/webapp/i18n/de/custom-error.json @@ -1,12 +1,20 @@ { "error": { - "shareSubscriptionPositivQuantity": "Zeichnungen von Geschäftsanteilen erfordern eine positive Stückzahl", + "shareSubscriptionPositiveQuantity": "Zeichnungen von Geschäftsanteilen erfordern eine positive Stückzahl", "shareCancellationNegativeQuantity": "Kündigungen von Geschäftsanteilen erfordern eine negative Stückzahl", "shareTransactionImmutable": "Transaktionen mit Geschäftsanteilen sind unveränderlich", "membershipNotDeletable": "Mitgliedschaft kann nicht gelöscht werden, setze stattdessen das 'untilDate'", "untilDateMustBeAfterSinceDate": "Mitgliedshafts-Austrittsdatum muss nach dem Beitrittsdatum liegen", "anotherUncancelledMembershipExists": "Nur eine einzige ungekündigte Mitgliedschaft pro Kunde ist zulässig", "initializationProhibited": "Initialisierung des Feldes unzulässig", - "updateProhibited": "Aktualisierung des Feldes unzulässig" + "updateProhibited": "Aktualisierung des Feldes unzulässig", + "documentDateMayNotBeAfterValueDate": "Belegdatum darf nicht vor dem Buchungsdatum liegen", + "assetTransactionImmutable": "Transaktionen mit Geschäftsguthaben sind unveränderlich", + "assetPaymentsPositiveAmount": "Einzahlungen von Geschäftsguthaben erfordern einen positiven Betrag", + "assetAdoptionsPositiveAmount": "Übernahmen von Geschäftsguthaben erfordern einen positiven Betrag", + "assetPaybacksNegativeAmount": "Auszahlungen von Geschäftsguthaben erfordern einen negativen Betrag", + "assetHandoversNegativeAmount": "Übertragungen von Geschäftsguthaben erfordern einen negativen Betrag", + "assetLossesNegativeAmount": "Verluste von Geschäftsguthaben erfordern einen negativen Betrag", + "assetClearingsNegativeAmount": "Verrechnungen von Geschäftsguthaben erfordern einen negativen Betrag" } } diff --git a/src/main/webapp/i18n/de/customer.json b/src/main/webapp/i18n/de/customer.json index a699be5a..af18676c 100644 --- a/src/main/webapp/i18n/de/customer.json +++ b/src/main/webapp/i18n/de/customer.json @@ -18,6 +18,13 @@ "reference": "Reference", "prefix": "Prefix", "name": "Name", + "kind": "Kind", + "birthDate": "Birth Date", + "birthPlace": "Birth Place", + "registrationCourt": "Registration Court", + "registrationNumber": "Registration Number", + "vatRegion": "Vat Region", + "vatNumber": "Vat Number", "contractualSalutation": "Contractual Salutation", "contractualAddress": "Contractual Address", "billingSalutation": "Billing Salutation", diff --git a/src/main/webapp/i18n/de/customerKind.json b/src/main/webapp/i18n/de/customerKind.json new file mode 100644 index 00000000..f96e75e4 --- /dev/null +++ b/src/main/webapp/i18n/de/customerKind.json @@ -0,0 +1,9 @@ +{ + "hsadminNgApp": { + "CustomerKind": { + "null": "", + "NATURAL": "NATURAL", + "LEGAL": "LEGAL" + } + } +} diff --git a/src/main/webapp/i18n/de/membership.json b/src/main/webapp/i18n/de/membership.json index 936c4fc9..e277b4dc 100644 --- a/src/main/webapp/i18n/de/membership.json +++ b/src/main/webapp/i18n/de/membership.json @@ -15,9 +15,10 @@ "detail": { "title": "Membership" }, - "documentDate": "Document Date", - "memberFrom": "Member From", - "memberUntil": "Member Until", + "admissionDocumentDate": "Admission Document Date", + "cancellationDocumentDate": "Cancellation Document Date", + "memberFromDate": "Member From Date", + "memberUntilDate": "Member Until Date", "remark": "Remark", "share": "Share", "asset": "Asset", diff --git a/src/main/webapp/i18n/de/sepaMandate.json b/src/main/webapp/i18n/de/sepaMandate.json index c0d1347b..f5ea6b73 100644 --- a/src/main/webapp/i18n/de/sepaMandate.json +++ b/src/main/webapp/i18n/de/sepaMandate.json @@ -18,11 +18,11 @@ "reference": "Reference", "iban": "Iban", "bic": "Bic", - "documentDate": "Document Date", - "validFrom": "Valid From", - "validUntil": "Valid Until", - "lastUsed": "Last Used", - "cancellationDate": "Cancellation Date", + "grantingDocumentDate": "Granting Document Date", + "revokationDocumentDate": "Revokation Document Date", + "validFromDate": "Valid From Date", + "validUntilDate": "Valid Until Date", + "lastUsedDate": "Last Used Date", "remark": "Remark", "customer": "Customer" } diff --git a/src/main/webapp/i18n/de/share.json b/src/main/webapp/i18n/de/share.json index fdb5dec4..2cadbe83 100644 --- a/src/main/webapp/i18n/de/share.json +++ b/src/main/webapp/i18n/de/share.json @@ -2,25 +2,25 @@ "hsadminNgApp": { "share": { "home": { - "title": "Shares", - "createLabel": "Share erstellen", - "createOrEditLabel": "Share erstellen oder bearbeiten" + "title": "Geschäftsanteil-Transaktionen", + "createLabel": "Geschäftsanteil-Transaktion erfassen", + "createOrEditLabel": "Geschäftsanteil-Transaktion erfassen oder bearbeiten" }, - "created": "Share erstellt mit ID {{ param }}", - "updated": "Share aktualisiert mit ID {{ param }}", - "deleted": "Share gelöscht mit ID {{ param }}", + "created": "Geschäftsanteil-Transaktion erfasst mit ID {{ param }}", + "updated": "Geschäftsanteil-Transaktion aktualisiert mit ID {{ param }}", + "deleted": "Geschäftsanteil-Transaktion gelöscht mit ID {{ param }}", "delete": { - "question": "Soll Share {{ id }} wirklich dauerhaft gelöscht werden?" + "question": "Soll die Geschäftsanteil-Transaktion {{ id }} wirklich dauerhaft gelöscht werden?" }, "detail": { - "title": "Share" + "title": "Geschäftsanteil-Transaktion" }, - "documentDate": "Document Date", - "valueDate": "Value Date", - "action": "Action", - "quantity": "Quantity", - "remark": "Remark", - "membership": "Membership" + "documentDate": "Belegdatum", + "valueDate": "Buchungsdatum", + "action": "Aktion", + "quantity": "Anzahl", + "remark": "Bemerkung", + "membership": "zugehörige Mitgliedschaft" } } } diff --git a/src/main/webapp/i18n/de/shareAction.json b/src/main/webapp/i18n/de/shareAction.json index 2016c4bb..63d4be57 100644 --- a/src/main/webapp/i18n/de/shareAction.json +++ b/src/main/webapp/i18n/de/shareAction.json @@ -2,8 +2,8 @@ "hsadminNgApp": { "ShareAction": { "null": "", - "SUBSCRIPTION": "SUBSCRIPTION", - "CANCELLATION": "CANCELLATION" + "SUBSCRIPTION": "Zeichnung", + "CANCELLATION": "Kündigung" } } } diff --git a/src/main/webapp/i18n/de/vatRegion.json b/src/main/webapp/i18n/de/vatRegion.json new file mode 100644 index 00000000..339febc1 --- /dev/null +++ b/src/main/webapp/i18n/de/vatRegion.json @@ -0,0 +1,10 @@ +{ + "hsadminNgApp": { + "VatRegion": { + "null": "", + "DOMESTIC": "DOMESTIC", + "EU": "EU", + "OTHER": "OTHER" + } + } +} diff --git a/src/main/webapp/i18n/en/asset.json b/src/main/webapp/i18n/en/asset.json index ac290fb7..a380f70f 100644 --- a/src/main/webapp/i18n/en/asset.json +++ b/src/main/webapp/i18n/en/asset.json @@ -2,25 +2,25 @@ "hsadminNgApp": { "asset": { "home": { - "title": "Assets", - "createLabel": "Create a new Asset", - "createOrEditLabel": "Create or edit a Asset" + "title": "Asset Transactions", + "createLabel": "Register a new asset transaction", + "createOrEditLabel": "Register or edit an asset transaction" }, - "created": "A new Asset is created with identifier {{ param }}", - "updated": "A Asset is updated with identifier {{ param }}", - "deleted": "A Asset is deleted with identifier {{ param }}", + "created": "A new asset transaction is registered with identifier {{ param }}", + "updated": "An asset transaction is updated with identifier {{ param }}", + "deleted": "An asset transaction is deleted with identifier {{ param }}", "delete": { - "question": "Are you sure you want to delete Asset {{ id }}?" + "question": "Are you sure you want to delete asset transaction {{ id }}?" }, "detail": { - "title": "Asset" + "title": "Asset transaction" }, - "documentDate": "Document Date", - "valueDate": "Value Date", + "documentDate": "Document date", + "valueDate": "Value date", "action": "Action", "amount": "Amount", "remark": "Remark", - "membership": "Membership" + "membership": "Related membership" } } } diff --git a/src/main/webapp/i18n/en/assetAction.json b/src/main/webapp/i18n/en/assetAction.json index d3f1ca77..e17447ca 100644 --- a/src/main/webapp/i18n/en/assetAction.json +++ b/src/main/webapp/i18n/en/assetAction.json @@ -2,12 +2,12 @@ "hsadminNgApp": { "AssetAction": { "null": "", - "PAYMENT": "PAYMENT", - "HANDOVER": "HANDOVER", - "ADOPTION": "ADOPTION", - "LOSS": "LOSS", - "CLEARING": "CLEARING", - "PAYBACK": "PAYBACK" + "PAYMENT": "Payment", + "HANDOVER": "Handover", + "ADOPTION": "Adoption", + "LOSS": "Loss", + "CLEARING": "Clearing", + "PAYBACK": "Payback" } } } diff --git a/src/main/webapp/i18n/en/custom-error.json b/src/main/webapp/i18n/en/custom-error.json index 13d9463a..ee5daa7e 100644 --- a/src/main/webapp/i18n/en/custom-error.json +++ b/src/main/webapp/i18n/en/custom-error.json @@ -1,12 +1,20 @@ { "error": { - "shareSubscriptionPositivQuantity": "Share subscriptions require a positive quantity", + "shareSubscriptionPositiveQuantity": "Share subscriptions require a positive quantity", "shareCancellationNegativeQuantity": "Share cancellations require a negative quantity", "shareTransactionImmutable": "Share transactions are immutable", "membershipNotDeletable": "Membership cannot be deleted, instead set 'untilDate'", "untilDateMustBeAfterSinceDate": "Membership until date must be after since date", "anotherUncancelledMembershipExists": "Only a single uncancelled membership allowed per customer", "initializationProhibited": "Initialization of the field prohibited", - "updateProhibited": "Update of the field prohibited" + "updateProhibited": "Update of the field prohibited", + "documentDateMayNotBeAfterValueDate": "Document date may not be after value date", + "assetTransactionImmutable": "Asset transactions are immutable", + "assetPaymentsPositiveAmount": "Asset payments require a positive amount", + "assetAdoptionsPositiveAmount": "Asset adoptions require a positive amount", + "assetPaybacksNegativeAmount": "Asset paybacks require a negative amount", + "assetHandoversNegativeAmount": "Asset handovers require a negative amount", + "assetLossesNegativeAmount": "Asset losses require a negative amount", + "assetClearingsNegativeAmount": "Asset clearings require a negative amount" } } diff --git a/src/main/webapp/i18n/en/customer.json b/src/main/webapp/i18n/en/customer.json index 6f30090f..6444cda2 100644 --- a/src/main/webapp/i18n/en/customer.json +++ b/src/main/webapp/i18n/en/customer.json @@ -18,6 +18,13 @@ "reference": "Reference", "prefix": "Prefix", "name": "Name", + "kind": "Kind", + "birthDate": "Birth Date", + "birthPlace": "Birth Place", + "registrationCourt": "Registration Court", + "registrationNumber": "Registration Number", + "vatRegion": "Vat Region", + "vatNumber": "Vat Number", "contractualSalutation": "Contractual Salutation", "contractualAddress": "Contractual Address", "billingSalutation": "Billing Salutation", diff --git a/src/main/webapp/i18n/en/customerKind.json b/src/main/webapp/i18n/en/customerKind.json new file mode 100644 index 00000000..f96e75e4 --- /dev/null +++ b/src/main/webapp/i18n/en/customerKind.json @@ -0,0 +1,9 @@ +{ + "hsadminNgApp": { + "CustomerKind": { + "null": "", + "NATURAL": "NATURAL", + "LEGAL": "LEGAL" + } + } +} diff --git a/src/main/webapp/i18n/en/membership.json b/src/main/webapp/i18n/en/membership.json index 9bf9136c..30388671 100644 --- a/src/main/webapp/i18n/en/membership.json +++ b/src/main/webapp/i18n/en/membership.json @@ -15,9 +15,10 @@ "detail": { "title": "Membership" }, - "documentDate": "Document Date", - "memberFrom": "Member From", - "memberUntil": "Member Until", + "admissionDocumentDate": "Admission Document Date", + "cancellationDocumentDate": "Cancellation Document Date", + "memberFromDate": "Member From Date", + "memberUntilDate": "Member Until Date", "remark": "Remark", "share": "Share", "asset": "Asset", diff --git a/src/main/webapp/i18n/en/sepaMandate.json b/src/main/webapp/i18n/en/sepaMandate.json index a403e016..d9aca2be 100644 --- a/src/main/webapp/i18n/en/sepaMandate.json +++ b/src/main/webapp/i18n/en/sepaMandate.json @@ -18,11 +18,11 @@ "reference": "Reference", "iban": "Iban", "bic": "Bic", - "documentDate": "Document Date", - "validFrom": "Valid From", - "validUntil": "Valid Until", - "lastUsed": "Last Used", - "cancellationDate": "Cancellation Date", + "grantingDocumentDate": "Granting Document Date", + "revokationDocumentDate": "Revokation Document Date", + "validFromDate": "Valid From Date", + "validUntilDate": "Valid Until Date", + "lastUsedDate": "Last Used Date", "remark": "Remark", "customer": "Customer" } diff --git a/src/main/webapp/i18n/en/share.json b/src/main/webapp/i18n/en/share.json index 5c178744..e103c0ec 100644 --- a/src/main/webapp/i18n/en/share.json +++ b/src/main/webapp/i18n/en/share.json @@ -2,25 +2,25 @@ "hsadminNgApp": { "share": { "home": { - "title": "Shares", - "createLabel": "Create a new Share", - "createOrEditLabel": "Create or edit a Share" + "title": "Share Transactions", + "createLabel": "Register a new share transaction", + "createOrEditLabel": "Register or edit a share transaction" }, - "created": "A new Share is created with identifier {{ param }}", - "updated": "A Share is updated with identifier {{ param }}", - "deleted": "A Share is deleted with identifier {{ param }}", + "created": "A new share transactions is registered with identifier {{ param }}", + "updated": "A share transaction is updated with identifier {{ param }}", + "deleted": "A share transcation is deleted with identifier {{ param }}", "delete": { - "question": "Are you sure you want to delete Share {{ id }}?" + "question": "Are you sure you want to delete share transaction {{ id }}?" }, "detail": { - "title": "Share" + "title": "Share transaction" }, - "documentDate": "Document Date", - "valueDate": "Value Date", + "documentDate": "Document date", + "valueDate": "Value date", "action": "Action", "quantity": "Quantity", "remark": "Remark", - "membership": "Membership" + "membership": "Related membership" } } } diff --git a/src/main/webapp/i18n/en/shareAction.json b/src/main/webapp/i18n/en/shareAction.json index 2016c4bb..b2aed341 100644 --- a/src/main/webapp/i18n/en/shareAction.json +++ b/src/main/webapp/i18n/en/shareAction.json @@ -2,8 +2,8 @@ "hsadminNgApp": { "ShareAction": { "null": "", - "SUBSCRIPTION": "SUBSCRIPTION", - "CANCELLATION": "CANCELLATION" + "SUBSCRIPTION": "Subscription", + "CANCELLATION": "Cancellation" } } } diff --git a/src/main/webapp/i18n/en/vatRegion.json b/src/main/webapp/i18n/en/vatRegion.json new file mode 100644 index 00000000..339febc1 --- /dev/null +++ b/src/main/webapp/i18n/en/vatRegion.json @@ -0,0 +1,10 @@ +{ + "hsadminNgApp": { + "VatRegion": { + "null": "", + "DOMESTIC": "DOMESTIC", + "EU": "EU", + "OTHER": "OTHER" + } + } +} diff --git a/src/test/java/org/hostsharing/hsadminng/repository/MembershipRepositoryIntTest.java b/src/test/java/org/hostsharing/hsadminng/repository/MembershipRepositoryIntTest.java index 52337747..d9a09878 100644 --- a/src/test/java/org/hostsharing/hsadminng/repository/MembershipRepositoryIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/repository/MembershipRepositoryIntTest.java @@ -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; @@ -20,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @SpringBootTest(classes = HsadminNgApp.class) @Transactional -public class MembershipRepositoryIntTest { +public class MembershipRepositoryIntTest { @Autowired private CustomerRepository customerRepository; @@ -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,10 +84,11 @@ public class MembershipRepositoryIntTest { final Customer customer = createCustomer(); final Membership membership = new Membership(); membership.setCustomer(customer); - membership.setMemberUntil(LocalDate.parse(from)); + membership.setMemberFromDate(LocalDate.parse(from)); if (to != null) { - membership.setMemberFrom(LocalDate.parse(to)); + membership.setMemberUntilDate(LocalDate.parse(to)); } + membership.setAdmissionDocumentDate(membership.getMemberFromDate().minusDays(7)); membershipRepository.save(membership); return customer; } diff --git a/src/test/java/org/hostsharing/hsadminng/service/AssetValidatorUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/AssetValidatorUnitTest.java new file mode 100644 index 00000000..d3b4c06a --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/service/AssetValidatorUnitTest.java @@ -0,0 +1,238 @@ +package org.hostsharing.hsadminng.service; + +import com.google.common.collect.ImmutableList; +import org.apache.commons.lang3.RandomUtils; +import org.assertj.core.api.AbstractThrowableAssert; +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; +import org.hostsharing.hsadminng.service.dto.AssetDTO; +import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; +import org.junit.Test; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.function.Consumer; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowableOfType; + +public class AssetValidatorUnitTest { + + private AssetValidator assetValidator = new AssetValidator(); + + @Test + public void shouldAcceptValidIncreasingTransaction() { + for (AssetAction action : ImmutableList.of(AssetAction.PAYMENT, AssetAction.ADOPTION)) { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(action).withAmount("64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isNull(); + } + } + + @Test + public void shouldAcceptValidDecreasingTransaction() { + for (AssetAction action : ImmutableList.of(AssetAction.PAYBACK, AssetAction.HANDOVER, AssetAction.CLEARING, AssetAction.LOSS)) { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(action).withAmount("-64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isNull(); + } + } + + @Test + public void shouldAcceptIfDocumentDateEqualsValueDate() { + new GivenAssetValidationTestCase() + .withDocumentDate("2019-04-11").withValueDate("2019-04-11") + .withAction(AssetAction.PAYMENT).withAmount("64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isNull(); + } + + @Test + public void shouldRejectUpdates() { + new GivenAssetValidationTestCase() + .withId(RandomUtils.nextLong()) + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset transactions are immutable", "asset", "assetTransactionImmutable")); + } + + @Test + public void shouldRejectIfDocumentDateAfterValueDate() { + new GivenAssetValidationTestCase() + .withDocumentDate("2019-04-13").withValueDate("2019-04-12") + .withAction(AssetAction.PAYMENT).withAmount("64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Document date may not be after value date", "asset", "documentDateMayNotBeAfterValueDate")); + } + + @Test + public void shouldRejectIfPaymentWithNegativeAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.PAYMENT).withAmount("-64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset payments require a positive amount", "asset", "assetPaymentsPositiveAmount")); + } + + @Test + public void shouldRejectIfPaymentWithZeroAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.PAYMENT).withAmount("0.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset payments require a positive amount", "asset", "assetPaymentsPositiveAmount")); + } + + @Test + public void shouldRejectIfAdoptionWithNegativeAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.ADOPTION).withAmount("-64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset adoptions require a positive amount", "asset", "assetAdoptionsPositiveAmount")); + } + + @Test + public void shouldRejectIfAdoptionWithZeroAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.ADOPTION).withAmount("0.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset adoptions require a positive amount", "asset", "assetAdoptionsPositiveAmount")); + } + + @Test + public void shouldRejectIfPaybackWithPositiveAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.PAYBACK).withAmount("64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset paybacks require a negative amount", "asset", "assetPaybacksNegativeAmount")); + } + + @Test + public void shouldRejectIfPaybackWithZeroAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.PAYBACK).withAmount("0.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset paybacks require a negative amount", "asset", "assetPaybacksNegativeAmount")); + } + + @Test + public void shouldRejectIfHandoverWithPositiveAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.HANDOVER).withAmount("64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset handovers require a negative amount", "asset", "assetHandoversNegativeAmount")); + } + + @Test + public void shouldRejectIfHandoverWithZeroAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.HANDOVER).withAmount("0.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset handovers require a negative amount", "asset", "assetHandoversNegativeAmount")); + } + + @Test + public void shouldRejectIfLossWithPositiveAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.LOSS).withAmount("64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset losses require a negative amount", "asset", "assetLossesNegativeAmount")); + } + + @Test + public void shouldRejectIfLossWithZeroAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.LOSS).withAmount("0.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset losses require a negative amount", "asset", "assetLossesNegativeAmount")); + } + + @Test + public void shouldRejectIfClearingWithPositiveAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.CLEARING).withAmount("64.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset clearings require a negative amount", "asset", "assetClearingsNegativeAmount")); + } + + @Test + public void shouldRejectIfClearingWithZeroAmount() { + new GivenAssetValidationTestCase() + .withAnyValidDateValues() + .withAction(AssetAction.CLEARING).withAmount("0.00") + .when((AssetDTO assetDto) -> assetValidator.validate(assetDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Asset clearings require a negative amount", "asset", "assetClearingsNegativeAmount")); + } + + + // -- only test fixture below --- + + private class GivenAssetValidationTestCase { + + private final AssetDTO assetDto = new AssetDTO(); + private BadRequestAlertException actualException; + + public GivenAssetValidationTestCase withId(long id) { + assetDto.setId(id); + return this; + } + + GivenAssetValidationTestCase withDocumentDate(String documentDate) { + assetDto.setDocumentDate(LocalDate.parse(documentDate)); + return this; + } + + GivenAssetValidationTestCase withValueDate(String valueDate) { + assetDto.setValueDate(LocalDate.parse(valueDate)); + return this; + } + + public GivenAssetValidationTestCase withAnyValidDateValues() { + return withDocumentDate("2019-04-11").withValueDate("2019-04-12"); + } + + GivenAssetValidationTestCase withAction(AssetAction assetAction) { + assetDto.setAction(assetAction); + return this; + } + + GivenAssetValidationTestCase withAmount(String amount) { + assetDto.setAmount(new BigDecimal(amount)); + return this; + } + + GivenAssetValidationTestCase when(final Consumer statement) { + actualException = catchThrowableOfType(() -> assetValidator.validate(assetDto), BadRequestAlertException.class); + return this; + } + + public AbstractThrowableAssert thenActualException() { + return assertThat(actualException); + } + } +} diff --git a/src/test/java/org/hostsharing/hsadminng/service/MembershipValidatorUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/MembershipValidatorUnitTest.java index a27c5d21..df080721 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/MembershipValidatorUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/MembershipValidatorUnitTest.java @@ -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; } diff --git a/src/test/java/org/hostsharing/hsadminng/service/ShareServiceUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/ShareServiceUnitTest.java index 24240081..5dacddfb 100644 --- a/src/test/java/org/hostsharing/hsadminng/service/ShareServiceUnitTest.java +++ b/src/test/java/org/hostsharing/hsadminng/service/ShareServiceUnitTest.java @@ -19,6 +19,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowableOfType; import static org.mockito.ArgumentMatchers.same; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; // HINT: In IntelliJ IDEA such unit test classes can be created with Shift-Ctrl-T. @@ -31,6 +33,9 @@ public class ShareServiceUnitTest { @Mock private ShareRepository shareRepository; + @Mock + private ShareValidator shareValidator; // needed for @InjectMocks shareService + @Mock private ShareMapper shareMapper; @@ -55,23 +60,11 @@ public class ShareServiceUnitTest { } @Test - public void saveShouldNotUpdateAnyExistingShareTransaction() { - // given - final ShareDTO givenShareDTO = givenShareDTO(anyNonNullId(), ShareAction.SUBSCRIPTION, anyPositiveNumber()); - - - // when - final Throwable throwException = catchThrowableOfType(() -> shareService.save(givenShareDTO), BadRequestAlertException.class); - - // then - assertThat(throwException).isEqualToComparingFieldByField( - new BadRequestAlertException("Share transactions are immutable", "share", "shareTransactionImmutable")); - } - - @Test - public void saveShouldPersistSubscriptionWithPositiveAmount() { + public void saveShouldPersistValidTransactions() { // given final ShareDTO givenShareDTO = givenShareDTO(null, ShareAction.SUBSCRIPTION, anyPositiveNumber()); + // HINT: given(...)...will...() can't be used for void methods, in that case use Mockito's do...() methods + doNothing().when(shareValidator).validate(givenShareDTO); // when final ShareDTO returnedShareDto = shareService.save(givenShareDTO); @@ -81,22 +74,24 @@ public class ShareServiceUnitTest { } @Test - public void saveShouldRejectSubscriptionWithNegativeAmount() { + public void saveShouldNotPersistInvalidTransactions() { // given final ShareDTO givenShareDTO = givenShareDTO(null, ShareAction.SUBSCRIPTION, anyNegativeNumber()); + doThrow(new BadRequestAlertException("Some Dummy Test Violation", "share", "shareInvalidTestDummy")).when(shareValidator).validate(givenShareDTO); // when final Throwable throwException = catchThrowableOfType(() -> shareService.save(givenShareDTO), BadRequestAlertException.class); // then assertThat(throwException).isEqualToComparingFieldByField( - new BadRequestAlertException("Share subscriptions require a positive quantity", "share", "shareSubscriptionPositivQuantity")); + new BadRequestAlertException("Some Dummy Test Violation", "share", "shareInvalidTestDummy")); } @Test - public void saveShouldPersistCancellationWithNegativeAmount() { + public void saveShouldUpdateValidTransactions() { // given - final ShareDTO givenShareDTO = givenShareDTO(null, ShareAction.CANCELLATION, anyNegativeNumber()); + final ShareDTO givenShareDTO = givenShareDTO(anyNonNullId(), ShareAction.SUBSCRIPTION, anyPositiveNumber()); + doNothing().when(shareValidator).validate(givenShareDTO); // when final ShareDTO returnedShareDto = shareService.save(givenShareDTO); @@ -106,16 +101,18 @@ public class ShareServiceUnitTest { } @Test - public void saveShouldRejectCancellationWithPositiveAmount() { + public void saveShouldNotUpdateInvalidTransactions() { // given - final ShareDTO givenShareDTO = givenShareDTO(null, ShareAction.CANCELLATION, anyPositiveNumber()); + final ShareDTO givenShareDTO = givenShareDTO(anyNonNullId(), ShareAction.SUBSCRIPTION, anyNegativeNumber()); + // HINT: given(...) can't be used for void methods, in that case use Mockito's do...() methods + doThrow(new BadRequestAlertException("Some Dummy Test Violation", "share", "shareInvalidTestDummy")).when(shareValidator).validate(givenShareDTO); // when final Throwable throwException = catchThrowableOfType(() -> shareService.save(givenShareDTO), BadRequestAlertException.class); // then assertThat(throwException).isEqualToComparingFieldByField( - new BadRequestAlertException("Share cancellations require a negative quantity", "share", "shareCancellationNegativeQuantity")); + new BadRequestAlertException("Some Dummy Test Violation", "share", "shareInvalidTestDummy")); } // --- only test fixture code below --- diff --git a/src/test/java/org/hostsharing/hsadminng/service/ShareValidatorUnitTest.java b/src/test/java/org/hostsharing/hsadminng/service/ShareValidatorUnitTest.java new file mode 100644 index 00000000..d521f510 --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/service/ShareValidatorUnitTest.java @@ -0,0 +1,154 @@ +package org.hostsharing.hsadminng.service; + +import org.apache.commons.lang3.RandomUtils; +import org.assertj.core.api.AbstractThrowableAssert; +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; +import org.hostsharing.hsadminng.service.dto.ShareDTO; +import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException; +import org.junit.Test; + +import java.time.LocalDate; +import java.util.function.Consumer; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowableOfType; + +public class ShareValidatorUnitTest { + + private ShareValidator shareValidator = new ShareValidator(); + + @Test + public void shouldAcceptValidSubscription() { + new GivenShareValidationTestCase() + .withAnyValidDateValues() + .withAction(ShareAction.SUBSCRIPTION).withQuantity(1) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isNull(); + } + + @Test + public void shouldAcceptValidCancellation() { + new GivenShareValidationTestCase() + .withAnyValidDateValues() + .withAction(ShareAction.CANCELLATION).withQuantity(-1) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isNull(); + } + + @Test + public void shouldAcceptIfDocumentDateEqualsValueDate() { + new GivenShareValidationTestCase() + .withDocumentDate("2019-04-11").withValueDate("2019-04-11") + .withAction(ShareAction.SUBSCRIPTION).withQuantity(1) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isNull(); + } + + @Test + public void shouldRejectUpdates() { + new GivenShareValidationTestCase() + .withId(RandomUtils.nextLong()) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Share transactions are immutable", "share", "shareTransactionImmutable")); + } + + @Test + public void shouldRejectIfDocumentDateAfterValueDate() { + new GivenShareValidationTestCase() + .withDocumentDate("2019-04-13").withValueDate("2019-04-12") + .withAction(ShareAction.SUBSCRIPTION).withQuantity(1) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Document date may not be after value date", "share", "documentDateMayNotBeAfterValueDate")); + } + + @Test + public void shouldRejectIfSubscriptionWithNegativeQuantity() { + new GivenShareValidationTestCase() + .withAnyValidDateValues() + .withAction(ShareAction.SUBSCRIPTION).withQuantity(-1) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Share subscriptions require a positive quantity", "share", "shareSubscriptionPositiveQuantity")); + } + + @Test + public void shouldRejectIfSubscriptionWithZeroQuantity() { + new GivenShareValidationTestCase() + .withAnyValidDateValues() + .withAction(ShareAction.SUBSCRIPTION).withQuantity(0) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Share subscriptions require a positive quantity", "share", "shareSubscriptionPositiveQuantity")); + } + + @Test + public void shouldRejectIfCancellationWithPositiveQuantity() { + new GivenShareValidationTestCase() + .withAnyValidDateValues() + .withAction(ShareAction.CANCELLATION).withQuantity(1) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Share cancellations require a negative quantity", "share", "shareCancellationNegativeQuantity")); + } + + @Test + public void shouldRejectIfCancellationWithZeroQuantity() { + new GivenShareValidationTestCase() + .withAnyValidDateValues() + .withAction(ShareAction.CANCELLATION).withQuantity(0) + .when((ShareDTO shareDto) -> shareValidator.validate(shareDto)) + .thenActualException().isEqualToComparingFieldByField(new BadRequestAlertException( + "Share cancellations require a negative quantity", "share", "shareCancellationNegativeQuantity")); + } + + + // -- only test fixture below --- + + private class GivenShareValidationTestCase { + + private final ShareDTO shareDto = new ShareDTO(); + private BadRequestAlertException actualException; + + public GivenShareValidationTestCase withId(long id) { + shareDto.setId(id); + return this; + } + + GivenShareValidationTestCase withDocumentDate(String documentDate) { + shareDto.setDocumentDate(LocalDate.parse(documentDate)); + return this; + } + + GivenShareValidationTestCase withValueDate(String valueDate) { + shareDto.setValueDate(LocalDate.parse(valueDate)); + return this; + } + + public GivenShareValidationTestCase withAnyValidDateValues() { + return withDocumentDate("2019-04-11").withValueDate("2019-04-12"); + } + + GivenShareValidationTestCase withAction(ShareAction shareAction) { + shareDto.setAction(shareAction); + return this; + } + + GivenShareValidationTestCase withQuantity(Integer quantity) { + shareDto.setQuantity(quantity); + return this; + } + + GivenShareValidationTestCase when(final Consumer statement) { + actualException = catchThrowableOfType(() -> shareValidator.validate(shareDto), BadRequestAlertException.class); + return this; + } + + public AbstractThrowableAssert thenActualException() { + return assertThat(actualException); + } + } +} + + diff --git a/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOTest.java b/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOTest.java new file mode 100644 index 00000000..ffcec115 --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/service/dto/MembershipDTOTest.java @@ -0,0 +1,15 @@ +package org.hostsharing.hsadminng.service.dto; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MembershipDTOTest { + + @Test + public void withShouldApplyCallback() { + final MembershipDTO actual = new MembershipDTO().with(m -> m.setRemark("Some Remark")); + + assertThat(actual.getRemark()).isEqualTo("Some Remark"); + } +} diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java index 99a0217f..ae7212be 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java @@ -1,17 +1,15 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; - import org.hostsharing.hsadminng.domain.Asset; import org.hostsharing.hsadminng.domain.Membership; +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; import org.hostsharing.hsadminng.repository.AssetRepository; +import org.hostsharing.hsadminng.service.AssetQueryService; import org.hostsharing.hsadminng.service.AssetService; import org.hostsharing.hsadminng.service.dto.AssetDTO; import org.hostsharing.hsadminng.service.mapper.AssetMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.AssetCriteria; -import org.hostsharing.hsadminng.service.AssetQueryService; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,14 +31,11 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; - -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.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; /** * Test class for the AssetResource REST controller. * @@ -129,6 +124,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 +557,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 +639,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 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 +682,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 assetList = assetRepository.findAll(); - assertThat(assetList).hasSize(databaseSizeBeforeDelete - 1); + assertThat(assetList).hasSize(databaseSizeBeforeDelete); } @Test 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 ce8721fc..01d0fa92 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java @@ -1,18 +1,17 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; - import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.domain.SepaMandate; +import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; +import org.hostsharing.hsadminng.domain.enumeration.VatRegion; import org.hostsharing.hsadminng.repository.CustomerRepository; +import org.hostsharing.hsadminng.service.CustomerQueryService; import org.hostsharing.hsadminng.service.CustomerService; import org.hostsharing.hsadminng.service.dto.CustomerDTO; import org.hostsharing.hsadminng.service.mapper.CustomerMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.CustomerCriteria; -import org.hostsharing.hsadminng.service.CustomerQueryService; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -29,15 +28,15 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.Validator; import javax.persistence.EntityManager; +import java.time.LocalDate; +import java.time.ZoneId; import java.util.List; - -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.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - /** * Test class for the CustomerResource REST controller. * @@ -49,27 +48,56 @@ public class CustomerResourceIntTest { private static final Integer DEFAULT_REFERENCE = 10000; private static final Integer UPDATED_REFERENCE = 10001; + private static final Integer OTHER_REFERENCE_BASE = 11000; - private static final String DEFAULT_PREFIX = "hu"; - private static final String UPDATED_PREFIX = "umj"; + private static final String DEFAULT_PREFIX = "def"; + private static final String UPDATED_PREFIX = "new"; + private static final String OTHER_PREFIX_BASE = "o"; - private static final String DEFAULT_NAME = "AAAAAAAAAA"; - private static final String UPDATED_NAME = "BBBBBBBBBB"; + private static final String DEFAULT_NAME = "Default GmbH"; + private static final String UPDATED_NAME = "Updated Default GmbH"; + private static final String OTHER_NAME_BASE = "Other Corp."; - private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA"; - private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB"; + private static final String DEFAULT_CONTRACTUAL_ADDRESS = "Default Address"; + private static final String UPDATED_CONTRACTUAL_ADDRESS = "Updated Address"; + private static final String OTHER_CONTRACTUAL_ADDRESS_BASE = "Other Street "; - private static final String DEFAULT_CONTRACTUAL_ADDRESS = "AAAAAAAAAA"; - private static final String UPDATED_CONTRACTUAL_ADDRESS = "BBBBBBBBBB"; + private static final String DEFAULT_CONTRACTUAL_SALUTATION = "Default Contractual Salutation"; + private static final String UPDATED_CONTRACTUAL_SALUTATION = "Update Contractual Salutation"; - private static final String DEFAULT_BILLING_SALUTATION = "AAAAAAAAAA"; - private static final String UPDATED_BILLING_SALUTATION = "BBBBBBBBBB"; + private static final String DEFAULT_BILLING_ADDRESS = "Default Billing Address"; + private static final String UPDATED_BILLING_ADDRESS = "Updated Billing Address"; - private static final String DEFAULT_BILLING_ADDRESS = "AAAAAAAAAA"; - private static final String UPDATED_BILLING_ADDRESS = "BBBBBBBBBB"; + private static final String DEFAULT_BILLING_SALUTATION = "Default Billing Salutation"; + private static final String UPDATED_BILLING_SALUTATION = "Updted Billing Salutation"; - private static final String DEFAULT_REMARK = "AAAAAAAAAA"; - private static final String UPDATED_REMARK = "BBBBBBBBBB"; + private static final String DEFAULT_REMARK = "Default Remark"; + private static final String UPDATED_REMARK = "Updated Remark"; + + 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()); + + private static final String DEFAULT_BIRTH_PLACE = "AAAAAAAAAA"; + private static final String UPDATED_BIRTH_PLACE = "BBBBBBBBBB"; + + private static final String DEFAULT_REGISTRATION_COURT = "AAAAAAAAAA"; + private static final String UPDATED_REGISTRATION_COURT = "BBBBBBBBBB"; + + private static final String DEFAULT_REGISTRATION_NUMBER = "AAAAAAAAAA"; + private static final String UPDATED_REGISTRATION_NUMBER = "BBBBBBBBBB"; + + 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"; + + private static int otherCounter = 0; @Autowired private CustomerRepository customerRepository; @@ -125,6 +153,13 @@ public class CustomerResourceIntTest { .reference(DEFAULT_REFERENCE) .prefix(DEFAULT_PREFIX) .name(DEFAULT_NAME) + .kind(DEFAULT_KIND) + .birthDate(DEFAULT_BIRTH_DATE) + .birthPlace(DEFAULT_BIRTH_PLACE) + .registrationCourt(DEFAULT_REGISTRATION_COURT) + .registrationNumber(DEFAULT_REGISTRATION_NUMBER) + .vatRegion(DEFAULT_VAT_REGION) + .vatNumber(DEFAULT_VAT_NUMBER) .contractualSalutation(DEFAULT_CONTRACTUAL_SALUTATION) .contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS) .billingSalutation(DEFAULT_BILLING_SALUTATION) @@ -133,6 +168,26 @@ 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 createPersistentEntity(EntityManager em) { + Customer customer = new Customer() + .reference(OTHER_REFERENCE_BASE + otherCounter) + .prefix(OTHER_PREFIX_BASE + String.format("%02d", otherCounter)) + .name(OTHER_NAME_BASE + otherCounter) + .kind(OTHER_KIND) + .vatRegion(OTHER_VAT_REGION) + .contractualAddress(OTHER_CONTRACTUAL_ADDRESS_BASE + otherCounter); + em.persist(customer); + em.flush(); + ++otherCounter; + return customer; + } + @Before public void initTest() { customer = createEntity(em); @@ -157,6 +212,13 @@ public class CustomerResourceIntTest { assertThat(testCustomer.getReference()).isEqualTo(DEFAULT_REFERENCE); assertThat(testCustomer.getPrefix()).isEqualTo(DEFAULT_PREFIX); assertThat(testCustomer.getName()).isEqualTo(DEFAULT_NAME); + assertThat(testCustomer.getKind()).isEqualTo(DEFAULT_KIND); + assertThat(testCustomer.getBirthDate()).isEqualTo(DEFAULT_BIRTH_DATE); + assertThat(testCustomer.getBirthPlace()).isEqualTo(DEFAULT_BIRTH_PLACE); + assertThat(testCustomer.getRegistrationCourt()).isEqualTo(DEFAULT_REGISTRATION_COURT); + assertThat(testCustomer.getRegistrationNumber()).isEqualTo(DEFAULT_REGISTRATION_NUMBER); + assertThat(testCustomer.getVatRegion()).isEqualTo(DEFAULT_VAT_REGION); + assertThat(testCustomer.getVatNumber()).isEqualTo(DEFAULT_VAT_NUMBER); assertThat(testCustomer.getContractualSalutation()).isEqualTo(DEFAULT_CONTRACTUAL_SALUTATION); assertThat(testCustomer.getContractualAddress()).isEqualTo(DEFAULT_CONTRACTUAL_ADDRESS); assertThat(testCustomer.getBillingSalutation()).isEqualTo(DEFAULT_BILLING_SALUTATION); @@ -241,6 +303,44 @@ public class CustomerResourceIntTest { assertThat(customerList).hasSize(databaseSizeBeforeTest); } + @Test + @Transactional + public void checkKindIsRequired() throws Exception { + int databaseSizeBeforeTest = customerRepository.findAll().size(); + // set the field null + customer.setKind(null); + + // Create the Customer, which fails. + CustomerDTO customerDTO = customerMapper.toDto(customer); + + restCustomerMockMvc.perform(post("/api/customers") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(customerDTO))) + .andExpect(status().isBadRequest()); + + List customerList = customerRepository.findAll(); + assertThat(customerList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkVatRegionIsRequired() throws Exception { + int databaseSizeBeforeTest = customerRepository.findAll().size(); + // set the field null + customer.setVatRegion(null); + + // Create the Customer, which fails. + CustomerDTO customerDTO = customerMapper.toDto(customer); + + restCustomerMockMvc.perform(post("/api/customers") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(customerDTO))) + .andExpect(status().isBadRequest()); + + List customerList = customerRepository.findAll(); + assertThat(customerList).hasSize(databaseSizeBeforeTest); + } + @Test @Transactional public void checkContractualAddressIsRequired() throws Exception { @@ -274,6 +374,13 @@ public class CustomerResourceIntTest { .andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE))) .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX.toString()))) .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))) + .andExpect(jsonPath("$.[*].kind").value(hasItem(DEFAULT_KIND.toString()))) + .andExpect(jsonPath("$.[*].birthDate").value(hasItem(DEFAULT_BIRTH_DATE.toString()))) + .andExpect(jsonPath("$.[*].birthPlace").value(hasItem(DEFAULT_BIRTH_PLACE.toString()))) + .andExpect(jsonPath("$.[*].registrationCourt").value(hasItem(DEFAULT_REGISTRATION_COURT.toString()))) + .andExpect(jsonPath("$.[*].registrationNumber").value(hasItem(DEFAULT_REGISTRATION_NUMBER.toString()))) + .andExpect(jsonPath("$.[*].vatRegion").value(hasItem(DEFAULT_VAT_REGION.toString()))) + .andExpect(jsonPath("$.[*].vatNumber").value(hasItem(DEFAULT_VAT_NUMBER.toString()))) .andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION.toString()))) .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS.toString()))) .andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION.toString()))) @@ -295,6 +402,13 @@ public class CustomerResourceIntTest { .andExpect(jsonPath("$.reference").value(DEFAULT_REFERENCE)) .andExpect(jsonPath("$.prefix").value(DEFAULT_PREFIX.toString())) .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())) + .andExpect(jsonPath("$.kind").value(DEFAULT_KIND.toString())) + .andExpect(jsonPath("$.birthDate").value(DEFAULT_BIRTH_DATE.toString())) + .andExpect(jsonPath("$.birthPlace").value(DEFAULT_BIRTH_PLACE.toString())) + .andExpect(jsonPath("$.registrationCourt").value(DEFAULT_REGISTRATION_COURT.toString())) + .andExpect(jsonPath("$.registrationNumber").value(DEFAULT_REGISTRATION_NUMBER.toString())) + .andExpect(jsonPath("$.vatRegion").value(DEFAULT_VAT_REGION.toString())) + .andExpect(jsonPath("$.vatNumber").value(DEFAULT_VAT_NUMBER.toString())) .andExpect(jsonPath("$.contractualSalutation").value(DEFAULT_CONTRACTUAL_SALUTATION.toString())) .andExpect(jsonPath("$.contractualAddress").value(DEFAULT_CONTRACTUAL_ADDRESS.toString())) .andExpect(jsonPath("$.billingSalutation").value(DEFAULT_BILLING_SALUTATION.toString())) @@ -446,6 +560,306 @@ public class CustomerResourceIntTest { defaultCustomerShouldNotBeFound("name.specified=false"); } + @Test + @Transactional + public void getAllCustomersByKindIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where kind equals to DEFAULT_KIND + defaultCustomerShouldBeFound("kind.equals=" + DEFAULT_KIND); + + // Get all the customerList where kind equals to UPDATED_KIND + defaultCustomerShouldNotBeFound("kind.equals=" + UPDATED_KIND); + } + + @Test + @Transactional + public void getAllCustomersByKindIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where kind in DEFAULT_KIND or UPDATED_KIND + defaultCustomerShouldBeFound("kind.in=" + DEFAULT_KIND + "," + UPDATED_KIND); + + // Get all the customerList where kind equals to UPDATED_KIND + defaultCustomerShouldNotBeFound("kind.in=" + UPDATED_KIND); + } + + @Test + @Transactional + public void getAllCustomersByKindIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where kind is not null + defaultCustomerShouldBeFound("kind.specified=true"); + + // Get all the customerList where kind is null + defaultCustomerShouldNotBeFound("kind.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByBirthDateIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where birthDate equals to DEFAULT_BIRTH_DATE + defaultCustomerShouldBeFound("birthDate.equals=" + DEFAULT_BIRTH_DATE); + + // Get all the customerList where birthDate equals to UPDATED_BIRTH_DATE + defaultCustomerShouldNotBeFound("birthDate.equals=" + UPDATED_BIRTH_DATE); + } + + @Test + @Transactional + public void getAllCustomersByBirthDateIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where birthDate in DEFAULT_BIRTH_DATE or UPDATED_BIRTH_DATE + defaultCustomerShouldBeFound("birthDate.in=" + DEFAULT_BIRTH_DATE + "," + UPDATED_BIRTH_DATE); + + // Get all the customerList where birthDate equals to UPDATED_BIRTH_DATE + defaultCustomerShouldNotBeFound("birthDate.in=" + UPDATED_BIRTH_DATE); + } + + @Test + @Transactional + public void getAllCustomersByBirthDateIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where birthDate is not null + defaultCustomerShouldBeFound("birthDate.specified=true"); + + // Get all the customerList where birthDate is null + defaultCustomerShouldNotBeFound("birthDate.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByBirthDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where birthDate greater than or equals to DEFAULT_BIRTH_DATE + defaultCustomerShouldBeFound("birthDate.greaterOrEqualThan=" + DEFAULT_BIRTH_DATE); + + // Get all the customerList where birthDate greater than or equals to UPDATED_BIRTH_DATE + defaultCustomerShouldNotBeFound("birthDate.greaterOrEqualThan=" + UPDATED_BIRTH_DATE); + } + + @Test + @Transactional + public void getAllCustomersByBirthDateIsLessThanSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where birthDate less than or equals to DEFAULT_BIRTH_DATE + defaultCustomerShouldNotBeFound("birthDate.lessThan=" + DEFAULT_BIRTH_DATE); + + // Get all the customerList where birthDate less than or equals to UPDATED_BIRTH_DATE + defaultCustomerShouldBeFound("birthDate.lessThan=" + UPDATED_BIRTH_DATE); + } + + + @Test + @Transactional + public void getAllCustomersByBirthPlaceIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where birthPlace equals to DEFAULT_BIRTH_PLACE + defaultCustomerShouldBeFound("birthPlace.equals=" + DEFAULT_BIRTH_PLACE); + + // Get all the customerList where birthPlace equals to UPDATED_BIRTH_PLACE + defaultCustomerShouldNotBeFound("birthPlace.equals=" + UPDATED_BIRTH_PLACE); + } + + @Test + @Transactional + public void getAllCustomersByBirthPlaceIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where birthPlace in DEFAULT_BIRTH_PLACE or UPDATED_BIRTH_PLACE + defaultCustomerShouldBeFound("birthPlace.in=" + DEFAULT_BIRTH_PLACE + "," + UPDATED_BIRTH_PLACE); + + // Get all the customerList where birthPlace equals to UPDATED_BIRTH_PLACE + defaultCustomerShouldNotBeFound("birthPlace.in=" + UPDATED_BIRTH_PLACE); + } + + @Test + @Transactional + public void getAllCustomersByBirthPlaceIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where birthPlace is not null + defaultCustomerShouldBeFound("birthPlace.specified=true"); + + // Get all the customerList where birthPlace is null + defaultCustomerShouldNotBeFound("birthPlace.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByRegistrationCourtIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where registrationCourt equals to DEFAULT_REGISTRATION_COURT + defaultCustomerShouldBeFound("registrationCourt.equals=" + DEFAULT_REGISTRATION_COURT); + + // Get all the customerList where registrationCourt equals to UPDATED_REGISTRATION_COURT + defaultCustomerShouldNotBeFound("registrationCourt.equals=" + UPDATED_REGISTRATION_COURT); + } + + @Test + @Transactional + public void getAllCustomersByRegistrationCourtIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where registrationCourt in DEFAULT_REGISTRATION_COURT or UPDATED_REGISTRATION_COURT + defaultCustomerShouldBeFound("registrationCourt.in=" + DEFAULT_REGISTRATION_COURT + "," + UPDATED_REGISTRATION_COURT); + + // Get all the customerList where registrationCourt equals to UPDATED_REGISTRATION_COURT + defaultCustomerShouldNotBeFound("registrationCourt.in=" + UPDATED_REGISTRATION_COURT); + } + + @Test + @Transactional + public void getAllCustomersByRegistrationCourtIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where registrationCourt is not null + defaultCustomerShouldBeFound("registrationCourt.specified=true"); + + // Get all the customerList where registrationCourt is null + defaultCustomerShouldNotBeFound("registrationCourt.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByRegistrationNumberIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where registrationNumber equals to DEFAULT_REGISTRATION_NUMBER + defaultCustomerShouldBeFound("registrationNumber.equals=" + DEFAULT_REGISTRATION_NUMBER); + + // Get all the customerList where registrationNumber equals to UPDATED_REGISTRATION_NUMBER + defaultCustomerShouldNotBeFound("registrationNumber.equals=" + UPDATED_REGISTRATION_NUMBER); + } + + @Test + @Transactional + public void getAllCustomersByRegistrationNumberIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where registrationNumber in DEFAULT_REGISTRATION_NUMBER or UPDATED_REGISTRATION_NUMBER + defaultCustomerShouldBeFound("registrationNumber.in=" + DEFAULT_REGISTRATION_NUMBER + "," + UPDATED_REGISTRATION_NUMBER); + + // Get all the customerList where registrationNumber equals to UPDATED_REGISTRATION_NUMBER + defaultCustomerShouldNotBeFound("registrationNumber.in=" + UPDATED_REGISTRATION_NUMBER); + } + + @Test + @Transactional + public void getAllCustomersByRegistrationNumberIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where registrationNumber is not null + defaultCustomerShouldBeFound("registrationNumber.specified=true"); + + // Get all the customerList where registrationNumber is null + defaultCustomerShouldNotBeFound("registrationNumber.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByVatRegionIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where vatRegion equals to DEFAULT_VAT_REGION + defaultCustomerShouldBeFound("vatRegion.equals=" + DEFAULT_VAT_REGION); + + // Get all the customerList where vatRegion equals to UPDATED_VAT_REGION + defaultCustomerShouldNotBeFound("vatRegion.equals=" + UPDATED_VAT_REGION); + } + + @Test + @Transactional + public void getAllCustomersByVatRegionIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where vatRegion in DEFAULT_VAT_REGION or UPDATED_VAT_REGION + defaultCustomerShouldBeFound("vatRegion.in=" + DEFAULT_VAT_REGION + "," + UPDATED_VAT_REGION); + + // Get all the customerList where vatRegion equals to UPDATED_VAT_REGION + defaultCustomerShouldNotBeFound("vatRegion.in=" + UPDATED_VAT_REGION); + } + + @Test + @Transactional + public void getAllCustomersByVatRegionIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where vatRegion is not null + defaultCustomerShouldBeFound("vatRegion.specified=true"); + + // Get all the customerList where vatRegion is null + defaultCustomerShouldNotBeFound("vatRegion.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByVatNumberIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where vatNumber equals to DEFAULT_VAT_NUMBER + defaultCustomerShouldBeFound("vatNumber.equals=" + DEFAULT_VAT_NUMBER); + + // Get all the customerList where vatNumber equals to UPDATED_VAT_NUMBER + defaultCustomerShouldNotBeFound("vatNumber.equals=" + UPDATED_VAT_NUMBER); + } + + @Test + @Transactional + public void getAllCustomersByVatNumberIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where vatNumber in DEFAULT_VAT_NUMBER or UPDATED_VAT_NUMBER + defaultCustomerShouldBeFound("vatNumber.in=" + DEFAULT_VAT_NUMBER + "," + UPDATED_VAT_NUMBER); + + // Get all the customerList where vatNumber equals to UPDATED_VAT_NUMBER + defaultCustomerShouldNotBeFound("vatNumber.in=" + UPDATED_VAT_NUMBER); + } + + @Test + @Transactional + public void getAllCustomersByVatNumberIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where vatNumber is not null + defaultCustomerShouldBeFound("vatNumber.specified=true"); + + // Get all the customerList where vatNumber is null + defaultCustomerShouldNotBeFound("vatNumber.specified=false"); + } + @Test @Transactional public void getAllCustomersByContractualSalutationIsEqualToSomething() throws Exception { @@ -645,7 +1059,7 @@ public class CustomerResourceIntTest { @Transactional public void getAllCustomersByMembershipIsEqualToSomething() throws Exception { // Initialize the database - Membership membership = MembershipResourceIntTest.createEntity(em); + Membership membership = MembershipResourceIntTest.createPersistentEntity(em, createPersistentEntity(em)); em.persist(membership); em.flush(); customer.addMembership(membership); @@ -664,7 +1078,7 @@ public class CustomerResourceIntTest { @Transactional public void getAllCustomersBySepamandateIsEqualToSomething() throws Exception { // Initialize the database - SepaMandate sepamandate = SepaMandateResourceIntTest.createEntity(em); + SepaMandate sepamandate = SepaMandateResourceIntTest.createEntity(em, createPersistentEntity(em)); em.persist(sepamandate); em.flush(); customer.addSepamandate(sepamandate); @@ -689,6 +1103,13 @@ public class CustomerResourceIntTest { .andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE))) .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX))) .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))) + .andExpect(jsonPath("$.[*].kind").value(hasItem(DEFAULT_KIND.toString()))) + .andExpect(jsonPath("$.[*].birthDate").value(hasItem(DEFAULT_BIRTH_DATE.toString()))) + .andExpect(jsonPath("$.[*].birthPlace").value(hasItem(DEFAULT_BIRTH_PLACE))) + .andExpect(jsonPath("$.[*].registrationCourt").value(hasItem(DEFAULT_REGISTRATION_COURT))) + .andExpect(jsonPath("$.[*].registrationNumber").value(hasItem(DEFAULT_REGISTRATION_NUMBER))) + .andExpect(jsonPath("$.[*].vatRegion").value(hasItem(DEFAULT_VAT_REGION.toString()))) + .andExpect(jsonPath("$.[*].vatNumber").value(hasItem(DEFAULT_VAT_NUMBER))) .andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION))) .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS))) .andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION))) @@ -744,6 +1165,13 @@ public class CustomerResourceIntTest { .reference(UPDATED_REFERENCE) .prefix(UPDATED_PREFIX) .name(UPDATED_NAME) + .kind(UPDATED_KIND) + .birthDate(UPDATED_BIRTH_DATE) + .birthPlace(UPDATED_BIRTH_PLACE) + .registrationCourt(UPDATED_REGISTRATION_COURT) + .registrationNumber(UPDATED_REGISTRATION_NUMBER) + .vatRegion(UPDATED_VAT_REGION) + .vatNumber(UPDATED_VAT_NUMBER) .contractualSalutation(UPDATED_CONTRACTUAL_SALUTATION) .contractualAddress(UPDATED_CONTRACTUAL_ADDRESS) .billingSalutation(UPDATED_BILLING_SALUTATION) @@ -763,6 +1191,13 @@ public class CustomerResourceIntTest { assertThat(testCustomer.getReference()).isEqualTo(UPDATED_REFERENCE); assertThat(testCustomer.getPrefix()).isEqualTo(UPDATED_PREFIX); assertThat(testCustomer.getName()).isEqualTo(UPDATED_NAME); + assertThat(testCustomer.getKind()).isEqualTo(UPDATED_KIND); + assertThat(testCustomer.getBirthDate()).isEqualTo(UPDATED_BIRTH_DATE); + assertThat(testCustomer.getBirthPlace()).isEqualTo(UPDATED_BIRTH_PLACE); + assertThat(testCustomer.getRegistrationCourt()).isEqualTo(UPDATED_REGISTRATION_COURT); + assertThat(testCustomer.getRegistrationNumber()).isEqualTo(UPDATED_REGISTRATION_NUMBER); + assertThat(testCustomer.getVatRegion()).isEqualTo(UPDATED_VAT_REGION); + assertThat(testCustomer.getVatNumber()).isEqualTo(UPDATED_VAT_NUMBER); assertThat(testCustomer.getContractualSalutation()).isEqualTo(UPDATED_CONTRACTUAL_SALUTATION); assertThat(testCustomer.getContractualAddress()).isEqualTo(UPDATED_CONTRACTUAL_ADDRESS); assertThat(testCustomer.getBillingSalutation()).isEqualTo(UPDATED_BILLING_SALUTATION); diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java index a267711d..b85b8ffc 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java @@ -1,19 +1,16 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; - -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.domain.Membership; +import org.hostsharing.hsadminng.domain.Share; import org.hostsharing.hsadminng.repository.MembershipRepository; +import org.hostsharing.hsadminng.service.MembershipQueryService; 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; import org.junit.runner.RunWith; @@ -34,10 +31,9 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; - -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.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -50,14 +46,20 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(classes = HsadminNgApp.class) public class MembershipResourceIntTest { - 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_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 = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_MEMBER_FROM = LocalDate.now(ZoneId.systemDefault()); + 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 = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_MEMBER_UNTIL = LocalDate.now(ZoneId.systemDefault()); + 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_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 String DEFAULT_REMARK = "AAAAAAAAAA"; private static final String UPDATED_REMARK = "BBBBBBBBBB"; @@ -113,9 +115,10 @@ public class MembershipResourceIntTest { */ public static Membership createEntity(EntityManager em) { Membership membership = new Membership() - .documentDate(DEFAULT_DOCUMENT_DATE) - .memberFrom(DEFAULT_MEMBER_FROM) - .memberUntil(DEFAULT_MEMBER_UNTIL) + .admissionDocumentDate(DEFAULT_ADMISSION_DOCUMENT_DATE) + .cancellationDocumentDate(DEFAULT_CANCELLATION_DOCUMENT_DATE) + .memberFromDate(DEFAULT_MEMBER_FROM_DATE) + .memberUntilDate(DEFAULT_MEMBER_UNTIL_DATE) .remark(DEFAULT_REMARK); // Add required entity Customer customer = CustomerResourceIntTest.createEntity(em); @@ -125,6 +128,25 @@ public class MembershipResourceIntTest { return membership; } + /** + * Create an entity for tests for 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 Membership createPersistentEntity(EntityManager em, final Customer customer) { + Membership membership = new Membership() + .admissionDocumentDate(DEFAULT_ADMISSION_DOCUMENT_DATE) + .memberFromDate(DEFAULT_MEMBER_FROM_DATE) + .memberUntilDate(DEFAULT_MEMBER_UNTIL_DATE) + .remark(DEFAULT_REMARK); + // Add required entity + membership.setCustomer(customer); + em.persist(membership); + em.flush(); + return membership; + } + @Before public void initTest() { membership = createEntity(em); @@ -146,9 +168,10 @@ public class MembershipResourceIntTest { List membershipList = membershipRepository.findAll(); assertThat(membershipList).hasSize(databaseSizeBeforeCreate + 1); Membership testMembership = membershipList.get(membershipList.size() - 1); - assertThat(testMembership.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE); - assertThat(testMembership.getMemberFrom()).isEqualTo(DEFAULT_MEMBER_FROM); - assertThat(testMembership.getMemberUntil()).isEqualTo(DEFAULT_MEMBER_UNTIL); + assertThat(testMembership.getAdmissionDocumentDate()).isEqualTo(DEFAULT_ADMISSION_DOCUMENT_DATE); + assertThat(testMembership.getCancellationDocumentDate()).isEqualTo(DEFAULT_CANCELLATION_DOCUMENT_DATE); + assertThat(testMembership.getMemberFromDate()).isEqualTo(DEFAULT_MEMBER_FROM_DATE); + assertThat(testMembership.getMemberUntilDate()).isEqualTo(DEFAULT_MEMBER_UNTIL_DATE); assertThat(testMembership.getRemark()).isEqualTo(DEFAULT_REMARK); } @@ -174,10 +197,10 @@ public class MembershipResourceIntTest { @Test @Transactional - public void checkDocumentDateIsRequired() throws Exception { + public void checkAdmissionDocumentDateIsRequired() throws Exception { int databaseSizeBeforeTest = membershipRepository.findAll().size(); // set the field null - membership.setDocumentDate(null); + membership.setAdmissionDocumentDate(null); // Create the Membership, which fails. MembershipDTO membershipDTO = membershipMapper.toDto(membership); @@ -193,10 +216,10 @@ public class MembershipResourceIntTest { @Test @Transactional - public void checkMemberFromIsRequired() throws Exception { + public void checkMemberFromDateIsRequired() throws Exception { int databaseSizeBeforeTest = membershipRepository.findAll().size(); // set the field null - membership.setMemberFrom(null); + membership.setMemberFromDate(null); // Create the Membership, which fails. MembershipDTO membershipDTO = membershipMapper.toDto(membership); @@ -221,12 +244,13 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue()))) - .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) - .andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString()))) - .andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].admissionDocumentDate").value(hasItem(DEFAULT_ADMISSION_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].cancellationDocumentDate").value(hasItem(DEFAULT_CANCELLATION_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].memberFromDate").value(hasItem(DEFAULT_MEMBER_FROM_DATE.toString()))) + .andExpect(jsonPath("$.[*].memberUntilDate").value(hasItem(DEFAULT_MEMBER_UNTIL_DATE.toString()))) .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); } - + @Test @Transactional public void getMembership() throws Exception { @@ -238,207 +262,274 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(membership.getId().intValue())) - .andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString())) - .andExpect(jsonPath("$.memberFrom").value(DEFAULT_MEMBER_FROM.toString())) - .andExpect(jsonPath("$.memberUntil").value(DEFAULT_MEMBER_UNTIL.toString())) + .andExpect(jsonPath("$.admissionDocumentDate").value(DEFAULT_ADMISSION_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.cancellationDocumentDate").value(DEFAULT_CANCELLATION_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.memberFromDate").value(DEFAULT_MEMBER_FROM_DATE.toString())) + .andExpect(jsonPath("$.memberUntilDate").value(DEFAULT_MEMBER_UNTIL_DATE.toString())) .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); } @Test @Transactional - public void getAllMembershipsByDocumentDateIsEqualToSomething() throws Exception { + public void getAllMembershipsByAdmissionDocumentDateIsEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where documentDate equals to DEFAULT_DOCUMENT_DATE - defaultMembershipShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); + // Get all the membershipList where admissionDocumentDate equals to DEFAULT_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldBeFound("admissionDocumentDate.equals=" + DEFAULT_ADMISSION_DOCUMENT_DATE); - // Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE - defaultMembershipShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); + // Get all the membershipList where admissionDocumentDate equals to UPDATED_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("admissionDocumentDate.equals=" + UPDATED_ADMISSION_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByDocumentDateIsInShouldWork() throws Exception { + public void getAllMembershipsByAdmissionDocumentDateIsInShouldWork() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE - defaultMembershipShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE); + // Get all the membershipList where admissionDocumentDate in DEFAULT_ADMISSION_DOCUMENT_DATE or UPDATED_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldBeFound("admissionDocumentDate.in=" + DEFAULT_ADMISSION_DOCUMENT_DATE + "," + UPDATED_ADMISSION_DOCUMENT_DATE); - // Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE - defaultMembershipShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); + // Get all the membershipList where admissionDocumentDate equals to UPDATED_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("admissionDocumentDate.in=" + UPDATED_ADMISSION_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByDocumentDateIsNullOrNotNull() throws Exception { + public void getAllMembershipsByAdmissionDocumentDateIsNullOrNotNull() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where documentDate is not null - defaultMembershipShouldBeFound("documentDate.specified=true"); + // Get all the membershipList where admissionDocumentDate is not null + defaultMembershipShouldBeFound("admissionDocumentDate.specified=true"); - // Get all the membershipList where documentDate is null - defaultMembershipShouldNotBeFound("documentDate.specified=false"); + // Get all the membershipList where admissionDocumentDate is null + defaultMembershipShouldNotBeFound("admissionDocumentDate.specified=false"); } @Test @Transactional - public void getAllMembershipsByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllMembershipsByAdmissionDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE - defaultMembershipShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE); + // Get all the membershipList where admissionDocumentDate greater than or equals to DEFAULT_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldBeFound("admissionDocumentDate.greaterOrEqualThan=" + DEFAULT_ADMISSION_DOCUMENT_DATE); - // Get all the membershipList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE - defaultMembershipShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE); + // Get all the membershipList where admissionDocumentDate greater than or equals to UPDATED_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("admissionDocumentDate.greaterOrEqualThan=" + UPDATED_ADMISSION_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByDocumentDateIsLessThanSomething() throws Exception { + public void getAllMembershipsByAdmissionDocumentDateIsLessThanSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE - defaultMembershipShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE); + // Get all the membershipList where admissionDocumentDate less than or equals to DEFAULT_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("admissionDocumentDate.lessThan=" + DEFAULT_ADMISSION_DOCUMENT_DATE); - // Get all the membershipList where documentDate less than or equals to UPDATED_DOCUMENT_DATE - defaultMembershipShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE); + // Get all the membershipList where admissionDocumentDate less than or equals to UPDATED_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldBeFound("admissionDocumentDate.lessThan=" + UPDATED_ADMISSION_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByMemberFromIsEqualToSomething() throws Exception { + public void getAllMembershipsByCancellationDocumentDateIsEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberFrom equals to DEFAULT_MEMBER_FROM - defaultMembershipShouldBeFound("memberFrom.equals=" + DEFAULT_MEMBER_FROM); + // Get all the membershipList where cancellationDocumentDate equals to DEFAULT_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldBeFound("cancellationDocumentDate.equals=" + DEFAULT_CANCELLATION_DOCUMENT_DATE); - // Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM - defaultMembershipShouldNotBeFound("memberFrom.equals=" + UPDATED_MEMBER_FROM); + // Get all the membershipList where cancellationDocumentDate equals to UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("cancellationDocumentDate.equals=" + UPDATED_CANCELLATION_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByMemberFromIsInShouldWork() throws Exception { + public void getAllMembershipsByCancellationDocumentDateIsInShouldWork() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberFrom in DEFAULT_MEMBER_FROM or UPDATED_MEMBER_FROM - defaultMembershipShouldBeFound("memberFrom.in=" + DEFAULT_MEMBER_FROM + "," + UPDATED_MEMBER_FROM); + // Get all the membershipList where cancellationDocumentDate in DEFAULT_CANCELLATION_DOCUMENT_DATE or UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldBeFound("cancellationDocumentDate.in=" + DEFAULT_CANCELLATION_DOCUMENT_DATE + "," + UPDATED_CANCELLATION_DOCUMENT_DATE); - // Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM - defaultMembershipShouldNotBeFound("memberFrom.in=" + UPDATED_MEMBER_FROM); + // Get all the membershipList where cancellationDocumentDate equals to UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("cancellationDocumentDate.in=" + UPDATED_CANCELLATION_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByMemberFromIsNullOrNotNull() throws Exception { + public void getAllMembershipsByCancellationDocumentDateIsNullOrNotNull() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberFrom is not null - defaultMembershipShouldBeFound("memberFrom.specified=true"); + // Get all the membershipList where cancellationDocumentDate is not null + defaultMembershipShouldBeFound("cancellationDocumentDate.specified=true"); - // Get all the membershipList where memberFrom is null - defaultMembershipShouldNotBeFound("memberFrom.specified=false"); + // Get all the membershipList where cancellationDocumentDate is null + defaultMembershipShouldNotBeFound("cancellationDocumentDate.specified=false"); } @Test @Transactional - public void getAllMembershipsByMemberFromIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllMembershipsByCancellationDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberFrom greater than or equals to DEFAULT_MEMBER_FROM - defaultMembershipShouldBeFound("memberFrom.greaterOrEqualThan=" + DEFAULT_MEMBER_FROM); + // Get all the membershipList where cancellationDocumentDate greater than or equals to DEFAULT_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldBeFound("cancellationDocumentDate.greaterOrEqualThan=" + DEFAULT_CANCELLATION_DOCUMENT_DATE); - // Get all the membershipList where memberFrom greater than or equals to UPDATED_MEMBER_FROM - defaultMembershipShouldNotBeFound("memberFrom.greaterOrEqualThan=" + UPDATED_MEMBER_FROM); + // Get all the membershipList where cancellationDocumentDate greater than or equals to UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("cancellationDocumentDate.greaterOrEqualThan=" + UPDATED_CANCELLATION_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByMemberFromIsLessThanSomething() throws Exception { + public void getAllMembershipsByCancellationDocumentDateIsLessThanSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberFrom less than or equals to DEFAULT_MEMBER_FROM - defaultMembershipShouldNotBeFound("memberFrom.lessThan=" + DEFAULT_MEMBER_FROM); + // Get all the membershipList where cancellationDocumentDate less than or equals to DEFAULT_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("cancellationDocumentDate.lessThan=" + DEFAULT_CANCELLATION_DOCUMENT_DATE); - // Get all the membershipList where memberFrom less than or equals to UPDATED_MEMBER_FROM - defaultMembershipShouldBeFound("memberFrom.lessThan=" + UPDATED_MEMBER_FROM); + // Get all the membershipList where cancellationDocumentDate less than or equals to UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldBeFound("cancellationDocumentDate.lessThan=" + UPDATED_CANCELLATION_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByMemberUntilIsEqualToSomething() throws Exception { + public void getAllMembershipsByMemberFromDateIsEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberUntil equals to DEFAULT_MEMBER_UNTIL - defaultMembershipShouldBeFound("memberUntil.equals=" + DEFAULT_MEMBER_UNTIL); + // Get all the membershipList where memberFromDate equals to DEFAULT_MEMBER_FROM_DATE + defaultMembershipShouldBeFound("memberFromDate.equals=" + DEFAULT_MEMBER_FROM_DATE); - // Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL - defaultMembershipShouldNotBeFound("memberUntil.equals=" + UPDATED_MEMBER_UNTIL); + // Get all the membershipList where memberFromDate equals to UPDATED_MEMBER_FROM_DATE + defaultMembershipShouldNotBeFound("memberFromDate.equals=" + UPDATED_MEMBER_FROM_DATE); } @Test @Transactional - public void getAllMembershipsByMemberUntilIsInShouldWork() throws Exception { + public void getAllMembershipsByMemberFromDateIsInShouldWork() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberUntil in DEFAULT_MEMBER_UNTIL or UPDATED_MEMBER_UNTIL - defaultMembershipShouldBeFound("memberUntil.in=" + DEFAULT_MEMBER_UNTIL + "," + UPDATED_MEMBER_UNTIL); + // Get all the membershipList where memberFromDate in DEFAULT_MEMBER_FROM_DATE or UPDATED_MEMBER_FROM_DATE + defaultMembershipShouldBeFound("memberFromDate.in=" + DEFAULT_MEMBER_FROM_DATE + "," + UPDATED_MEMBER_FROM_DATE); - // Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL - defaultMembershipShouldNotBeFound("memberUntil.in=" + UPDATED_MEMBER_UNTIL); + // Get all the membershipList where memberFromDate equals to UPDATED_MEMBER_FROM_DATE + defaultMembershipShouldNotBeFound("memberFromDate.in=" + UPDATED_MEMBER_FROM_DATE); } @Test @Transactional - public void getAllMembershipsByMemberUntilIsNullOrNotNull() throws Exception { + public void getAllMembershipsByMemberFromDateIsNullOrNotNull() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberUntil is not null - defaultMembershipShouldBeFound("memberUntil.specified=true"); + // Get all the membershipList where memberFromDate is not null + defaultMembershipShouldBeFound("memberFromDate.specified=true"); - // Get all the membershipList where memberUntil is null - defaultMembershipShouldNotBeFound("memberUntil.specified=false"); + // Get all the membershipList where memberFromDate is null + defaultMembershipShouldNotBeFound("memberFromDate.specified=false"); } @Test @Transactional - public void getAllMembershipsByMemberUntilIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllMembershipsByMemberFromDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberUntil greater than or equals to DEFAULT_MEMBER_UNTIL - defaultMembershipShouldBeFound("memberUntil.greaterOrEqualThan=" + DEFAULT_MEMBER_UNTIL); + // Get all the membershipList where memberFromDate greater than or equals to DEFAULT_MEMBER_FROM_DATE + defaultMembershipShouldBeFound("memberFromDate.greaterOrEqualThan=" + DEFAULT_MEMBER_FROM_DATE); - // Get all the membershipList where memberUntil greater than or equals to UPDATED_MEMBER_UNTIL - defaultMembershipShouldNotBeFound("memberUntil.greaterOrEqualThan=" + UPDATED_MEMBER_UNTIL); + // Get all the membershipList where memberFromDate greater than or equals to UPDATED_MEMBER_FROM_DATE + defaultMembershipShouldNotBeFound("memberFromDate.greaterOrEqualThan=" + UPDATED_MEMBER_FROM_DATE); } @Test @Transactional - public void getAllMembershipsByMemberUntilIsLessThanSomething() throws Exception { + public void getAllMembershipsByMemberFromDateIsLessThanSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where memberUntil less than or equals to DEFAULT_MEMBER_UNTIL - defaultMembershipShouldNotBeFound("memberUntil.lessThan=" + DEFAULT_MEMBER_UNTIL); + // Get all the membershipList where memberFromDate less than or equals to DEFAULT_MEMBER_FROM_DATE + defaultMembershipShouldNotBeFound("memberFromDate.lessThan=" + DEFAULT_MEMBER_FROM_DATE); - // Get all the membershipList where memberUntil less than or equals to UPDATED_MEMBER_UNTIL - defaultMembershipShouldBeFound("memberUntil.lessThan=" + UPDATED_MEMBER_UNTIL); + // Get all the membershipList where memberFromDate less than or equals to UPDATED_MEMBER_FROM_DATE + defaultMembershipShouldBeFound("memberFromDate.lessThan=" + UPDATED_MEMBER_FROM_DATE); + } + + + @Test + @Transactional + public void getAllMembershipsByMemberUntilDateIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntilDate equals to DEFAULT_MEMBER_UNTIL_DATE + defaultMembershipShouldBeFound("memberUntilDate.equals=" + DEFAULT_MEMBER_UNTIL_DATE); + + // Get all the membershipList where memberUntilDate equals to UPDATED_MEMBER_UNTIL_DATE + defaultMembershipShouldNotBeFound("memberUntilDate.equals=" + UPDATED_MEMBER_UNTIL_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilDateIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntilDate in DEFAULT_MEMBER_UNTIL_DATE or UPDATED_MEMBER_UNTIL_DATE + defaultMembershipShouldBeFound("memberUntilDate.in=" + DEFAULT_MEMBER_UNTIL_DATE + "," + UPDATED_MEMBER_UNTIL_DATE); + + // Get all the membershipList where memberUntilDate equals to UPDATED_MEMBER_UNTIL_DATE + defaultMembershipShouldNotBeFound("memberUntilDate.in=" + UPDATED_MEMBER_UNTIL_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilDateIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntilDate is not null + defaultMembershipShouldBeFound("memberUntilDate.specified=true"); + + // Get all the membershipList where memberUntilDate is null + defaultMembershipShouldNotBeFound("memberUntilDate.specified=false"); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntilDate greater than or equals to DEFAULT_MEMBER_UNTIL_DATE + defaultMembershipShouldBeFound("memberUntilDate.greaterOrEqualThan=" + DEFAULT_MEMBER_UNTIL_DATE); + + // Get all the membershipList where memberUntilDate greater than or equals to UPDATED_MEMBER_UNTIL_DATE + defaultMembershipShouldNotBeFound("memberUntilDate.greaterOrEqualThan=" + UPDATED_MEMBER_UNTIL_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilDateIsLessThanSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntilDate less than or equals to DEFAULT_MEMBER_UNTIL_DATE + defaultMembershipShouldNotBeFound("memberUntilDate.lessThan=" + DEFAULT_MEMBER_UNTIL_DATE); + + // Get all the membershipList where memberUntilDate less than or equals to UPDATED_MEMBER_UNTIL_DATE + defaultMembershipShouldBeFound("memberUntilDate.lessThan=" + UPDATED_MEMBER_UNTIL_DATE); } @@ -485,11 +576,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 @@ -504,11 +593,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 @@ -523,9 +610,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(); @@ -545,9 +630,10 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue()))) - .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) - .andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString()))) - .andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].admissionDocumentDate").value(hasItem(DEFAULT_ADMISSION_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].cancellationDocumentDate").value(hasItem(DEFAULT_CANCELLATION_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].memberFromDate").value(hasItem(DEFAULT_MEMBER_FROM_DATE.toString()))) + .andExpect(jsonPath("$.[*].memberUntilDate").value(hasItem(DEFAULT_MEMBER_UNTIL_DATE.toString()))) .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK))); // Check, that the count call also returns 1 @@ -596,9 +682,10 @@ public class MembershipResourceIntTest { // Disconnect from session so that the updates on updatedMembership are not directly saved in db em.detach(updatedMembership); updatedMembership - .documentDate(UPDATED_DOCUMENT_DATE) - .memberFrom(UPDATED_MEMBER_FROM) - .memberUntil(UPDATED_MEMBER_UNTIL) + .admissionDocumentDate(UPDATED_ADMISSION_DOCUMENT_DATE) + .cancellationDocumentDate(UPDATED_CANCELLATION_DOCUMENT_DATE) + .memberFromDate(UPDATED_MEMBER_FROM_DATE) + .memberUntilDate(UPDATED_MEMBER_UNTIL_DATE) .remark(UPDATED_REMARK); MembershipDTO membershipDTO = membershipMapper.toDto(updatedMembership); @@ -611,9 +698,10 @@ public class MembershipResourceIntTest { List membershipList = membershipRepository.findAll(); assertThat(membershipList).hasSize(databaseSizeBeforeUpdate); Membership testMembership = membershipList.get(membershipList.size() - 1); - assertThat(testMembership.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE); - assertThat(testMembership.getMemberFrom()).isEqualTo(UPDATED_MEMBER_FROM); - assertThat(testMembership.getMemberUntil()).isEqualTo(UPDATED_MEMBER_UNTIL); + assertThat(testMembership.getAdmissionDocumentDate()).isEqualTo(UPDATED_ADMISSION_DOCUMENT_DATE); + assertThat(testMembership.getCancellationDocumentDate()).isEqualTo(UPDATED_CANCELLATION_DOCUMENT_DATE); + assertThat(testMembership.getMemberFromDate()).isEqualTo(UPDATED_MEMBER_FROM_DATE); + assertThat(testMembership.getMemberUntilDate()).isEqualTo(UPDATED_MEMBER_UNTIL_DATE); assertThat(testMembership.getRemark()).isEqualTo(UPDATED_REMARK); } @@ -647,11 +735,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 membershipList = membershipRepository.findAll(); - assertThat(membershipList).hasSize(databaseSizeBeforeDelete - 1); + assertThat(membershipList).hasSize(databaseSizeBeforeDelete); } @Test diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java index 78bf4160..916a8c27 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java @@ -1,17 +1,14 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; - -import org.hostsharing.hsadminng.domain.SepaMandate; import org.hostsharing.hsadminng.domain.Customer; +import org.hostsharing.hsadminng.domain.SepaMandate; import org.hostsharing.hsadminng.repository.SepaMandateRepository; +import org.hostsharing.hsadminng.service.SepaMandateQueryService; 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; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,10 +29,9 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; - -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.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -60,17 +56,23 @@ 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_FROM_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_FROM_DATE = 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_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_CANCELLATION_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_CANCELLATION_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_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()); private static final String DEFAULT_REMARK = "AAAAAAAAAA"; private static final String UPDATED_REMARK = "BBBBBBBBBB"; @@ -129,11 +131,11 @@ public class SepaMandateResourceIntTest { .reference(DEFAULT_REFERENCE) .iban(DEFAULT_IBAN) .bic(DEFAULT_BIC) - .documentDate(DEFAULT_DOCUMENT_DATE) - .validFrom(DEFAULT_VALID_FROM) - .validUntil(DEFAULT_VALID_UNTIL) - .lastUsed(DEFAULT_LAST_USED) - .cancellationDate(DEFAULT_CANCELLATION_DATE) + .grantingDocumentDate(DEFAULT_GRANTING_DOCUMENT_DATE) + .revokationDocumentDate(DEFAULT_REVOKATION_DOCUMENT_DATE) + .validFromDate(DEFAULT_VALID_FROM_DATE) + .validUntilDate(DEFAULT_VALID_UNTIL_DATE) + .lastUsedDate(DEFAULT_LAST_USED_DATE) .remark(DEFAULT_REMARK); // Add required entity Customer customer = CustomerResourceIntTest.createEntity(em); @@ -143,6 +145,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); @@ -167,11 +191,11 @@ public class SepaMandateResourceIntTest { assertThat(testSepaMandate.getReference()).isEqualTo(DEFAULT_REFERENCE); assertThat(testSepaMandate.getIban()).isEqualTo(DEFAULT_IBAN); assertThat(testSepaMandate.getBic()).isEqualTo(DEFAULT_BIC); - assertThat(testSepaMandate.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE); - assertThat(testSepaMandate.getValidFrom()).isEqualTo(DEFAULT_VALID_FROM); - assertThat(testSepaMandate.getValidUntil()).isEqualTo(DEFAULT_VALID_UNTIL); - assertThat(testSepaMandate.getLastUsed()).isEqualTo(DEFAULT_LAST_USED); - assertThat(testSepaMandate.getCancellationDate()).isEqualTo(DEFAULT_CANCELLATION_DATE); + assertThat(testSepaMandate.getGrantingDocumentDate()).isEqualTo(DEFAULT_GRANTING_DOCUMENT_DATE); + assertThat(testSepaMandate.getRevokationDocumentDate()).isEqualTo(DEFAULT_REVOKATION_DOCUMENT_DATE); + assertThat(testSepaMandate.getValidFromDate()).isEqualTo(DEFAULT_VALID_FROM_DATE); + assertThat(testSepaMandate.getValidUntilDate()).isEqualTo(DEFAULT_VALID_UNTIL_DATE); + assertThat(testSepaMandate.getLastUsedDate()).isEqualTo(DEFAULT_LAST_USED_DATE); assertThat(testSepaMandate.getRemark()).isEqualTo(DEFAULT_REMARK); } @@ -216,10 +240,10 @@ public class SepaMandateResourceIntTest { @Test @Transactional - public void checkDocumentDateIsRequired() throws Exception { + public void checkGrantingDocumentDateIsRequired() throws Exception { int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); // set the field null - sepaMandate.setDocumentDate(null); + sepaMandate.setGrantingDocumentDate(null); // Create the SepaMandate, which fails. SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate); @@ -235,10 +259,10 @@ public class SepaMandateResourceIntTest { @Test @Transactional - public void checkValidFromIsRequired() throws Exception { + public void checkValidFromDateIsRequired() throws Exception { int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); // set the field null - sepaMandate.setValidFrom(null); + sepaMandate.setValidFromDate(null); // Create the SepaMandate, which fails. SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate); @@ -266,11 +290,11 @@ public class SepaMandateResourceIntTest { .andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE.toString()))) .andExpect(jsonPath("$.[*].iban").value(hasItem(DEFAULT_IBAN.toString()))) .andExpect(jsonPath("$.[*].bic").value(hasItem(DEFAULT_BIC.toString()))) - .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) - .andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString()))) - .andExpect(jsonPath("$.[*].validUntil").value(hasItem(DEFAULT_VALID_UNTIL.toString()))) - .andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString()))) - .andExpect(jsonPath("$.[*].cancellationDate").value(hasItem(DEFAULT_CANCELLATION_DATE.toString()))) + .andExpect(jsonPath("$.[*].grantingDocumentDate").value(hasItem(DEFAULT_GRANTING_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].revokationDocumentDate").value(hasItem(DEFAULT_REVOKATION_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].validFromDate").value(hasItem(DEFAULT_VALID_FROM_DATE.toString()))) + .andExpect(jsonPath("$.[*].validUntilDate").value(hasItem(DEFAULT_VALID_UNTIL_DATE.toString()))) + .andExpect(jsonPath("$.[*].lastUsedDate").value(hasItem(DEFAULT_LAST_USED_DATE.toString()))) .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); } @@ -288,11 +312,11 @@ public class SepaMandateResourceIntTest { .andExpect(jsonPath("$.reference").value(DEFAULT_REFERENCE.toString())) .andExpect(jsonPath("$.iban").value(DEFAULT_IBAN.toString())) .andExpect(jsonPath("$.bic").value(DEFAULT_BIC.toString())) - .andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString())) - .andExpect(jsonPath("$.validFrom").value(DEFAULT_VALID_FROM.toString())) - .andExpect(jsonPath("$.validUntil").value(DEFAULT_VALID_UNTIL.toString())) - .andExpect(jsonPath("$.lastUsed").value(DEFAULT_LAST_USED.toString())) - .andExpect(jsonPath("$.cancellationDate").value(DEFAULT_CANCELLATION_DATE.toString())) + .andExpect(jsonPath("$.grantingDocumentDate").value(DEFAULT_GRANTING_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.revokationDocumentDate").value(DEFAULT_REVOKATION_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.validFromDate").value(DEFAULT_VALID_FROM_DATE.toString())) + .andExpect(jsonPath("$.validUntilDate").value(DEFAULT_VALID_UNTIL_DATE.toString())) + .andExpect(jsonPath("$.lastUsedDate").value(DEFAULT_LAST_USED_DATE.toString())) .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); } @@ -415,331 +439,331 @@ public class SepaMandateResourceIntTest { @Test @Transactional - public void getAllSepaMandatesByDocumentDateIsEqualToSomething() throws Exception { + public void getAllSepaMandatesByGrantingDocumentDateIsEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where documentDate equals to DEFAULT_DOCUMENT_DATE - defaultSepaMandateShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); + // Get all the sepaMandateList where grantingDocumentDate equals to DEFAULT_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("grantingDocumentDate.equals=" + DEFAULT_GRANTING_DOCUMENT_DATE); - // Get all the sepaMandateList where documentDate equals to UPDATED_DOCUMENT_DATE - defaultSepaMandateShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); + // Get all the sepaMandateList where grantingDocumentDate equals to UPDATED_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("grantingDocumentDate.equals=" + UPDATED_GRANTING_DOCUMENT_DATE); } @Test @Transactional - public void getAllSepaMandatesByDocumentDateIsInShouldWork() throws Exception { + public void getAllSepaMandatesByGrantingDocumentDateIsInShouldWork() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE - defaultSepaMandateShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE); + // Get all the sepaMandateList where grantingDocumentDate in DEFAULT_GRANTING_DOCUMENT_DATE or UPDATED_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("grantingDocumentDate.in=" + DEFAULT_GRANTING_DOCUMENT_DATE + "," + UPDATED_GRANTING_DOCUMENT_DATE); - // Get all the sepaMandateList where documentDate equals to UPDATED_DOCUMENT_DATE - defaultSepaMandateShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); + // Get all the sepaMandateList where grantingDocumentDate equals to UPDATED_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("grantingDocumentDate.in=" + UPDATED_GRANTING_DOCUMENT_DATE); } @Test @Transactional - public void getAllSepaMandatesByDocumentDateIsNullOrNotNull() throws Exception { + public void getAllSepaMandatesByGrantingDocumentDateIsNullOrNotNull() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where documentDate is not null - defaultSepaMandateShouldBeFound("documentDate.specified=true"); + // Get all the sepaMandateList where grantingDocumentDate is not null + defaultSepaMandateShouldBeFound("grantingDocumentDate.specified=true"); - // Get all the sepaMandateList where documentDate is null - defaultSepaMandateShouldNotBeFound("documentDate.specified=false"); + // Get all the sepaMandateList where grantingDocumentDate is null + defaultSepaMandateShouldNotBeFound("grantingDocumentDate.specified=false"); } @Test @Transactional - public void getAllSepaMandatesByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllSepaMandatesByGrantingDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE - defaultSepaMandateShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE); + // Get all the sepaMandateList where grantingDocumentDate greater than or equals to DEFAULT_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("grantingDocumentDate.greaterOrEqualThan=" + DEFAULT_GRANTING_DOCUMENT_DATE); - // Get all the sepaMandateList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE - defaultSepaMandateShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE); + // Get all the sepaMandateList where grantingDocumentDate greater than or equals to UPDATED_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("grantingDocumentDate.greaterOrEqualThan=" + UPDATED_GRANTING_DOCUMENT_DATE); } @Test @Transactional - public void getAllSepaMandatesByDocumentDateIsLessThanSomething() throws Exception { + public void getAllSepaMandatesByGrantingDocumentDateIsLessThanSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE - defaultSepaMandateShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE); + // Get all the sepaMandateList where grantingDocumentDate less than or equals to DEFAULT_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("grantingDocumentDate.lessThan=" + DEFAULT_GRANTING_DOCUMENT_DATE); - // Get all the sepaMandateList where documentDate less than or equals to UPDATED_DOCUMENT_DATE - defaultSepaMandateShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE); + // Get all the sepaMandateList where grantingDocumentDate less than or equals to UPDATED_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("grantingDocumentDate.lessThan=" + UPDATED_GRANTING_DOCUMENT_DATE); } @Test @Transactional - public void getAllSepaMandatesByValidFromIsEqualToSomething() throws Exception { + public void getAllSepaMandatesByRevokationDocumentDateIsEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validFrom equals to DEFAULT_VALID_FROM - defaultSepaMandateShouldBeFound("validFrom.equals=" + DEFAULT_VALID_FROM); + // Get all the sepaMandateList where revokationDocumentDate equals to DEFAULT_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("revokationDocumentDate.equals=" + DEFAULT_REVOKATION_DOCUMENT_DATE); - // Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM - defaultSepaMandateShouldNotBeFound("validFrom.equals=" + UPDATED_VALID_FROM); + // Get all the sepaMandateList where revokationDocumentDate equals to UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.equals=" + UPDATED_REVOKATION_DOCUMENT_DATE); } @Test @Transactional - public void getAllSepaMandatesByValidFromIsInShouldWork() throws Exception { + public void getAllSepaMandatesByRevokationDocumentDateIsInShouldWork() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validFrom in DEFAULT_VALID_FROM or UPDATED_VALID_FROM - defaultSepaMandateShouldBeFound("validFrom.in=" + DEFAULT_VALID_FROM + "," + UPDATED_VALID_FROM); + // Get all the sepaMandateList where revokationDocumentDate in DEFAULT_REVOKATION_DOCUMENT_DATE or UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("revokationDocumentDate.in=" + DEFAULT_REVOKATION_DOCUMENT_DATE + "," + UPDATED_REVOKATION_DOCUMENT_DATE); - // Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM - defaultSepaMandateShouldNotBeFound("validFrom.in=" + UPDATED_VALID_FROM); + // Get all the sepaMandateList where revokationDocumentDate equals to UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.in=" + UPDATED_REVOKATION_DOCUMENT_DATE); } @Test @Transactional - public void getAllSepaMandatesByValidFromIsNullOrNotNull() throws Exception { + public void getAllSepaMandatesByRevokationDocumentDateIsNullOrNotNull() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validFrom is not null - defaultSepaMandateShouldBeFound("validFrom.specified=true"); + // Get all the sepaMandateList where revokationDocumentDate is not null + defaultSepaMandateShouldBeFound("revokationDocumentDate.specified=true"); - // Get all the sepaMandateList where validFrom is null - defaultSepaMandateShouldNotBeFound("validFrom.specified=false"); + // Get all the sepaMandateList where revokationDocumentDate is null + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.specified=false"); } @Test @Transactional - public void getAllSepaMandatesByValidFromIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllSepaMandatesByRevokationDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validFrom greater than or equals to DEFAULT_VALID_FROM - defaultSepaMandateShouldBeFound("validFrom.greaterOrEqualThan=" + DEFAULT_VALID_FROM); + // Get all the sepaMandateList where revokationDocumentDate greater than or equals to DEFAULT_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("revokationDocumentDate.greaterOrEqualThan=" + DEFAULT_REVOKATION_DOCUMENT_DATE); - // Get all the sepaMandateList where validFrom greater than or equals to UPDATED_VALID_FROM - defaultSepaMandateShouldNotBeFound("validFrom.greaterOrEqualThan=" + UPDATED_VALID_FROM); + // Get all the sepaMandateList where revokationDocumentDate greater than or equals to UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.greaterOrEqualThan=" + UPDATED_REVOKATION_DOCUMENT_DATE); } @Test @Transactional - public void getAllSepaMandatesByValidFromIsLessThanSomething() throws Exception { + public void getAllSepaMandatesByRevokationDocumentDateIsLessThanSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validFrom less than or equals to DEFAULT_VALID_FROM - defaultSepaMandateShouldNotBeFound("validFrom.lessThan=" + DEFAULT_VALID_FROM); + // Get all the sepaMandateList where revokationDocumentDate less than or equals to DEFAULT_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.lessThan=" + DEFAULT_REVOKATION_DOCUMENT_DATE); - // Get all the sepaMandateList where validFrom less than or equals to UPDATED_VALID_FROM - defaultSepaMandateShouldBeFound("validFrom.lessThan=" + UPDATED_VALID_FROM); + // Get all the sepaMandateList where revokationDocumentDate less than or equals to UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("revokationDocumentDate.lessThan=" + UPDATED_REVOKATION_DOCUMENT_DATE); } @Test @Transactional - public void getAllSepaMandatesByValidUntilIsEqualToSomething() throws Exception { + public void getAllSepaMandatesByValidFromDateIsEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validUntil equals to DEFAULT_VALID_UNTIL - defaultSepaMandateShouldBeFound("validUntil.equals=" + DEFAULT_VALID_UNTIL); + // Get all the sepaMandateList where validFromDate equals to DEFAULT_VALID_FROM_DATE + defaultSepaMandateShouldBeFound("validFromDate.equals=" + DEFAULT_VALID_FROM_DATE); - // Get all the sepaMandateList where validUntil equals to UPDATED_VALID_UNTIL - defaultSepaMandateShouldNotBeFound("validUntil.equals=" + UPDATED_VALID_UNTIL); + // Get all the sepaMandateList where validFromDate equals to UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldNotBeFound("validFromDate.equals=" + UPDATED_VALID_FROM_DATE); } @Test @Transactional - public void getAllSepaMandatesByValidUntilIsInShouldWork() throws Exception { + public void getAllSepaMandatesByValidFromDateIsInShouldWork() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validUntil in DEFAULT_VALID_UNTIL or UPDATED_VALID_UNTIL - defaultSepaMandateShouldBeFound("validUntil.in=" + DEFAULT_VALID_UNTIL + "," + UPDATED_VALID_UNTIL); + // Get all the sepaMandateList where validFromDate in DEFAULT_VALID_FROM_DATE or UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldBeFound("validFromDate.in=" + DEFAULT_VALID_FROM_DATE + "," + UPDATED_VALID_FROM_DATE); - // Get all the sepaMandateList where validUntil equals to UPDATED_VALID_UNTIL - defaultSepaMandateShouldNotBeFound("validUntil.in=" + UPDATED_VALID_UNTIL); + // Get all the sepaMandateList where validFromDate equals to UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldNotBeFound("validFromDate.in=" + UPDATED_VALID_FROM_DATE); } @Test @Transactional - public void getAllSepaMandatesByValidUntilIsNullOrNotNull() throws Exception { + public void getAllSepaMandatesByValidFromDateIsNullOrNotNull() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validUntil is not null - defaultSepaMandateShouldBeFound("validUntil.specified=true"); + // Get all the sepaMandateList where validFromDate is not null + defaultSepaMandateShouldBeFound("validFromDate.specified=true"); - // Get all the sepaMandateList where validUntil is null - defaultSepaMandateShouldNotBeFound("validUntil.specified=false"); + // Get all the sepaMandateList where validFromDate is null + defaultSepaMandateShouldNotBeFound("validFromDate.specified=false"); } @Test @Transactional - public void getAllSepaMandatesByValidUntilIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllSepaMandatesByValidFromDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validUntil greater than or equals to DEFAULT_VALID_UNTIL - defaultSepaMandateShouldBeFound("validUntil.greaterOrEqualThan=" + DEFAULT_VALID_UNTIL); + // Get all the sepaMandateList where validFromDate greater than or equals to DEFAULT_VALID_FROM_DATE + defaultSepaMandateShouldBeFound("validFromDate.greaterOrEqualThan=" + DEFAULT_VALID_FROM_DATE); - // Get all the sepaMandateList where validUntil greater than or equals to UPDATED_VALID_UNTIL - defaultSepaMandateShouldNotBeFound("validUntil.greaterOrEqualThan=" + UPDATED_VALID_UNTIL); + // Get all the sepaMandateList where validFromDate greater than or equals to UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldNotBeFound("validFromDate.greaterOrEqualThan=" + UPDATED_VALID_FROM_DATE); } @Test @Transactional - public void getAllSepaMandatesByValidUntilIsLessThanSomething() throws Exception { + public void getAllSepaMandatesByValidFromDateIsLessThanSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where validUntil less than or equals to DEFAULT_VALID_UNTIL - defaultSepaMandateShouldNotBeFound("validUntil.lessThan=" + DEFAULT_VALID_UNTIL); + // Get all the sepaMandateList where validFromDate less than or equals to DEFAULT_VALID_FROM_DATE + defaultSepaMandateShouldNotBeFound("validFromDate.lessThan=" + DEFAULT_VALID_FROM_DATE); - // Get all the sepaMandateList where validUntil less than or equals to UPDATED_VALID_UNTIL - defaultSepaMandateShouldBeFound("validUntil.lessThan=" + UPDATED_VALID_UNTIL); + // Get all the sepaMandateList where validFromDate less than or equals to UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldBeFound("validFromDate.lessThan=" + UPDATED_VALID_FROM_DATE); } @Test @Transactional - public void getAllSepaMandatesByLastUsedIsEqualToSomething() throws Exception { + public void getAllSepaMandatesByValidUntilDateIsEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where lastUsed equals to DEFAULT_LAST_USED - defaultSepaMandateShouldBeFound("lastUsed.equals=" + DEFAULT_LAST_USED); + // Get all the sepaMandateList where validUntilDate equals to DEFAULT_VALID_UNTIL_DATE + defaultSepaMandateShouldBeFound("validUntilDate.equals=" + DEFAULT_VALID_UNTIL_DATE); - // Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED - defaultSepaMandateShouldNotBeFound("lastUsed.equals=" + UPDATED_LAST_USED); + // Get all the sepaMandateList where validUntilDate equals to UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldNotBeFound("validUntilDate.equals=" + UPDATED_VALID_UNTIL_DATE); } @Test @Transactional - public void getAllSepaMandatesByLastUsedIsInShouldWork() throws Exception { + public void getAllSepaMandatesByValidUntilDateIsInShouldWork() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where lastUsed in DEFAULT_LAST_USED or UPDATED_LAST_USED - defaultSepaMandateShouldBeFound("lastUsed.in=" + DEFAULT_LAST_USED + "," + UPDATED_LAST_USED); + // Get all the sepaMandateList where validUntilDate in DEFAULT_VALID_UNTIL_DATE or UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldBeFound("validUntilDate.in=" + DEFAULT_VALID_UNTIL_DATE + "," + UPDATED_VALID_UNTIL_DATE); - // Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED - defaultSepaMandateShouldNotBeFound("lastUsed.in=" + UPDATED_LAST_USED); + // Get all the sepaMandateList where validUntilDate equals to UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldNotBeFound("validUntilDate.in=" + UPDATED_VALID_UNTIL_DATE); } @Test @Transactional - public void getAllSepaMandatesByLastUsedIsNullOrNotNull() throws Exception { + public void getAllSepaMandatesByValidUntilDateIsNullOrNotNull() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where lastUsed is not null - defaultSepaMandateShouldBeFound("lastUsed.specified=true"); + // Get all the sepaMandateList where validUntilDate is not null + defaultSepaMandateShouldBeFound("validUntilDate.specified=true"); - // Get all the sepaMandateList where lastUsed is null - defaultSepaMandateShouldNotBeFound("lastUsed.specified=false"); + // Get all the sepaMandateList where validUntilDate is null + defaultSepaMandateShouldNotBeFound("validUntilDate.specified=false"); } @Test @Transactional - public void getAllSepaMandatesByLastUsedIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllSepaMandatesByValidUntilDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where lastUsed greater than or equals to DEFAULT_LAST_USED - defaultSepaMandateShouldBeFound("lastUsed.greaterOrEqualThan=" + DEFAULT_LAST_USED); + // Get all the sepaMandateList where validUntilDate greater than or equals to DEFAULT_VALID_UNTIL_DATE + defaultSepaMandateShouldBeFound("validUntilDate.greaterOrEqualThan=" + DEFAULT_VALID_UNTIL_DATE); - // Get all the sepaMandateList where lastUsed greater than or equals to UPDATED_LAST_USED - defaultSepaMandateShouldNotBeFound("lastUsed.greaterOrEqualThan=" + UPDATED_LAST_USED); + // Get all the sepaMandateList where validUntilDate greater than or equals to UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldNotBeFound("validUntilDate.greaterOrEqualThan=" + UPDATED_VALID_UNTIL_DATE); } @Test @Transactional - public void getAllSepaMandatesByLastUsedIsLessThanSomething() throws Exception { + public void getAllSepaMandatesByValidUntilDateIsLessThanSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where lastUsed less than or equals to DEFAULT_LAST_USED - defaultSepaMandateShouldNotBeFound("lastUsed.lessThan=" + DEFAULT_LAST_USED); + // Get all the sepaMandateList where validUntilDate less than or equals to DEFAULT_VALID_UNTIL_DATE + defaultSepaMandateShouldNotBeFound("validUntilDate.lessThan=" + DEFAULT_VALID_UNTIL_DATE); - // Get all the sepaMandateList where lastUsed less than or equals to UPDATED_LAST_USED - defaultSepaMandateShouldBeFound("lastUsed.lessThan=" + UPDATED_LAST_USED); + // Get all the sepaMandateList where validUntilDate less than or equals to UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldBeFound("validUntilDate.lessThan=" + UPDATED_VALID_UNTIL_DATE); } @Test @Transactional - public void getAllSepaMandatesByCancellationDateIsEqualToSomething() throws Exception { + public void getAllSepaMandatesByLastUsedDateIsEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where cancellationDate equals to DEFAULT_CANCELLATION_DATE - defaultSepaMandateShouldBeFound("cancellationDate.equals=" + DEFAULT_CANCELLATION_DATE); + // Get all the sepaMandateList where lastUsedDate equals to DEFAULT_LAST_USED_DATE + defaultSepaMandateShouldBeFound("lastUsedDate.equals=" + DEFAULT_LAST_USED_DATE); - // Get all the sepaMandateList where cancellationDate equals to UPDATED_CANCELLATION_DATE - defaultSepaMandateShouldNotBeFound("cancellationDate.equals=" + UPDATED_CANCELLATION_DATE); + // Get all the sepaMandateList where lastUsedDate equals to UPDATED_LAST_USED_DATE + defaultSepaMandateShouldNotBeFound("lastUsedDate.equals=" + UPDATED_LAST_USED_DATE); } @Test @Transactional - public void getAllSepaMandatesByCancellationDateIsInShouldWork() throws Exception { + public void getAllSepaMandatesByLastUsedDateIsInShouldWork() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where cancellationDate in DEFAULT_CANCELLATION_DATE or UPDATED_CANCELLATION_DATE - defaultSepaMandateShouldBeFound("cancellationDate.in=" + DEFAULT_CANCELLATION_DATE + "," + UPDATED_CANCELLATION_DATE); + // Get all the sepaMandateList where lastUsedDate in DEFAULT_LAST_USED_DATE or UPDATED_LAST_USED_DATE + defaultSepaMandateShouldBeFound("lastUsedDate.in=" + DEFAULT_LAST_USED_DATE + "," + UPDATED_LAST_USED_DATE); - // Get all the sepaMandateList where cancellationDate equals to UPDATED_CANCELLATION_DATE - defaultSepaMandateShouldNotBeFound("cancellationDate.in=" + UPDATED_CANCELLATION_DATE); + // Get all the sepaMandateList where lastUsedDate equals to UPDATED_LAST_USED_DATE + defaultSepaMandateShouldNotBeFound("lastUsedDate.in=" + UPDATED_LAST_USED_DATE); } @Test @Transactional - public void getAllSepaMandatesByCancellationDateIsNullOrNotNull() throws Exception { + public void getAllSepaMandatesByLastUsedDateIsNullOrNotNull() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where cancellationDate is not null - defaultSepaMandateShouldBeFound("cancellationDate.specified=true"); + // Get all the sepaMandateList where lastUsedDate is not null + defaultSepaMandateShouldBeFound("lastUsedDate.specified=true"); - // Get all the sepaMandateList where cancellationDate is null - defaultSepaMandateShouldNotBeFound("cancellationDate.specified=false"); + // Get all the sepaMandateList where lastUsedDate is null + defaultSepaMandateShouldNotBeFound("lastUsedDate.specified=false"); } @Test @Transactional - public void getAllSepaMandatesByCancellationDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllSepaMandatesByLastUsedDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where cancellationDate greater than or equals to DEFAULT_CANCELLATION_DATE - defaultSepaMandateShouldBeFound("cancellationDate.greaterOrEqualThan=" + DEFAULT_CANCELLATION_DATE); + // Get all the sepaMandateList where lastUsedDate greater than or equals to DEFAULT_LAST_USED_DATE + defaultSepaMandateShouldBeFound("lastUsedDate.greaterOrEqualThan=" + DEFAULT_LAST_USED_DATE); - // Get all the sepaMandateList where cancellationDate greater than or equals to UPDATED_CANCELLATION_DATE - defaultSepaMandateShouldNotBeFound("cancellationDate.greaterOrEqualThan=" + UPDATED_CANCELLATION_DATE); + // Get all the sepaMandateList where lastUsedDate greater than or equals to UPDATED_LAST_USED_DATE + defaultSepaMandateShouldNotBeFound("lastUsedDate.greaterOrEqualThan=" + UPDATED_LAST_USED_DATE); } @Test @Transactional - public void getAllSepaMandatesByCancellationDateIsLessThanSomething() throws Exception { + public void getAllSepaMandatesByLastUsedDateIsLessThanSomething() throws Exception { // Initialize the database sepaMandateRepository.saveAndFlush(sepaMandate); - // Get all the sepaMandateList where cancellationDate less than or equals to DEFAULT_CANCELLATION_DATE - defaultSepaMandateShouldNotBeFound("cancellationDate.lessThan=" + DEFAULT_CANCELLATION_DATE); + // Get all the sepaMandateList where lastUsedDate less than or equals to DEFAULT_LAST_USED_DATE + defaultSepaMandateShouldNotBeFound("lastUsedDate.lessThan=" + DEFAULT_LAST_USED_DATE); - // Get all the sepaMandateList where cancellationDate less than or equals to UPDATED_CANCELLATION_DATE - defaultSepaMandateShouldBeFound("cancellationDate.lessThan=" + UPDATED_CANCELLATION_DATE); + // Get all the sepaMandateList where lastUsedDate less than or equals to UPDATED_LAST_USED_DATE + defaultSepaMandateShouldBeFound("lastUsedDate.lessThan=" + UPDATED_LAST_USED_DATE); } @@ -786,9 +810,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(); @@ -811,11 +833,11 @@ public class SepaMandateResourceIntTest { .andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE))) .andExpect(jsonPath("$.[*].iban").value(hasItem(DEFAULT_IBAN))) .andExpect(jsonPath("$.[*].bic").value(hasItem(DEFAULT_BIC))) - .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) - .andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString()))) - .andExpect(jsonPath("$.[*].validUntil").value(hasItem(DEFAULT_VALID_UNTIL.toString()))) - .andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString()))) - .andExpect(jsonPath("$.[*].cancellationDate").value(hasItem(DEFAULT_CANCELLATION_DATE.toString()))) + .andExpect(jsonPath("$.[*].grantingDocumentDate").value(hasItem(DEFAULT_GRANTING_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].revokationDocumentDate").value(hasItem(DEFAULT_REVOKATION_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].validFromDate").value(hasItem(DEFAULT_VALID_FROM_DATE.toString()))) + .andExpect(jsonPath("$.[*].validUntilDate").value(hasItem(DEFAULT_VALID_UNTIL_DATE.toString()))) + .andExpect(jsonPath("$.[*].lastUsedDate").value(hasItem(DEFAULT_LAST_USED_DATE.toString()))) .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK))); // Check, that the count call also returns 1 @@ -867,11 +889,11 @@ public class SepaMandateResourceIntTest { .reference(UPDATED_REFERENCE) .iban(UPDATED_IBAN) .bic(UPDATED_BIC) - .documentDate(UPDATED_DOCUMENT_DATE) - .validFrom(UPDATED_VALID_FROM) - .validUntil(UPDATED_VALID_UNTIL) - .lastUsed(UPDATED_LAST_USED) - .cancellationDate(UPDATED_CANCELLATION_DATE) + .grantingDocumentDate(UPDATED_GRANTING_DOCUMENT_DATE) + .revokationDocumentDate(UPDATED_REVOKATION_DOCUMENT_DATE) + .validFromDate(UPDATED_VALID_FROM_DATE) + .validUntilDate(UPDATED_VALID_UNTIL_DATE) + .lastUsedDate(UPDATED_LAST_USED_DATE) .remark(UPDATED_REMARK); SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(updatedSepaMandate); @@ -887,11 +909,11 @@ public class SepaMandateResourceIntTest { assertThat(testSepaMandate.getReference()).isEqualTo(UPDATED_REFERENCE); assertThat(testSepaMandate.getIban()).isEqualTo(UPDATED_IBAN); assertThat(testSepaMandate.getBic()).isEqualTo(UPDATED_BIC); - assertThat(testSepaMandate.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE); - assertThat(testSepaMandate.getValidFrom()).isEqualTo(UPDATED_VALID_FROM); - assertThat(testSepaMandate.getValidUntil()).isEqualTo(UPDATED_VALID_UNTIL); - assertThat(testSepaMandate.getLastUsed()).isEqualTo(UPDATED_LAST_USED); - assertThat(testSepaMandate.getCancellationDate()).isEqualTo(UPDATED_CANCELLATION_DATE); + assertThat(testSepaMandate.getGrantingDocumentDate()).isEqualTo(UPDATED_GRANTING_DOCUMENT_DATE); + assertThat(testSepaMandate.getRevokationDocumentDate()).isEqualTo(UPDATED_REVOKATION_DOCUMENT_DATE); + assertThat(testSepaMandate.getValidFromDate()).isEqualTo(UPDATED_VALID_FROM_DATE); + assertThat(testSepaMandate.getValidUntilDate()).isEqualTo(UPDATED_VALID_UNTIL_DATE); + assertThat(testSepaMandate.getLastUsedDate()).isEqualTo(UPDATED_LAST_USED_DATE); assertThat(testSepaMandate.getRemark()).isEqualTo(UPDATED_REMARK); } diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java index 3b99a17c..eacbe431 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java @@ -1,17 +1,15 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; - -import org.hostsharing.hsadminng.domain.Share; import org.hostsharing.hsadminng.domain.Membership; +import org.hostsharing.hsadminng.domain.Share; +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; import org.hostsharing.hsadminng.repository.ShareRepository; +import org.hostsharing.hsadminng.service.ShareQueryService; import org.hostsharing.hsadminng.service.ShareService; import org.hostsharing.hsadminng.service.dto.ShareDTO; import org.hostsharing.hsadminng.service.mapper.ShareMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.ShareCriteria; -import org.hostsharing.hsadminng.service.ShareQueryService; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,14 +30,11 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; - -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.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import org.hostsharing.hsadminng.domain.enumeration.ShareAction; /** * Test class for the ShareResource REST controller. * @@ -128,6 +123,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 +584,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 +666,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 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 +710,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 shareList = shareRepository.findAll(); - assertThat(shareList).hasSize(databaseSizeBeforeDelete - 1); + assertThat(shareList).hasSize(databaseSizeBeforeDelete); } @Test diff --git a/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts b/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts index 53f01f13..6d717639 100644 --- a/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts +++ b/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts @@ -1,11 +1,11 @@ /* tslint:disable max-line-length */ -import { TestBed, getTestBed } from '@angular/core/testing'; +import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { HttpClient, HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; -import { take, map } from 'rxjs/operators'; +import { map, take } from 'rxjs/operators'; +import * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; import { CustomerService } from 'app/entities/customer/customer.service'; -import { ICustomer, Customer } from 'app/shared/model/customer.model'; +import { Customer, CustomerKind, ICustomer, VatRegion } from 'app/shared/model/customer.model'; describe('Service Tests', () => { describe('Customer Service', () => { @@ -13,6 +13,7 @@ describe('Service Tests', () => { let service: CustomerService; let httpMock: HttpTestingController; let elemDefault: ICustomer; + let currentDate: moment.Moment; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule] @@ -20,13 +21,36 @@ describe('Service Tests', () => { injector = getTestBed(); service = injector.get(CustomerService); httpMock = injector.get(HttpTestingController); + currentDate = moment(); - elemDefault = new Customer(0, 0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA'); + elemDefault = new Customer( + 0, + 0, + 'AAAAAAA', + 'AAAAAAA', + CustomerKind.NATURAL, + currentDate, + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + VatRegion.DOMESTIC, + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA' + ); }); describe('Service methods', async () => { it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); + const returnedFromService = Object.assign( + { + birthDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); service .find(123) .pipe(take(1)) @@ -39,11 +63,17 @@ describe('Service Tests', () => { it('should create a Customer', async () => { const returnedFromService = Object.assign( { - id: 0 + id: 0, + birthDate: currentDate.format(DATE_FORMAT) }, elemDefault ); - const expected = Object.assign({}, returnedFromService); + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); service .create(new Customer(null)) .pipe(take(1)) @@ -58,6 +88,13 @@ describe('Service Tests', () => { reference: 1, prefix: 'BBBBBB', name: 'BBBBBB', + kind: 'BBBBBB', + birthDate: currentDate.format(DATE_FORMAT), + birthPlace: 'BBBBBB', + registrationCourt: 'BBBBBB', + registrationNumber: 'BBBBBB', + vatRegion: 'BBBBBB', + vatNumber: 'BBBBBB', contractualSalutation: 'BBBBBB', contractualAddress: 'BBBBBB', billingSalutation: 'BBBBBB', @@ -67,7 +104,12 @@ describe('Service Tests', () => { elemDefault ); - const expected = Object.assign({}, returnedFromService); + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); service .update(expected) .pipe(take(1)) @@ -82,6 +124,13 @@ describe('Service Tests', () => { reference: 1, prefix: 'BBBBBB', name: 'BBBBBB', + kind: 'BBBBBB', + birthDate: currentDate.format(DATE_FORMAT), + birthPlace: 'BBBBBB', + registrationCourt: 'BBBBBB', + registrationNumber: 'BBBBBB', + vatRegion: 'BBBBBB', + vatNumber: 'BBBBBB', contractualSalutation: 'BBBBBB', contractualAddress: 'BBBBBB', billingSalutation: 'BBBBBB', @@ -90,7 +139,12 @@ describe('Service Tests', () => { }, elemDefault ); - const expected = Object.assign({}, returnedFromService); + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); service .query(expected) .pipe( diff --git a/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts b/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts index 765beeec..1f5ced40 100644 --- a/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts +++ b/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts @@ -1,9 +1,7 @@ /* tslint:disable max-line-length */ -import { TestBed, getTestBed } from '@angular/core/testing'; +import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { HttpClient, HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; -import { take, map } from 'rxjs/operators'; +import { map, take } from 'rxjs/operators'; import * as moment from 'moment'; import { DATE_FORMAT } from 'app/shared/constants/input.constants'; import { MembershipService } from 'app/entities/membership/membership.service'; @@ -25,16 +23,17 @@ describe('Service Tests', () => { httpMock = injector.get(HttpTestingController); currentDate = moment(); - elemDefault = new Membership(0, currentDate, currentDate, currentDate, 'AAAAAAA'); + elemDefault = new Membership(0, currentDate, currentDate, currentDate, currentDate, 'AAAAAAA'); }); describe('Service methods', async () => { it('should find an element', async () => { const returnedFromService = Object.assign( { - documentDate: currentDate.format(DATE_FORMAT), - memberFrom: currentDate.format(DATE_FORMAT), - memberUntil: currentDate.format(DATE_FORMAT) + admissionDocumentDate: currentDate.format(DATE_FORMAT), + cancellationDocumentDate: currentDate.format(DATE_FORMAT), + memberFromDate: currentDate.format(DATE_FORMAT), + memberUntilDate: currentDate.format(DATE_FORMAT) }, elemDefault ); @@ -51,17 +50,19 @@ describe('Service Tests', () => { const returnedFromService = Object.assign( { id: 0, - documentDate: currentDate.format(DATE_FORMAT), - memberFrom: currentDate.format(DATE_FORMAT), - memberUntil: currentDate.format(DATE_FORMAT) + admissionDocumentDate: currentDate.format(DATE_FORMAT), + cancellationDocumentDate: currentDate.format(DATE_FORMAT), + memberFromDate: currentDate.format(DATE_FORMAT), + memberUntilDate: currentDate.format(DATE_FORMAT) }, elemDefault ); const expected = Object.assign( { - documentDate: currentDate, - memberFrom: currentDate, - memberUntil: currentDate + admissionDocumentDate: currentDate, + cancellationDocumentDate: currentDate, + memberFromDate: currentDate, + memberUntilDate: currentDate }, returnedFromService ); @@ -76,9 +77,10 @@ describe('Service Tests', () => { it('should update a Membership', async () => { const returnedFromService = Object.assign( { - documentDate: currentDate.format(DATE_FORMAT), - memberFrom: currentDate.format(DATE_FORMAT), - memberUntil: currentDate.format(DATE_FORMAT), + admissionDocumentDate: currentDate.format(DATE_FORMAT), + cancellationDocumentDate: currentDate.format(DATE_FORMAT), + memberFromDate: currentDate.format(DATE_FORMAT), + memberUntilDate: currentDate.format(DATE_FORMAT), remark: 'BBBBBB' }, elemDefault @@ -86,9 +88,10 @@ describe('Service Tests', () => { const expected = Object.assign( { - documentDate: currentDate, - memberFrom: currentDate, - memberUntil: currentDate + admissionDocumentDate: currentDate, + cancellationDocumentDate: currentDate, + memberFromDate: currentDate, + memberUntilDate: currentDate }, returnedFromService ); @@ -103,18 +106,20 @@ describe('Service Tests', () => { it('should return a list of Membership', async () => { const returnedFromService = Object.assign( { - documentDate: currentDate.format(DATE_FORMAT), - memberFrom: currentDate.format(DATE_FORMAT), - memberUntil: currentDate.format(DATE_FORMAT), + admissionDocumentDate: currentDate.format(DATE_FORMAT), + cancellationDocumentDate: currentDate.format(DATE_FORMAT), + memberFromDate: currentDate.format(DATE_FORMAT), + memberUntilDate: currentDate.format(DATE_FORMAT), remark: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - documentDate: currentDate, - memberFrom: currentDate, - memberUntil: currentDate + admissionDocumentDate: currentDate, + cancellationDocumentDate: currentDate, + memberFromDate: currentDate, + memberUntilDate: currentDate }, returnedFromService ); diff --git a/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.service.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.service.spec.ts index 0ff6222c..89b1dc0b 100644 --- a/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.service.spec.ts +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.service.spec.ts @@ -1,9 +1,7 @@ /* tslint:disable max-line-length */ -import { TestBed, getTestBed } from '@angular/core/testing'; +import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { HttpClient, HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; -import { take, map } from 'rxjs/operators'; +import { map, take } from 'rxjs/operators'; import * as moment from 'moment'; import { DATE_FORMAT } from 'app/shared/constants/input.constants'; import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service'; @@ -43,11 +41,11 @@ describe('Service Tests', () => { it('should find an element', async () => { const returnedFromService = Object.assign( { - documentDate: currentDate.format(DATE_FORMAT), - validFrom: currentDate.format(DATE_FORMAT), - validUntil: currentDate.format(DATE_FORMAT), - lastUsed: currentDate.format(DATE_FORMAT), - cancellationDate: currentDate.format(DATE_FORMAT) + grantingDocumentDate: currentDate.format(DATE_FORMAT), + revokationDocumentDate: currentDate.format(DATE_FORMAT), + validFromDate: currentDate.format(DATE_FORMAT), + validUntilDate: currentDate.format(DATE_FORMAT), + lastUsedDate: currentDate.format(DATE_FORMAT) }, elemDefault ); @@ -64,21 +62,21 @@ describe('Service Tests', () => { const returnedFromService = Object.assign( { id: 0, - documentDate: currentDate.format(DATE_FORMAT), - validFrom: currentDate.format(DATE_FORMAT), - validUntil: currentDate.format(DATE_FORMAT), - lastUsed: currentDate.format(DATE_FORMAT), - cancellationDate: currentDate.format(DATE_FORMAT) + grantingDocumentDate: currentDate.format(DATE_FORMAT), + revokationDocumentDate: currentDate.format(DATE_FORMAT), + validFromDate: currentDate.format(DATE_FORMAT), + validUntilDate: currentDate.format(DATE_FORMAT), + lastUsedDate: currentDate.format(DATE_FORMAT) }, elemDefault ); const expected = Object.assign( { - documentDate: currentDate, - validFrom: currentDate, - validUntil: currentDate, - lastUsed: currentDate, - cancellationDate: currentDate + grantingDocumentDate: currentDate, + revokationDocumentDate: currentDate, + validFromDate: currentDate, + validUntilDate: currentDate, + lastUsedDate: currentDate }, returnedFromService ); @@ -96,11 +94,11 @@ describe('Service Tests', () => { reference: 'BBBBBB', iban: 'BBBBBB', bic: 'BBBBBB', - documentDate: currentDate.format(DATE_FORMAT), - validFrom: currentDate.format(DATE_FORMAT), - validUntil: currentDate.format(DATE_FORMAT), - lastUsed: currentDate.format(DATE_FORMAT), - cancellationDate: currentDate.format(DATE_FORMAT), + grantingDocumentDate: currentDate.format(DATE_FORMAT), + revokationDocumentDate: currentDate.format(DATE_FORMAT), + validFromDate: currentDate.format(DATE_FORMAT), + validUntilDate: currentDate.format(DATE_FORMAT), + lastUsedDate: currentDate.format(DATE_FORMAT), remark: 'BBBBBB' }, elemDefault @@ -108,11 +106,11 @@ describe('Service Tests', () => { const expected = Object.assign( { - documentDate: currentDate, - validFrom: currentDate, - validUntil: currentDate, - lastUsed: currentDate, - cancellationDate: currentDate + grantingDocumentDate: currentDate, + revokationDocumentDate: currentDate, + validFromDate: currentDate, + validUntilDate: currentDate, + lastUsedDate: currentDate }, returnedFromService ); @@ -130,22 +128,22 @@ describe('Service Tests', () => { reference: 'BBBBBB', iban: 'BBBBBB', bic: 'BBBBBB', - documentDate: currentDate.format(DATE_FORMAT), - validFrom: currentDate.format(DATE_FORMAT), - validUntil: currentDate.format(DATE_FORMAT), - lastUsed: currentDate.format(DATE_FORMAT), - cancellationDate: currentDate.format(DATE_FORMAT), + grantingDocumentDate: currentDate.format(DATE_FORMAT), + revokationDocumentDate: currentDate.format(DATE_FORMAT), + validFromDate: currentDate.format(DATE_FORMAT), + validUntilDate: currentDate.format(DATE_FORMAT), + lastUsedDate: currentDate.format(DATE_FORMAT), remark: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - documentDate: currentDate, - validFrom: currentDate, - validUntil: currentDate, - lastUsed: currentDate, - cancellationDate: currentDate + grantingDocumentDate: currentDate, + revokationDocumentDate: currentDate, + validFromDate: currentDate, + validUntilDate: currentDate, + lastUsedDate: currentDate }, returnedFromService );