diff --git a/.jhipster/Asset.json b/.jhipster/Asset.json new file mode 100644 index 00000000..8da741c9 --- /dev/null +++ b/.jhipster/Asset.json @@ -0,0 +1,61 @@ +{ + "name": "Asset", + "fields": [ + { + "fieldName": "documentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "valueDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "action", + "fieldType": "AssetAction", + "fieldValues": "PAYMENT,HANDOVER,ADOPTION,LOSS,CLEARING,PAYBACK", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "amount", + "fieldType": "BigDecimal", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "remark", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 160 + } + ], + "relationships": [ + { + "relationshipType": "many-to-one", + "otherEntityName": "membership", + "otherEntityRelationshipName": "asset", + "relationshipValidateRules": "required", + "relationshipName": "membership", + "otherEntityField": "admissionDocumentDate" + } + ], + "changelogDate": "20190424123258", + "entityTableName": "asset", + "dto": "mapstruct", + "pagination": "infinite-scroll", + "service": "serviceClass", + "jpaMetamodelFiltering": true, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Customer.json b/.jhipster/Customer.json new file mode 100644 index 00000000..2819d558 --- /dev/null +++ b/.jhipster/Customer.json @@ -0,0 +1,154 @@ +{ + "name": "Customer", + "fields": [ + { + "fieldName": "reference", + "fieldType": "Integer", + "fieldValidateRules": [ + "required", + "unique", + "min", + "max" + ], + "fieldValidateRulesMin": 10000, + "fieldValidateRulesMax": 99999 + }, + { + "fieldName": "prefix", + "fieldType": "String", + "fieldValidateRules": [ + "required", + "maxlength", + "unique", + "pattern" + ], + "fieldValidateRulesMaxlength": 3, + "fieldValidateRulesPattern": "[a-z][a-z0-9]+" + }, + { + "fieldName": "name", + "fieldType": "String", + "fieldValidateRules": [ + "required", + "maxlength" + ], + "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", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 80 + }, + { + "fieldName": "contractualAddress", + "fieldType": "String", + "fieldValidateRules": [ + "required", + "maxlength" + ], + "fieldValidateRulesMaxlength": 400 + }, + { + "fieldName": "billingSalutation", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 80 + }, + { + "fieldName": "billingAddress", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 400 + }, + { + "fieldName": "remark", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 160 + } + ], + "relationships": [ + { + "relationshipType": "one-to-many", + "otherEntityName": "membership", + "otherEntityRelationshipName": "customer", + "relationshipName": "membership" + }, + { + "relationshipType": "one-to-many", + "otherEntityName": "sepaMandate", + "otherEntityRelationshipName": "customer", + "relationshipName": "sepamandate" + } + ], + "changelogDate": "20190424123255", + "entityTableName": "customer", + "dto": "mapstruct", + "pagination": "infinite-scroll", + "service": "serviceClass", + "jpaMetamodelFiltering": true, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Membership.json b/.jhipster/Membership.json new file mode 100644 index 00000000..17d9c161 --- /dev/null +++ b/.jhipster/Membership.json @@ -0,0 +1,66 @@ +{ + "name": "Membership", + "fields": [ + { + "fieldName": "admissionDocumentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "cancellationDocumentDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "memberFromDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "memberUntilDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "remark", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 160 + } + ], + "relationships": [ + { + "relationshipType": "one-to-many", + "otherEntityName": "share", + "otherEntityRelationshipName": "membership", + "relationshipName": "share" + }, + { + "relationshipType": "one-to-many", + "otherEntityName": "asset", + "otherEntityRelationshipName": "membership", + "relationshipName": "asset" + }, + { + "relationshipType": "many-to-one", + "otherEntityName": "customer", + "otherEntityRelationshipName": "membership", + "relationshipValidateRules": "required", + "relationshipName": "customer", + "otherEntityField": "prefix" + } + ], + "changelogDate": "20190424123256", + "entityTableName": "membership", + "dto": "mapstruct", + "pagination": "infinite-scroll", + "service": "serviceClass", + "jpaMetamodelFiltering": true, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/SepaMandate.json b/.jhipster/SepaMandate.json new file mode 100644 index 00000000..e04d2c2b --- /dev/null +++ b/.jhipster/SepaMandate.json @@ -0,0 +1,84 @@ +{ + "name": "SepaMandate", + "fields": [ + { + "fieldName": "reference", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength", + "unique", + "required" + ], + "fieldValidateRulesMaxlength": 40 + }, + { + "fieldName": "iban", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 34 + }, + { + "fieldName": "bic", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 11 + }, + { + "fieldName": "grantingDocumentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "revokationDocumentDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "validFromDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "validUntilDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "lastUsedDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "remark", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 160 + } + ], + "relationships": [ + { + "relationshipType": "many-to-one", + "otherEntityName": "customer", + "otherEntityRelationshipName": "sepamandate", + "relationshipValidateRules": "required", + "relationshipName": "customer", + "otherEntityField": "prefix" + } + ], + "changelogDate": "20190424123259", + "entityTableName": "sepa_mandate", + "dto": "mapstruct", + "pagination": "infinite-scroll", + "service": "serviceClass", + "jpaMetamodelFiltering": true, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Share.json b/.jhipster/Share.json new file mode 100644 index 00000000..4416d50f --- /dev/null +++ b/.jhipster/Share.json @@ -0,0 +1,61 @@ +{ + "name": "Share", + "fields": [ + { + "fieldName": "documentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "valueDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "action", + "fieldType": "ShareAction", + "fieldValues": "SUBSCRIPTION,CANCELLATION", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "quantity", + "fieldType": "Integer", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "remark", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 160 + } + ], + "relationships": [ + { + "relationshipType": "many-to-one", + "otherEntityName": "membership", + "otherEntityRelationshipName": "share", + "relationshipValidateRules": "required", + "relationshipName": "membership", + "otherEntityField": "admissionDocumentDate" + } + ], + "changelogDate": "20190424123257", + "entityTableName": "share", + "dto": "mapstruct", + "pagination": "infinite-scroll", + "service": "serviceClass", + "jpaMetamodelFiltering": true, + "fluentMethods": true, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java new file mode 100644 index 00000000..22227eb3 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java @@ -0,0 +1,175 @@ +package org.hostsharing.hsadminng.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.*; +import javax.validation.constraints.*; + +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. + */ +@Entity +@Table(name = "asset") +public class Asset implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Column(name = "document_date", nullable = false) + private LocalDate documentDate; + + @NotNull + @Column(name = "value_date", nullable = false) + private LocalDate valueDate; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "action", nullable = false) + private AssetAction action; + + @NotNull + @Column(name = "amount", precision = 10, scale = 2, nullable = false) + private BigDecimal amount; + + @Size(max = 160) + @Column(name = "remark", length = 160) + private String remark; + + @ManyToOne(optional = false) + @NotNull + @JsonIgnoreProperties("assets") + private Membership membership; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDate getDocumentDate() { + return documentDate; + } + + public Asset documentDate(LocalDate documentDate) { + this.documentDate = documentDate; + return this; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValueDate() { + return valueDate; + } + + public Asset valueDate(LocalDate valueDate) { + this.valueDate = valueDate; + return this; + } + + public void setValueDate(LocalDate valueDate) { + this.valueDate = valueDate; + } + + public AssetAction getAction() { + return action; + } + + public Asset action(AssetAction action) { + this.action = action; + return this; + } + + public void setAction(AssetAction action) { + this.action = action; + } + + public BigDecimal getAmount() { + return amount; + } + + public Asset amount(BigDecimal amount) { + this.amount = amount; + return this; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public String getRemark() { + return remark; + } + + public Asset remark(String remark) { + this.remark = remark; + return this; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Membership getMembership() { + return membership; + } + + public Asset membership(Membership membership) { + this.membership = membership; + return this; + } + + public void setMembership(Membership membership) { + this.membership = membership; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Asset asset = (Asset) o; + if (asset.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), asset.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Asset{" + + "id=" + getId() + + ", documentDate='" + getDocumentDate() + "'" + + ", valueDate='" + getValueDate() + "'" + + ", action='" + getAction() + "'" + + ", amount=" + getAmount() + + ", remark='" + getRemark() + "'" + + "}"; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java new file mode 100644 index 00000000..8d49b690 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java @@ -0,0 +1,400 @@ +package org.hostsharing.hsadminng.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.time.LocalDate; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; + +import org.hostsharing.hsadminng.domain.enumeration.VatRegion; + +/** + * A Customer. + */ +@Entity +@Table(name = "customer") +public class Customer implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Min(value = 10000) + @Max(value = 99999) + @Column(name = "reference", nullable = false, unique = true) + private Integer reference; + + @NotNull + @Size(max = 3) + @Pattern(regexp = "[a-z][a-z0-9]+") + @Column(name = "prefix", length = 3, nullable = false, unique = true) + private String prefix; + + @NotNull + @Size(max = 80) + @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; + + @NotNull + @Size(max = 400) + @Column(name = "contractual_address", length = 400, nullable = false) + private String contractualAddress; + + @Size(max = 80) + @Column(name = "billing_salutation", length = 80) + private String billingSalutation; + + @Size(max = 400) + @Column(name = "billing_address", length = 400) + private String billingAddress; + + @Size(max = 160) + @Column(name = "remark", length = 160) + private String remark; + + @OneToMany(mappedBy = "customer") + private Set memberships = new HashSet<>(); + @OneToMany(mappedBy = "customer") + private Set sepamandates = new HashSet<>(); + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getReference() { + return reference; + } + + public Customer reference(Integer reference) { + this.reference = reference; + return this; + } + + public void setReference(Integer reference) { + this.reference = reference; + } + + public String getPrefix() { + return prefix; + } + + public Customer prefix(String prefix) { + this.prefix = prefix; + return this; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getName() { + return name; + } + + public Customer name(String name) { + this.name = name; + return this; + } + + public void setName(String name) { + 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; + } + + public Customer contractualSalutation(String contractualSalutation) { + this.contractualSalutation = contractualSalutation; + return this; + } + + public void setContractualSalutation(String contractualSalutation) { + this.contractualSalutation = contractualSalutation; + } + + public String getContractualAddress() { + return contractualAddress; + } + + public Customer contractualAddress(String contractualAddress) { + this.contractualAddress = contractualAddress; + return this; + } + + public void setContractualAddress(String contractualAddress) { + this.contractualAddress = contractualAddress; + } + + public String getBillingSalutation() { + return billingSalutation; + } + + public Customer billingSalutation(String billingSalutation) { + this.billingSalutation = billingSalutation; + return this; + } + + public void setBillingSalutation(String billingSalutation) { + this.billingSalutation = billingSalutation; + } + + public String getBillingAddress() { + return billingAddress; + } + + public Customer billingAddress(String billingAddress) { + this.billingAddress = billingAddress; + return this; + } + + public void setBillingAddress(String billingAddress) { + this.billingAddress = billingAddress; + } + + public String getRemark() { + return remark; + } + + public Customer remark(String remark) { + this.remark = remark; + return this; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Set getMemberships() { + return memberships; + } + + public Customer memberships(Set memberships) { + this.memberships = memberships; + return this; + } + + public Customer addMembership(Membership membership) { + this.memberships.add(membership); + membership.setCustomer(this); + return this; + } + + public Customer removeMembership(Membership membership) { + this.memberships.remove(membership); + membership.setCustomer(null); + return this; + } + + public void setMemberships(Set memberships) { + this.memberships = memberships; + } + + public Set getSepamandates() { + return sepamandates; + } + + public Customer sepamandates(Set sepaMandates) { + this.sepamandates = sepaMandates; + return this; + } + + public Customer addSepamandate(SepaMandate sepaMandate) { + this.sepamandates.add(sepaMandate); + sepaMandate.setCustomer(this); + return this; + } + + public Customer removeSepamandate(SepaMandate sepaMandate) { + this.sepamandates.remove(sepaMandate); + sepaMandate.setCustomer(null); + return this; + } + + public void setSepamandates(Set sepaMandates) { + this.sepamandates = sepaMandates; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Customer customer = (Customer) o; + if (customer.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), customer.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Customer{" + + "id=" + getId() + + ", 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() + "'" + + ", billingAddress='" + getBillingAddress() + "'" + + ", remark='" + getRemark() + "'" + + "}"; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java new file mode 100644 index 00000000..e6f7afca --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java @@ -0,0 +1,226 @@ +package org.hostsharing.hsadminng.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.time.LocalDate; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +/** + * A Membership. + */ +@Entity +@Table(name = "membership") +public class Membership implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Column(name = "admission_document_date", nullable = false) + private LocalDate admissionDocumentDate; + + @Column(name = "cancellation_document_date") + private LocalDate cancellationDocumentDate; + + @NotNull + @Column(name = "member_from_date", nullable = false) + private LocalDate memberFromDate; + + @Column(name = "member_until_date") + private LocalDate memberUntilDate; + + @Size(max = 160) + @Column(name = "remark", length = 160) + private String remark; + + @OneToMany(mappedBy = "membership") + private Set shares = new HashSet<>(); + @OneToMany(mappedBy = "membership") + private Set assets = new HashSet<>(); + @ManyToOne(optional = false) + @NotNull + @JsonIgnoreProperties("memberships") + private Customer customer; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDate getAdmissionDocumentDate() { + return admissionDocumentDate; + } + + public Membership admissionDocumentDate(LocalDate admissionDocumentDate) { + this.admissionDocumentDate = admissionDocumentDate; + return this; + } + + public void setAdmissionDocumentDate(LocalDate admissionDocumentDate) { + this.admissionDocumentDate = admissionDocumentDate; + } + + public LocalDate getCancellationDocumentDate() { + return cancellationDocumentDate; + } + + public Membership cancellationDocumentDate(LocalDate cancellationDocumentDate) { + this.cancellationDocumentDate = cancellationDocumentDate; + return this; + } + + public void setCancellationDocumentDate(LocalDate cancellationDocumentDate) { + this.cancellationDocumentDate = cancellationDocumentDate; + } + + public LocalDate getMemberFromDate() { + return memberFromDate; + } + + public Membership memberFromDate(LocalDate memberFromDate) { + this.memberFromDate = memberFromDate; + return this; + } + + 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() { + return remark; + } + + public Membership remark(String remark) { + this.remark = remark; + return this; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Set getShares() { + return shares; + } + + public Membership shares(Set shares) { + this.shares = shares; + return this; + } + + public Membership addShare(Share share) { + this.shares.add(share); + share.setMembership(this); + return this; + } + + public Membership removeShare(Share share) { + this.shares.remove(share); + share.setMembership(null); + return this; + } + + public void setShares(Set shares) { + this.shares = shares; + } + + public Set getAssets() { + return assets; + } + + public Membership assets(Set assets) { + this.assets = assets; + return this; + } + + public Membership addAsset(Asset asset) { + this.assets.add(asset); + asset.setMembership(this); + return this; + } + + public Membership removeAsset(Asset asset) { + this.assets.remove(asset); + asset.setMembership(null); + return this; + } + + public void setAssets(Set assets) { + this.assets = assets; + } + + public Customer getCustomer() { + return customer; + } + + public Membership customer(Customer customer) { + this.customer = customer; + return this; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Membership membership = (Membership) o; + if (membership.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), membership.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Membership{" + + "id=" + getId() + + ", 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 new file mode 100644 index 00000000..e6bd34f4 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/SepaMandate.java @@ -0,0 +1,241 @@ +package org.hostsharing.hsadminng.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.time.LocalDate; +import java.util.Objects; + +/** + * A SepaMandate. + */ +@Entity +@Table(name = "sepa_mandate") +public class SepaMandate implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Size(max = 40) + @Column(name = "reference", length = 40, nullable = false, unique = true) + private String reference; + + @Size(max = 34) + @Column(name = "iban", length = 34) + private String iban; + + @Size(max = 11) + @Column(name = "bic", length = 11) + private String bic; + + @NotNull + @Column(name = "granting_document_date", nullable = false) + private LocalDate grantingDocumentDate; + + @Column(name = "revokation_document_date") + private LocalDate revokationDocumentDate; + + @NotNull + @Column(name = "valid_from_date", nullable = false) + private LocalDate validFromDate; + + @Column(name = "valid_until_date") + private LocalDate validUntilDate; + + @Column(name = "last_used_date") + private LocalDate lastUsedDate; + + @Size(max = 160) + @Column(name = "remark", length = 160) + private String remark; + + @ManyToOne(optional = false) + @NotNull + @JsonIgnoreProperties("sepamandates") + private Customer customer; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getReference() { + return reference; + } + + public SepaMandate reference(String reference) { + this.reference = reference; + return this; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getIban() { + return iban; + } + + public SepaMandate iban(String iban) { + this.iban = iban; + return this; + } + + public void setIban(String iban) { + this.iban = iban; + } + + public String getBic() { + return bic; + } + + public SepaMandate bic(String bic) { + this.bic = bic; + return this; + } + + public void setBic(String bic) { + this.bic = bic; + } + + public LocalDate getGrantingDocumentDate() { + return grantingDocumentDate; + } + + public SepaMandate grantingDocumentDate(LocalDate grantingDocumentDate) { + this.grantingDocumentDate = grantingDocumentDate; + return this; + } + + public void setGrantingDocumentDate(LocalDate grantingDocumentDate) { + this.grantingDocumentDate = grantingDocumentDate; + } + + public LocalDate getRevokationDocumentDate() { + return revokationDocumentDate; + } + + public SepaMandate revokationDocumentDate(LocalDate revokationDocumentDate) { + this.revokationDocumentDate = revokationDocumentDate; + return this; + } + + public void setRevokationDocumentDate(LocalDate revokationDocumentDate) { + this.revokationDocumentDate = revokationDocumentDate; + } + + public LocalDate getValidFromDate() { + return validFromDate; + } + + public SepaMandate validFromDate(LocalDate validFromDate) { + this.validFromDate = validFromDate; + return this; + } + + public void setValidFromDate(LocalDate validFromDate) { + this.validFromDate = validFromDate; + } + + public LocalDate getValidUntilDate() { + return validUntilDate; + } + + public SepaMandate validUntilDate(LocalDate validUntilDate) { + this.validUntilDate = validUntilDate; + return this; + } + + public void setValidUntilDate(LocalDate validUntilDate) { + this.validUntilDate = validUntilDate; + } + + public LocalDate getLastUsedDate() { + return lastUsedDate; + } + + public SepaMandate lastUsedDate(LocalDate lastUsedDate) { + this.lastUsedDate = lastUsedDate; + return this; + } + + public void setLastUsedDate(LocalDate lastUsedDate) { + this.lastUsedDate = lastUsedDate; + } + + public String getRemark() { + return remark; + } + + public SepaMandate remark(String remark) { + this.remark = remark; + return this; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Customer getCustomer() { + return customer; + } + + public SepaMandate customer(Customer customer) { + this.customer = customer; + return this; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SepaMandate sepaMandate = (SepaMandate) o; + if (sepaMandate.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), sepaMandate.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "SepaMandate{" + + "id=" + getId() + + ", reference='" + getReference() + "'" + + ", iban='" + getIban() + "'" + + ", bic='" + getBic() + "'" + + ", 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 new file mode 100644 index 00000000..2bc26931 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/Share.java @@ -0,0 +1,174 @@ +package org.hostsharing.hsadminng.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.time.LocalDate; +import java.util.Objects; + +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; + +/** + * A Share. + */ +@Entity +@Table(name = "share") +public class Share implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Column(name = "document_date", nullable = false) + private LocalDate documentDate; + + @NotNull + @Column(name = "value_date", nullable = false) + private LocalDate valueDate; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "action", nullable = false) + private ShareAction action; + + @NotNull + @Column(name = "quantity", nullable = false) + private Integer quantity; + + @Size(max = 160) + @Column(name = "remark", length = 160) + private String remark; + + @ManyToOne(optional = false) + @NotNull + @JsonIgnoreProperties("shares") + private Membership membership; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDate getDocumentDate() { + return documentDate; + } + + public Share documentDate(LocalDate documentDate) { + this.documentDate = documentDate; + return this; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValueDate() { + return valueDate; + } + + public Share valueDate(LocalDate valueDate) { + this.valueDate = valueDate; + return this; + } + + public void setValueDate(LocalDate valueDate) { + this.valueDate = valueDate; + } + + public ShareAction getAction() { + return action; + } + + public Share action(ShareAction action) { + this.action = action; + return this; + } + + public void setAction(ShareAction action) { + this.action = action; + } + + public Integer getQuantity() { + return quantity; + } + + public Share quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public String getRemark() { + return remark; + } + + public Share remark(String remark) { + this.remark = remark; + return this; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Membership getMembership() { + return membership; + } + + public Share membership(Membership membership) { + this.membership = membership; + return this; + } + + public void setMembership(Membership membership) { + this.membership = membership; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Share share = (Share) o; + if (share.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), share.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Share{" + + "id=" + getId() + + ", documentDate='" + getDocumentDate() + "'" + + ", valueDate='" + getValueDate() + "'" + + ", action='" + getAction() + "'" + + ", quantity=" + getQuantity() + + ", remark='" + getRemark() + "'" + + "}"; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/AssetAction.java b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/AssetAction.java new file mode 100644 index 00000000..a42d7a04 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/AssetAction.java @@ -0,0 +1,8 @@ +package org.hostsharing.hsadminng.domain.enumeration; + +/** + * The AssetAction enumeration. + */ +public enum AssetAction { + PAYMENT, HANDOVER, ADOPTION, LOSS, CLEARING, PAYBACK +} 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/ShareAction.java b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/ShareAction.java new file mode 100644 index 00000000..032d8638 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/ShareAction.java @@ -0,0 +1,8 @@ +package org.hostsharing.hsadminng.domain.enumeration; + +/** + * The ShareAction enumeration. + */ +public enum ShareAction { + SUBSCRIPTION, CANCELLATION +} 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/AssetRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/AssetRepository.java new file mode 100644 index 00000000..31c5a947 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/repository/AssetRepository.java @@ -0,0 +1,15 @@ +package org.hostsharing.hsadminng.repository; + +import org.hostsharing.hsadminng.domain.Asset; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Asset entity. + */ +@SuppressWarnings("unused") +@Repository +public interface AssetRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/CustomerRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/CustomerRepository.java new file mode 100644 index 00000000..11367351 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/repository/CustomerRepository.java @@ -0,0 +1,15 @@ +package org.hostsharing.hsadminng.repository; + +import org.hostsharing.hsadminng.domain.Customer; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Customer entity. + */ +@SuppressWarnings("unused") +@Repository +public interface CustomerRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java new file mode 100644 index 00000000..8382a19b --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java @@ -0,0 +1,15 @@ +package org.hostsharing.hsadminng.repository; + +import org.hostsharing.hsadminng.domain.Membership; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Membership entity. + */ +@SuppressWarnings("unused") +@Repository +public interface MembershipRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/SepaMandateRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/SepaMandateRepository.java new file mode 100644 index 00000000..323a7783 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/repository/SepaMandateRepository.java @@ -0,0 +1,15 @@ +package org.hostsharing.hsadminng.repository; + +import org.hostsharing.hsadminng.domain.SepaMandate; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the SepaMandate entity. + */ +@SuppressWarnings("unused") +@Repository +public interface SepaMandateRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/ShareRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/ShareRepository.java new file mode 100644 index 00000000..660f4d9b --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/repository/ShareRepository.java @@ -0,0 +1,15 @@ +package org.hostsharing.hsadminng.repository; + +import org.hostsharing.hsadminng.domain.Share; +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + + +/** + * Spring Data repository for the Share entity. + */ +@SuppressWarnings("unused") +@Repository +public interface ShareRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java new file mode 100644 index 00000000..82137a84 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java @@ -0,0 +1,114 @@ +package org.hostsharing.hsadminng.service; + +import java.util.List; + +import javax.persistence.criteria.JoinType; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +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.Asset; +import org.hostsharing.hsadminng.domain.*; // for static metamodels +import org.hostsharing.hsadminng.repository.AssetRepository; +import org.hostsharing.hsadminng.service.dto.AssetCriteria; +import org.hostsharing.hsadminng.service.dto.AssetDTO; +import org.hostsharing.hsadminng.service.mapper.AssetMapper; + +/** + * Service for executing complex queries for Asset entities in the database. + * The main input is a {@link AssetCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link List} of {@link AssetDTO} or a {@link Page} of {@link AssetDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class AssetQueryService extends QueryService { + + private final Logger log = LoggerFactory.getLogger(AssetQueryService.class); + + private final AssetRepository assetRepository; + + private final AssetMapper assetMapper; + + public AssetQueryService(AssetRepository assetRepository, AssetMapper assetMapper) { + this.assetRepository = assetRepository; + this.assetMapper = assetMapper; + } + + /** + * Return a {@link List} of {@link AssetDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public List findByCriteria(AssetCriteria criteria) { + log.debug("find by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return assetMapper.toDto(assetRepository.findAll(specification)); + } + + /** + * Return a {@link Page} of {@link AssetDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(AssetCriteria criteria, Pageable page) { + log.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return assetRepository.findAll(specification, page) + .map(assetMapper::toDto); + } + + /** + * Return the number of matching entities in the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(AssetCriteria criteria) { + log.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return assetRepository.count(specification); + } + + /** + * Function to convert AssetCriteria to a {@link Specification} + */ + private Specification createSpecification(AssetCriteria criteria) { + Specification specification = Specification.where(null); + if (criteria != null) { + if (criteria.getId() != null) { + specification = specification.and(buildSpecification(criteria.getId(), Asset_.id)); + } + if (criteria.getDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), Asset_.documentDate)); + } + if (criteria.getValueDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValueDate(), Asset_.valueDate)); + } + if (criteria.getAction() != null) { + specification = specification.and(buildSpecification(criteria.getAction(), Asset_.action)); + } + if (criteria.getAmount() != null) { + specification = specification.and(buildRangeSpecification(criteria.getAmount(), Asset_.amount)); + } + if (criteria.getRemark() != null) { + specification = specification.and(buildStringSpecification(criteria.getRemark(), Asset_.remark)); + } + if (criteria.getMembershipId() != null) { + specification = specification.and(buildSpecification(criteria.getMembershipId(), + root -> root.join(Asset_.membership, JoinType.LEFT).get(Membership_.id))); + } + } + return specification; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/AssetService.java b/src/main/java/org/hostsharing/hsadminng/service/AssetService.java new file mode 100644 index 00000000..0b6ab5a9 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/AssetService.java @@ -0,0 +1,84 @@ +package org.hostsharing.hsadminng.service; + +import org.hostsharing.hsadminng.domain.Asset; +import org.hostsharing.hsadminng.repository.AssetRepository; +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; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing Asset. + */ +@Service +@Transactional +public class AssetService { + + private final Logger log = LoggerFactory.getLogger(AssetService.class); + + private final AssetRepository assetRepository; + + private final AssetMapper assetMapper; + + public AssetService(AssetRepository assetRepository, AssetMapper assetMapper) { + this.assetRepository = assetRepository; + this.assetMapper = assetMapper; + } + + /** + * Save a asset. + * + * @param assetDTO the entity to save + * @return the persisted entity + */ + public AssetDTO save(AssetDTO assetDTO) { + log.debug("Request to save Asset : {}", assetDTO); + Asset asset = assetMapper.toEntity(assetDTO); + asset = assetRepository.save(asset); + return assetMapper.toDto(asset); + } + + /** + * Get all the assets. + * + * @param pageable the pagination information + * @return the list of entities + */ + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all Assets"); + return assetRepository.findAll(pageable) + .map(assetMapper::toDto); + } + + + /** + * Get one asset by id. + * + * @param id the id of the entity + * @return the entity + */ + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Asset : {}", id); + return assetRepository.findById(id) + .map(assetMapper::toDto); + } + + /** + * Delete the asset by id. + * + * @param id the id of the entity + */ + public void delete(Long id) { + log.debug("Request to delete Asset : {}", id); + assetRepository.deleteById(id); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java new file mode 100644 index 00000000..e596b66d --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java @@ -0,0 +1,148 @@ +package org.hostsharing.hsadminng.service; + +import java.util.List; + +import javax.persistence.criteria.JoinType; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +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; + +/** + * Service for executing complex queries for Customer entities in the database. + * The main input is a {@link CustomerCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link List} of {@link CustomerDTO} or a {@link Page} of {@link CustomerDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class CustomerQueryService extends QueryService { + + private final Logger log = LoggerFactory.getLogger(CustomerQueryService.class); + + private final CustomerRepository customerRepository; + + private final CustomerMapper customerMapper; + + public CustomerQueryService(CustomerRepository customerRepository, CustomerMapper customerMapper) { + this.customerRepository = customerRepository; + this.customerMapper = customerMapper; + } + + /** + * Return a {@link List} of {@link CustomerDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public List findByCriteria(CustomerCriteria criteria) { + log.debug("find by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return customerMapper.toDto(customerRepository.findAll(specification)); + } + + /** + * Return a {@link Page} of {@link CustomerDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(CustomerCriteria criteria, Pageable page) { + log.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return customerRepository.findAll(specification, page) + .map(customerMapper::toDto); + } + + /** + * Return the number of matching entities in the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(CustomerCriteria criteria) { + log.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return customerRepository.count(specification); + } + + /** + * Function to convert CustomerCriteria to a {@link Specification} + */ + private Specification createSpecification(CustomerCriteria criteria) { + Specification specification = Specification.where(null); + if (criteria != null) { + if (criteria.getId() != null) { + specification = specification.and(buildSpecification(criteria.getId(), Customer_.id)); + } + if (criteria.getReference() != null) { + specification = specification.and(buildRangeSpecification(criteria.getReference(), Customer_.reference)); + } + if (criteria.getPrefix() != null) { + specification = specification.and(buildStringSpecification(criteria.getPrefix(), Customer_.prefix)); + } + 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)); + } + if (criteria.getContractualAddress() != null) { + specification = specification.and(buildStringSpecification(criteria.getContractualAddress(), Customer_.contractualAddress)); + } + if (criteria.getBillingSalutation() != null) { + specification = specification.and(buildStringSpecification(criteria.getBillingSalutation(), Customer_.billingSalutation)); + } + if (criteria.getBillingAddress() != null) { + specification = specification.and(buildStringSpecification(criteria.getBillingAddress(), Customer_.billingAddress)); + } + if (criteria.getRemark() != null) { + specification = specification.and(buildStringSpecification(criteria.getRemark(), Customer_.remark)); + } + if (criteria.getMembershipId() != null) { + specification = specification.and(buildSpecification(criteria.getMembershipId(), + root -> root.join(Customer_.memberships, JoinType.LEFT).get(Membership_.id))); + } + if (criteria.getSepamandateId() != null) { + specification = specification.and(buildSpecification(criteria.getSepamandateId(), + root -> root.join(Customer_.sepamandates, JoinType.LEFT).get(SepaMandate_.id))); + } + } + return specification; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerService.java new file mode 100644 index 00000000..d7153deb --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/CustomerService.java @@ -0,0 +1,84 @@ +package org.hostsharing.hsadminng.service; + +import org.hostsharing.hsadminng.domain.Customer; +import org.hostsharing.hsadminng.repository.CustomerRepository; +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; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing Customer. + */ +@Service +@Transactional +public class CustomerService { + + private final Logger log = LoggerFactory.getLogger(CustomerService.class); + + private final CustomerRepository customerRepository; + + private final CustomerMapper customerMapper; + + public CustomerService(CustomerRepository customerRepository, CustomerMapper customerMapper) { + this.customerRepository = customerRepository; + this.customerMapper = customerMapper; + } + + /** + * Save a customer. + * + * @param customerDTO the entity to save + * @return the persisted entity + */ + public CustomerDTO save(CustomerDTO customerDTO) { + log.debug("Request to save Customer : {}", customerDTO); + Customer customer = customerMapper.toEntity(customerDTO); + customer = customerRepository.save(customer); + return customerMapper.toDto(customer); + } + + /** + * Get all the customers. + * + * @param pageable the pagination information + * @return the list of entities + */ + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all Customers"); + return customerRepository.findAll(pageable) + .map(customerMapper::toDto); + } + + + /** + * Get one customer by id. + * + * @param id the id of the entity + * @return the entity + */ + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Customer : {}", id); + return customerRepository.findById(id) + .map(customerMapper::toDto); + } + + /** + * Delete the customer by id. + * + * @param id the id of the entity + */ + public void delete(Long id) { + log.debug("Request to delete Customer : {}", id); + customerRepository.deleteById(id); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java new file mode 100644 index 00000000..c25a4912 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java @@ -0,0 +1,122 @@ +package org.hostsharing.hsadminng.service; + +import java.util.List; + +import javax.persistence.criteria.JoinType; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +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; + +/** + * Service for executing complex queries for Membership entities in the database. + * The main input is a {@link MembershipCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link List} of {@link MembershipDTO} or a {@link Page} of {@link MembershipDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class MembershipQueryService extends QueryService { + + private final Logger log = LoggerFactory.getLogger(MembershipQueryService.class); + + private final MembershipRepository membershipRepository; + + private final MembershipMapper membershipMapper; + + public MembershipQueryService(MembershipRepository membershipRepository, MembershipMapper membershipMapper) { + this.membershipRepository = membershipRepository; + this.membershipMapper = membershipMapper; + } + + /** + * Return a {@link List} of {@link MembershipDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public List findByCriteria(MembershipCriteria criteria) { + log.debug("find by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return membershipMapper.toDto(membershipRepository.findAll(specification)); + } + + /** + * Return a {@link Page} of {@link MembershipDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(MembershipCriteria criteria, Pageable page) { + log.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return membershipRepository.findAll(specification, page) + .map(membershipMapper::toDto); + } + + /** + * Return the number of matching entities in the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(MembershipCriteria criteria) { + log.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return membershipRepository.count(specification); + } + + /** + * Function to convert MembershipCriteria to a {@link Specification} + */ + private Specification createSpecification(MembershipCriteria criteria) { + Specification specification = Specification.where(null); + if (criteria != null) { + if (criteria.getId() != null) { + specification = specification.and(buildSpecification(criteria.getId(), Membership_.id)); + } + if (criteria.getAdmissionDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getAdmissionDocumentDate(), Membership_.admissionDocumentDate)); + } + if (criteria.getCancellationDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getCancellationDocumentDate(), Membership_.cancellationDocumentDate)); + } + 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)); + } + if (criteria.getShareId() != null) { + specification = specification.and(buildSpecification(criteria.getShareId(), + root -> root.join(Membership_.shares, JoinType.LEFT).get(Share_.id))); + } + if (criteria.getAssetId() != null) { + specification = specification.and(buildSpecification(criteria.getAssetId(), + root -> root.join(Membership_.assets, JoinType.LEFT).get(Asset_.id))); + } + if (criteria.getCustomerId() != null) { + specification = specification.and(buildSpecification(criteria.getCustomerId(), + root -> root.join(Membership_.customer, JoinType.LEFT).get(Customer_.id))); + } + } + return specification; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/MembershipService.java b/src/main/java/org/hostsharing/hsadminng/service/MembershipService.java new file mode 100644 index 00000000..53fb74cb --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/MembershipService.java @@ -0,0 +1,84 @@ +package org.hostsharing.hsadminng.service; + +import org.hostsharing.hsadminng.domain.Membership; +import org.hostsharing.hsadminng.repository.MembershipRepository; +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; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing Membership. + */ +@Service +@Transactional +public class MembershipService { + + private final Logger log = LoggerFactory.getLogger(MembershipService.class); + + private final MembershipRepository membershipRepository; + + private final MembershipMapper membershipMapper; + + public MembershipService(MembershipRepository membershipRepository, MembershipMapper membershipMapper) { + this.membershipRepository = membershipRepository; + this.membershipMapper = membershipMapper; + } + + /** + * Save a membership. + * + * @param membershipDTO the entity to save + * @return the persisted entity + */ + public MembershipDTO save(MembershipDTO membershipDTO) { + log.debug("Request to save Membership : {}", membershipDTO); + Membership membership = membershipMapper.toEntity(membershipDTO); + membership = membershipRepository.save(membership); + return membershipMapper.toDto(membership); + } + + /** + * Get all the memberships. + * + * @param pageable the pagination information + * @return the list of entities + */ + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all Memberships"); + return membershipRepository.findAll(pageable) + .map(membershipMapper::toDto); + } + + + /** + * Get one membership by id. + * + * @param id the id of the entity + * @return the entity + */ + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Membership : {}", id); + return membershipRepository.findById(id) + .map(membershipMapper::toDto); + } + + /** + * Delete the membership by id. + * + * @param id the id of the entity + */ + public void delete(Long id) { + log.debug("Request to delete Membership : {}", id); + membershipRepository.deleteById(id); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java new file mode 100644 index 00000000..ff0ebc89 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java @@ -0,0 +1,126 @@ +package org.hostsharing.hsadminng.service; + +import java.util.List; + +import javax.persistence.criteria.JoinType; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +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; + +/** + * Service for executing complex queries for SepaMandate entities in the database. + * The main input is a {@link SepaMandateCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link List} of {@link SepaMandateDTO} or a {@link Page} of {@link SepaMandateDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class SepaMandateQueryService extends QueryService { + + private final Logger log = LoggerFactory.getLogger(SepaMandateQueryService.class); + + private final SepaMandateRepository sepaMandateRepository; + + private final SepaMandateMapper sepaMandateMapper; + + public SepaMandateQueryService(SepaMandateRepository sepaMandateRepository, SepaMandateMapper sepaMandateMapper) { + this.sepaMandateRepository = sepaMandateRepository; + this.sepaMandateMapper = sepaMandateMapper; + } + + /** + * Return a {@link List} of {@link SepaMandateDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public List findByCriteria(SepaMandateCriteria criteria) { + log.debug("find by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return sepaMandateMapper.toDto(sepaMandateRepository.findAll(specification)); + } + + /** + * Return a {@link Page} of {@link SepaMandateDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(SepaMandateCriteria criteria, Pageable page) { + log.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return sepaMandateRepository.findAll(specification, page) + .map(sepaMandateMapper::toDto); + } + + /** + * Return the number of matching entities in the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(SepaMandateCriteria criteria) { + log.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return sepaMandateRepository.count(specification); + } + + /** + * Function to convert SepaMandateCriteria to a {@link Specification} + */ + private Specification createSpecification(SepaMandateCriteria criteria) { + Specification specification = Specification.where(null); + if (criteria != null) { + if (criteria.getId() != null) { + specification = specification.and(buildSpecification(criteria.getId(), SepaMandate_.id)); + } + if (criteria.getReference() != null) { + specification = specification.and(buildStringSpecification(criteria.getReference(), SepaMandate_.reference)); + } + if (criteria.getIban() != null) { + specification = specification.and(buildStringSpecification(criteria.getIban(), SepaMandate_.iban)); + } + if (criteria.getBic() != null) { + specification = specification.and(buildStringSpecification(criteria.getBic(), SepaMandate_.bic)); + } + if (criteria.getGrantingDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getGrantingDocumentDate(), SepaMandate_.grantingDocumentDate)); + } + if (criteria.getRevokationDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getRevokationDocumentDate(), SepaMandate_.revokationDocumentDate)); + } + if (criteria.getValidFromDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidFromDate(), SepaMandate_.validFromDate)); + } + if (criteria.getValidUntilDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidUntilDate(), SepaMandate_.validUntilDate)); + } + if (criteria.getLastUsedDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getLastUsedDate(), SepaMandate_.lastUsedDate)); + } + if (criteria.getRemark() != null) { + specification = specification.and(buildStringSpecification(criteria.getRemark(), SepaMandate_.remark)); + } + if (criteria.getCustomerId() != null) { + specification = specification.and(buildSpecification(criteria.getCustomerId(), + root -> root.join(SepaMandate_.customer, JoinType.LEFT).get(Customer_.id))); + } + } + return specification; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/SepaMandateService.java b/src/main/java/org/hostsharing/hsadminng/service/SepaMandateService.java new file mode 100644 index 00000000..fc59fb57 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/SepaMandateService.java @@ -0,0 +1,84 @@ +package org.hostsharing.hsadminng.service; + +import org.hostsharing.hsadminng.domain.SepaMandate; +import org.hostsharing.hsadminng.repository.SepaMandateRepository; +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; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing SepaMandate. + */ +@Service +@Transactional +public class SepaMandateService { + + private final Logger log = LoggerFactory.getLogger(SepaMandateService.class); + + private final SepaMandateRepository sepaMandateRepository; + + private final SepaMandateMapper sepaMandateMapper; + + public SepaMandateService(SepaMandateRepository sepaMandateRepository, SepaMandateMapper sepaMandateMapper) { + this.sepaMandateRepository = sepaMandateRepository; + this.sepaMandateMapper = sepaMandateMapper; + } + + /** + * Save a sepaMandate. + * + * @param sepaMandateDTO the entity to save + * @return the persisted entity + */ + public SepaMandateDTO save(SepaMandateDTO sepaMandateDTO) { + log.debug("Request to save SepaMandate : {}", sepaMandateDTO); + SepaMandate sepaMandate = sepaMandateMapper.toEntity(sepaMandateDTO); + sepaMandate = sepaMandateRepository.save(sepaMandate); + return sepaMandateMapper.toDto(sepaMandate); + } + + /** + * Get all the sepaMandates. + * + * @param pageable the pagination information + * @return the list of entities + */ + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all SepaMandates"); + return sepaMandateRepository.findAll(pageable) + .map(sepaMandateMapper::toDto); + } + + + /** + * Get one sepaMandate by id. + * + * @param id the id of the entity + * @return the entity + */ + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get SepaMandate : {}", id); + return sepaMandateRepository.findById(id) + .map(sepaMandateMapper::toDto); + } + + /** + * Delete the sepaMandate by id. + * + * @param id the id of the entity + */ + public void delete(Long id) { + log.debug("Request to delete SepaMandate : {}", id); + sepaMandateRepository.deleteById(id); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java new file mode 100644 index 00000000..7dcfb36c --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java @@ -0,0 +1,114 @@ +package org.hostsharing.hsadminng.service; + +import java.util.List; + +import javax.persistence.criteria.JoinType; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +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.Share; +import org.hostsharing.hsadminng.domain.*; // for static metamodels +import org.hostsharing.hsadminng.repository.ShareRepository; +import org.hostsharing.hsadminng.service.dto.ShareCriteria; +import org.hostsharing.hsadminng.service.dto.ShareDTO; +import org.hostsharing.hsadminng.service.mapper.ShareMapper; + +/** + * Service for executing complex queries for Share entities in the database. + * The main input is a {@link ShareCriteria} which gets converted to {@link Specification}, + * in a way that all the filters must apply. + * It returns a {@link List} of {@link ShareDTO} or a {@link Page} of {@link ShareDTO} which fulfills the criteria. + */ +@Service +@Transactional(readOnly = true) +public class ShareQueryService extends QueryService { + + private final Logger log = LoggerFactory.getLogger(ShareQueryService.class); + + private final ShareRepository shareRepository; + + private final ShareMapper shareMapper; + + public ShareQueryService(ShareRepository shareRepository, ShareMapper shareMapper) { + this.shareRepository = shareRepository; + this.shareMapper = shareMapper; + } + + /** + * Return a {@link List} of {@link ShareDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public List findByCriteria(ShareCriteria criteria) { + log.debug("find by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return shareMapper.toDto(shareRepository.findAll(specification)); + } + + /** + * Return a {@link Page} of {@link ShareDTO} which matches the criteria from the database + * @param criteria The object which holds all the filters, which the entities should match. + * @param page The page, which should be returned. + * @return the matching entities. + */ + @Transactional(readOnly = true) + public Page findByCriteria(ShareCriteria criteria, Pageable page) { + log.debug("find by criteria : {}, page: {}", criteria, page); + final Specification specification = createSpecification(criteria); + return shareRepository.findAll(specification, page) + .map(shareMapper::toDto); + } + + /** + * Return the number of matching entities in the database + * @param criteria The object which holds all the filters, which the entities should match. + * @return the number of matching entities. + */ + @Transactional(readOnly = true) + public long countByCriteria(ShareCriteria criteria) { + log.debug("count by criteria : {}", criteria); + final Specification specification = createSpecification(criteria); + return shareRepository.count(specification); + } + + /** + * Function to convert ShareCriteria to a {@link Specification} + */ + private Specification createSpecification(ShareCriteria criteria) { + Specification specification = Specification.where(null); + if (criteria != null) { + if (criteria.getId() != null) { + specification = specification.and(buildSpecification(criteria.getId(), Share_.id)); + } + if (criteria.getDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), Share_.documentDate)); + } + if (criteria.getValueDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValueDate(), Share_.valueDate)); + } + if (criteria.getAction() != null) { + specification = specification.and(buildSpecification(criteria.getAction(), Share_.action)); + } + if (criteria.getQuantity() != null) { + specification = specification.and(buildRangeSpecification(criteria.getQuantity(), Share_.quantity)); + } + if (criteria.getRemark() != null) { + specification = specification.and(buildStringSpecification(criteria.getRemark(), Share_.remark)); + } + if (criteria.getMembershipId() != null) { + specification = specification.and(buildSpecification(criteria.getMembershipId(), + root -> root.join(Share_.membership, JoinType.LEFT).get(Membership_.id))); + } + } + return specification; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/ShareService.java b/src/main/java/org/hostsharing/hsadminng/service/ShareService.java new file mode 100644 index 00000000..925deb7e --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/ShareService.java @@ -0,0 +1,84 @@ +package org.hostsharing.hsadminng.service; + +import org.hostsharing.hsadminng.domain.Share; +import org.hostsharing.hsadminng.repository.ShareRepository; +import org.hostsharing.hsadminng.service.dto.ShareDTO; +import org.hostsharing.hsadminng.service.mapper.ShareMapper; +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; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing Share. + */ +@Service +@Transactional +public class ShareService { + + private final Logger log = LoggerFactory.getLogger(ShareService.class); + + private final ShareRepository shareRepository; + + private final ShareMapper shareMapper; + + public ShareService(ShareRepository shareRepository, ShareMapper shareMapper) { + this.shareRepository = shareRepository; + this.shareMapper = shareMapper; + } + + /** + * Save a share. + * + * @param shareDTO the entity to save + * @return the persisted entity + */ + public ShareDTO save(ShareDTO shareDTO) { + log.debug("Request to save Share : {}", shareDTO); + Share share = shareMapper.toEntity(shareDTO); + share = shareRepository.save(share); + return shareMapper.toDto(share); + } + + /** + * Get all the shares. + * + * @param pageable the pagination information + * @return the list of entities + */ + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all Shares"); + return shareRepository.findAll(pageable) + .map(shareMapper::toDto); + } + + + /** + * Get one share by id. + * + * @param id the id of the entity + * @return the entity + */ + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Share : {}", id); + return shareRepository.findById(id) + .map(shareMapper::toDto); + } + + /** + * Delete the share by id. + * + * @param id the id of the entity + */ + public void delete(Long id) { + log.debug("Request to delete Share : {}", id); + shareRepository.deleteById(id); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java new file mode 100644 index 00000000..fe0091fc --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java @@ -0,0 +1,149 @@ +package org.hostsharing.hsadminng.service.dto; + +import java.io.Serializable; +import java.util.Objects; +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; +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.BigDecimalFilter; +import io.github.jhipster.service.filter.LocalDateFilter; + +/** + * Criteria class for the Asset entity. This class is used in AssetResource to + * receive all the possible filtering options from the Http GET request parameters. + * For example the following could be a valid requests: + * /assets?id.greaterThan=5&attr1.contains=something&attr2.specified=false + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +public class AssetCriteria implements Serializable { + /** + * Class for filtering AssetAction + */ + public static class AssetActionFilter extends Filter { + } + + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private LocalDateFilter documentDate; + + private LocalDateFilter valueDate; + + private AssetActionFilter action; + + private BigDecimalFilter amount; + + private StringFilter remark; + + private LongFilter membershipId; + + public LongFilter getId() { + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public LocalDateFilter getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDateFilter documentDate) { + this.documentDate = documentDate; + } + + public LocalDateFilter getValueDate() { + return valueDate; + } + + public void setValueDate(LocalDateFilter valueDate) { + this.valueDate = valueDate; + } + + public AssetActionFilter getAction() { + return action; + } + + public void setAction(AssetActionFilter action) { + this.action = action; + } + + public BigDecimalFilter getAmount() { + return amount; + } + + public void setAmount(BigDecimalFilter amount) { + this.amount = amount; + } + + public StringFilter getRemark() { + return remark; + } + + public void setRemark(StringFilter remark) { + this.remark = remark; + } + + public LongFilter getMembershipId() { + return membershipId; + } + + public void setMembershipId(LongFilter membershipId) { + this.membershipId = membershipId; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AssetCriteria that = (AssetCriteria) o; + return + Objects.equals(id, that.id) && + Objects.equals(documentDate, that.documentDate) && + Objects.equals(valueDate, that.valueDate) && + Objects.equals(action, that.action) && + Objects.equals(amount, that.amount) && + Objects.equals(remark, that.remark) && + Objects.equals(membershipId, that.membershipId); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + documentDate, + valueDate, + action, + amount, + remark, + membershipId + ); + } + + @Override + public String toString() { + return "AssetCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (documentDate != null ? "documentDate=" + documentDate + ", " : "") + + (valueDate != null ? "valueDate=" + valueDate + ", " : "") + + (action != null ? "action=" + action + ", " : "") + + (amount != null ? "amount=" + amount + ", " : "") + + (remark != null ? "remark=" + remark + ", " : "") + + (membershipId != null ? "membershipId=" + membershipId + ", " : "") + + "}"; + } + +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java new file mode 100644 index 00000000..db7570af --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java @@ -0,0 +1,134 @@ +package org.hostsharing.hsadminng.service.dto; +import java.time.LocalDate; +import javax.validation.constraints.*; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Objects; +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; + +/** + * A DTO for the Asset entity. + */ +public class AssetDTO implements Serializable { + + private Long id; + + @NotNull + private LocalDate documentDate; + + @NotNull + private LocalDate valueDate; + + @NotNull + private AssetAction action; + + @NotNull + private BigDecimal amount; + + @Size(max = 160) + private String remark; + + + private Long membershipId; + + private String membershipAdmissionDocumentDate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDate getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValueDate() { + return valueDate; + } + + public void setValueDate(LocalDate valueDate) { + this.valueDate = valueDate; + } + + public AssetAction getAction() { + return action; + } + + public void setAction(AssetAction action) { + this.action = action; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Long getMembershipId() { + return membershipId; + } + + public void setMembershipId(Long membershipId) { + this.membershipId = membershipId; + } + + public String getMembershipAdmissionDocumentDate() { + return membershipAdmissionDocumentDate; + } + + public void setMembershipAdmissionDocumentDate(String membershipAdmissionDocumentDate) { + this.membershipAdmissionDocumentDate = membershipAdmissionDocumentDate; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + AssetDTO assetDTO = (AssetDTO) o; + if (assetDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), assetDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "AssetDTO{" + + "id=" + getId() + + ", documentDate='" + getDocumentDate() + "'" + + ", valueDate='" + getValueDate() + "'" + + ", action='" + getAction() + "'" + + ", amount=" + getAmount() + + ", remark='" + getRemark() + "'" + + ", membership=" + getMembershipId() + + ", 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 new file mode 100644 index 00000000..dce18ff4 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java @@ -0,0 +1,297 @@ +package org.hostsharing.hsadminng.service.dto; + +import java.io.Serializable; +import java.util.Objects; +import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; +import org.hostsharing.hsadminng.domain.enumeration.VatRegion; +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 Customer entity. This class is used in CustomerResource to + * receive all the possible filtering options from the Http GET request parameters. + * For example the following could be a valid requests: + * /customers?id.greaterThan=5&attr1.contains=something&attr2.specified=false + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * 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; + + private LongFilter id; + + private IntegerFilter reference; + + private StringFilter prefix; + + 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; + + private StringFilter billingSalutation; + + private StringFilter billingAddress; + + private StringFilter remark; + + private LongFilter membershipId; + + private LongFilter sepamandateId; + + public LongFilter getId() { + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public IntegerFilter getReference() { + return reference; + } + + public void setReference(IntegerFilter reference) { + this.reference = reference; + } + + public StringFilter getPrefix() { + return prefix; + } + + public void setPrefix(StringFilter prefix) { + this.prefix = prefix; + } + + public StringFilter getName() { + return name; + } + + public void setName(StringFilter name) { + 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; + } + + public void setContractualSalutation(StringFilter contractualSalutation) { + this.contractualSalutation = contractualSalutation; + } + + public StringFilter getContractualAddress() { + return contractualAddress; + } + + public void setContractualAddress(StringFilter contractualAddress) { + this.contractualAddress = contractualAddress; + } + + public StringFilter getBillingSalutation() { + return billingSalutation; + } + + public void setBillingSalutation(StringFilter billingSalutation) { + this.billingSalutation = billingSalutation; + } + + public StringFilter getBillingAddress() { + return billingAddress; + } + + public void setBillingAddress(StringFilter billingAddress) { + this.billingAddress = billingAddress; + } + + public StringFilter getRemark() { + return remark; + } + + public void setRemark(StringFilter remark) { + this.remark = remark; + } + + public LongFilter getMembershipId() { + return membershipId; + } + + public void setMembershipId(LongFilter membershipId) { + this.membershipId = membershipId; + } + + public LongFilter getSepamandateId() { + return sepamandateId; + } + + public void setSepamandateId(LongFilter sepamandateId) { + this.sepamandateId = sepamandateId; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CustomerCriteria that = (CustomerCriteria) o; + return + Objects.equals(id, that.id) && + 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) && + Objects.equals(billingAddress, that.billingAddress) && + Objects.equals(remark, that.remark) && + Objects.equals(membershipId, that.membershipId) && + Objects.equals(sepamandateId, that.sepamandateId); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + reference, + prefix, + name, + kind, + birthDate, + birthPlace, + registrationCourt, + registrationNumber, + vatRegion, + vatNumber, + contractualSalutation, + contractualAddress, + billingSalutation, + billingAddress, + remark, + membershipId, + sepamandateId + ); + } + + @Override + public String toString() { + return "CustomerCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (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 + ", " : "") + + (billingAddress != null ? "billingAddress=" + billingAddress + ", " : "") + + (remark != null ? "remark=" + remark + ", " : "") + + (membershipId != null ? "membershipId=" + membershipId + ", " : "") + + (sepamandateId != null ? "sepamandateId=" + sepamandateId + ", " : "") + + "}"; + } + +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java new file mode 100644 index 00000000..2d0fdfdb --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java @@ -0,0 +1,237 @@ +package org.hostsharing.hsadminng.service.dto; +import java.time.LocalDate; +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; +import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; +import org.hostsharing.hsadminng.domain.enumeration.VatRegion; + +/** + * A DTO for the Customer entity. + */ +public class CustomerDTO implements Serializable { + + private Long id; + + @NotNull + @Min(value = 10000) + @Max(value = 99999) + private Integer reference; + + @NotNull + @Size(max = 3) + @Pattern(regexp = "[a-z][a-z0-9]+") + private String prefix; + + @NotNull + @Size(max = 80) + 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) + private String contractualSalutation; + + @NotNull + @Size(max = 400) + private String contractualAddress; + + @Size(max = 80) + private String billingSalutation; + + @Size(max = 400) + private String billingAddress; + + @Size(max = 160) + private String remark; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Integer getReference() { + return reference; + } + + public void setReference(Integer reference) { + this.reference = reference; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getName() { + return name; + } + + public void setName(String name) { + 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; + } + + public void setContractualSalutation(String contractualSalutation) { + this.contractualSalutation = contractualSalutation; + } + + public String getContractualAddress() { + return contractualAddress; + } + + public void setContractualAddress(String contractualAddress) { + this.contractualAddress = contractualAddress; + } + + public String getBillingSalutation() { + return billingSalutation; + } + + public void setBillingSalutation(String billingSalutation) { + this.billingSalutation = billingSalutation; + } + + public String getBillingAddress() { + return billingAddress; + } + + public void setBillingAddress(String billingAddress) { + this.billingAddress = billingAddress; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + CustomerDTO customerDTO = (CustomerDTO) o; + if (customerDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), customerDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "CustomerDTO{" + + "id=" + getId() + + ", 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() + "'" + + ", billingAddress='" + getBillingAddress() + "'" + + ", remark='" + getRemark() + "'" + + "}"; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java new file mode 100644 index 00000000..8e29c98f --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java @@ -0,0 +1,168 @@ +package org.hostsharing.hsadminng.service.dto; + +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 + * receive all the possible filtering options from the Http GET request parameters. + * For example the following could be a valid requests: + * /memberships?id.greaterThan=5&attr1.contains=something&attr2.specified=false + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +public class MembershipCriteria implements Serializable { + + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private LocalDateFilter admissionDocumentDate; + + private LocalDateFilter cancellationDocumentDate; + + private LocalDateFilter memberFromDate; + + private LocalDateFilter memberUntilDate; + + private StringFilter remark; + + private LongFilter shareId; + + private LongFilter assetId; + + private LongFilter customerId; + + public LongFilter getId() { + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public LocalDateFilter getAdmissionDocumentDate() { + return admissionDocumentDate; + } + + public void setAdmissionDocumentDate(LocalDateFilter admissionDocumentDate) { + this.admissionDocumentDate = admissionDocumentDate; + } + + public LocalDateFilter getCancellationDocumentDate() { + return cancellationDocumentDate; + } + + public void setCancellationDocumentDate(LocalDateFilter cancellationDocumentDate) { + this.cancellationDocumentDate = cancellationDocumentDate; + } + + public LocalDateFilter getMemberFromDate() { + return memberFromDate; + } + + public void setMemberFromDate(LocalDateFilter memberFromDate) { + this.memberFromDate = memberFromDate; + } + + public LocalDateFilter getMemberUntilDate() { + return memberUntilDate; + } + + public void setMemberUntilDate(LocalDateFilter memberUntilDate) { + this.memberUntilDate = memberUntilDate; + } + + public StringFilter getRemark() { + return remark; + } + + public void setRemark(StringFilter remark) { + this.remark = remark; + } + + public LongFilter getShareId() { + return shareId; + } + + public void setShareId(LongFilter shareId) { + this.shareId = shareId; + } + + public LongFilter getAssetId() { + return assetId; + } + + public void setAssetId(LongFilter assetId) { + this.assetId = assetId; + } + + public LongFilter getCustomerId() { + return customerId; + } + + public void setCustomerId(LongFilter customerId) { + this.customerId = customerId; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final MembershipCriteria that = (MembershipCriteria) o; + return + Objects.equals(id, that.id) && + 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) && + Objects.equals(customerId, that.customerId); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + admissionDocumentDate, + cancellationDocumentDate, + memberFromDate, + memberUntilDate, + remark, + shareId, + assetId, + customerId + ); + } + + @Override + public String toString() { + return "MembershipCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (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 + ", " : "") + + (customerId != null ? "customerId=" + customerId + ", " : "") + + "}"; + } + +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java new file mode 100644 index 00000000..a1523891 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java @@ -0,0 +1,130 @@ +package org.hostsharing.hsadminng.service.dto; +import java.time.LocalDate; +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; + +/** + * A DTO for the Membership entity. + */ +public class MembershipDTO implements Serializable { + + private Long id; + + @NotNull + private LocalDate admissionDocumentDate; + + private LocalDate cancellationDocumentDate; + + @NotNull + private LocalDate memberFromDate; + + private LocalDate memberUntilDate; + + @Size(max = 160) + private String remark; + + + private Long customerId; + + private String customerPrefix; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDate getAdmissionDocumentDate() { + return admissionDocumentDate; + } + + public void setAdmissionDocumentDate(LocalDate admissionDocumentDate) { + this.admissionDocumentDate = admissionDocumentDate; + } + + public LocalDate getCancellationDocumentDate() { + return cancellationDocumentDate; + } + + public void setCancellationDocumentDate(LocalDate cancellationDocumentDate) { + this.cancellationDocumentDate = cancellationDocumentDate; + } + + public LocalDate getMemberFromDate() { + return memberFromDate; + } + + public void setMemberFromDate(LocalDate memberFromDate) { + this.memberFromDate = memberFromDate; + } + + public LocalDate getMemberUntilDate() { + return memberUntilDate; + } + + public void setMemberUntilDate(LocalDate memberUntilDate) { + this.memberUntilDate = memberUntilDate; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Long getCustomerId() { + return customerId; + } + + public void setCustomerId(Long customerId) { + this.customerId = customerId; + } + + public String getCustomerPrefix() { + return customerPrefix; + } + + public void setCustomerPrefix(String customerPrefix) { + this.customerPrefix = customerPrefix; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + MembershipDTO membershipDTO = (MembershipDTO) o; + if (membershipDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), membershipDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "MembershipDTO{" + + "id=" + getId() + + ", 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 new file mode 100644 index 00000000..9b3a4fe1 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateCriteria.java @@ -0,0 +1,194 @@ +package org.hostsharing.hsadminng.service.dto; + +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 + * receive all the possible filtering options from the Http GET request parameters. + * For example the following could be a valid requests: + * /sepa-mandates?id.greaterThan=5&attr1.contains=something&attr2.specified=false + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +public class SepaMandateCriteria implements Serializable { + + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private StringFilter reference; + + private StringFilter iban; + + private StringFilter bic; + + private LocalDateFilter grantingDocumentDate; + + private LocalDateFilter revokationDocumentDate; + + private LocalDateFilter validFromDate; + + private LocalDateFilter validUntilDate; + + private LocalDateFilter lastUsedDate; + + private StringFilter remark; + + private LongFilter customerId; + + public LongFilter getId() { + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public StringFilter getReference() { + return reference; + } + + public void setReference(StringFilter reference) { + this.reference = reference; + } + + public StringFilter getIban() { + return iban; + } + + public void setIban(StringFilter iban) { + this.iban = iban; + } + + public StringFilter getBic() { + return bic; + } + + public void setBic(StringFilter bic) { + this.bic = bic; + } + + public LocalDateFilter getGrantingDocumentDate() { + return grantingDocumentDate; + } + + public void setGrantingDocumentDate(LocalDateFilter grantingDocumentDate) { + this.grantingDocumentDate = grantingDocumentDate; + } + + public LocalDateFilter getRevokationDocumentDate() { + return revokationDocumentDate; + } + + public void setRevokationDocumentDate(LocalDateFilter revokationDocumentDate) { + this.revokationDocumentDate = revokationDocumentDate; + } + + public LocalDateFilter getValidFromDate() { + return validFromDate; + } + + public void setValidFromDate(LocalDateFilter validFromDate) { + this.validFromDate = validFromDate; + } + + public LocalDateFilter getValidUntilDate() { + return validUntilDate; + } + + public void setValidUntilDate(LocalDateFilter validUntilDate) { + this.validUntilDate = validUntilDate; + } + + public LocalDateFilter getLastUsedDate() { + return lastUsedDate; + } + + public void setLastUsedDate(LocalDateFilter lastUsedDate) { + this.lastUsedDate = lastUsedDate; + } + + public StringFilter getRemark() { + return remark; + } + + public void setRemark(StringFilter remark) { + this.remark = remark; + } + + public LongFilter getCustomerId() { + return customerId; + } + + public void setCustomerId(LongFilter customerId) { + this.customerId = customerId; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final SepaMandateCriteria that = (SepaMandateCriteria) o; + return + Objects.equals(id, that.id) && + Objects.equals(reference, that.reference) && + Objects.equals(iban, that.iban) && + Objects.equals(bic, that.bic) && + 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); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + reference, + iban, + bic, + grantingDocumentDate, + revokationDocumentDate, + validFromDate, + validUntilDate, + lastUsedDate, + remark, + customerId + ); + } + + @Override + public String toString() { + return "SepaMandateCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (reference != null ? "reference=" + reference + ", " : "") + + (iban != null ? "iban=" + iban + ", " : "") + + (bic != null ? "bic=" + bic + ", " : "") + + (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 new file mode 100644 index 00000000..1867c642 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java @@ -0,0 +1,178 @@ +package org.hostsharing.hsadminng.service.dto; +import java.time.LocalDate; +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; + +/** + * A DTO for the SepaMandate entity. + */ +public class SepaMandateDTO implements Serializable { + + private Long id; + + @NotNull + @Size(max = 40) + private String reference; + + @Size(max = 34) + private String iban; + + @Size(max = 11) + private String bic; + + @NotNull + private LocalDate grantingDocumentDate; + + private LocalDate revokationDocumentDate; + + @NotNull + private LocalDate validFromDate; + + private LocalDate validUntilDate; + + private LocalDate lastUsedDate; + + @Size(max = 160) + private String remark; + + + private Long customerId; + + private String customerPrefix; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getIban() { + return iban; + } + + public void setIban(String iban) { + this.iban = iban; + } + + public String getBic() { + return bic; + } + + public void setBic(String bic) { + this.bic = bic; + } + + public LocalDate getGrantingDocumentDate() { + return grantingDocumentDate; + } + + public void setGrantingDocumentDate(LocalDate grantingDocumentDate) { + this.grantingDocumentDate = grantingDocumentDate; + } + + public LocalDate getRevokationDocumentDate() { + return revokationDocumentDate; + } + + public void setRevokationDocumentDate(LocalDate revokationDocumentDate) { + this.revokationDocumentDate = revokationDocumentDate; + } + + public LocalDate getValidFromDate() { + return validFromDate; + } + + public void setValidFromDate(LocalDate validFromDate) { + this.validFromDate = validFromDate; + } + + public LocalDate getValidUntilDate() { + return validUntilDate; + } + + public void setValidUntilDate(LocalDate validUntilDate) { + this.validUntilDate = validUntilDate; + } + + public LocalDate getLastUsedDate() { + return lastUsedDate; + } + + public void setLastUsedDate(LocalDate lastUsedDate) { + this.lastUsedDate = lastUsedDate; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Long getCustomerId() { + return customerId; + } + + public void setCustomerId(Long customerId) { + this.customerId = customerId; + } + + public String getCustomerPrefix() { + return customerPrefix; + } + + public void setCustomerPrefix(String customerPrefix) { + this.customerPrefix = customerPrefix; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SepaMandateDTO sepaMandateDTO = (SepaMandateDTO) o; + if (sepaMandateDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), sepaMandateDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "SepaMandateDTO{" + + "id=" + getId() + + ", reference='" + getReference() + "'" + + ", iban='" + getIban() + "'" + + ", bic='" + getBic() + "'" + + ", 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/ShareCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java new file mode 100644 index 00000000..313be4d3 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java @@ -0,0 +1,148 @@ +package org.hostsharing.hsadminng.service.dto; + +import java.io.Serializable; +import java.util.Objects; +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; +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 Share entity. This class is used in ShareResource to + * receive all the possible filtering options from the Http GET request parameters. + * For example the following could be a valid requests: + * /shares?id.greaterThan=5&attr1.contains=something&attr2.specified=false + * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use + * fix type specific filters. + */ +public class ShareCriteria implements Serializable { + /** + * Class for filtering ShareAction + */ + public static class ShareActionFilter extends Filter { + } + + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private LocalDateFilter documentDate; + + private LocalDateFilter valueDate; + + private ShareActionFilter action; + + private IntegerFilter quantity; + + private StringFilter remark; + + private LongFilter membershipId; + + public LongFilter getId() { + return id; + } + + public void setId(LongFilter id) { + this.id = id; + } + + public LocalDateFilter getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDateFilter documentDate) { + this.documentDate = documentDate; + } + + public LocalDateFilter getValueDate() { + return valueDate; + } + + public void setValueDate(LocalDateFilter valueDate) { + this.valueDate = valueDate; + } + + public ShareActionFilter getAction() { + return action; + } + + public void setAction(ShareActionFilter action) { + this.action = action; + } + + public IntegerFilter getQuantity() { + return quantity; + } + + public void setQuantity(IntegerFilter quantity) { + this.quantity = quantity; + } + + public StringFilter getRemark() { + return remark; + } + + public void setRemark(StringFilter remark) { + this.remark = remark; + } + + public LongFilter getMembershipId() { + return membershipId; + } + + public void setMembershipId(LongFilter membershipId) { + this.membershipId = membershipId; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ShareCriteria that = (ShareCriteria) o; + return + Objects.equals(id, that.id) && + Objects.equals(documentDate, that.documentDate) && + Objects.equals(valueDate, that.valueDate) && + Objects.equals(action, that.action) && + Objects.equals(quantity, that.quantity) && + Objects.equals(remark, that.remark) && + Objects.equals(membershipId, that.membershipId); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + documentDate, + valueDate, + action, + quantity, + remark, + membershipId + ); + } + + @Override + public String toString() { + return "ShareCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (documentDate != null ? "documentDate=" + documentDate + ", " : "") + + (valueDate != null ? "valueDate=" + valueDate + ", " : "") + + (action != null ? "action=" + action + ", " : "") + + (quantity != null ? "quantity=" + quantity + ", " : "") + + (remark != null ? "remark=" + remark + ", " : "") + + (membershipId != null ? "membershipId=" + membershipId + ", " : "") + + "}"; + } + +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java new file mode 100644 index 00000000..d4d7ef2d --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java @@ -0,0 +1,133 @@ +package org.hostsharing.hsadminng.service.dto; +import java.time.LocalDate; +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; + +/** + * A DTO for the Share entity. + */ +public class ShareDTO implements Serializable { + + private Long id; + + @NotNull + private LocalDate documentDate; + + @NotNull + private LocalDate valueDate; + + @NotNull + private ShareAction action; + + @NotNull + private Integer quantity; + + @Size(max = 160) + private String remark; + + + private Long membershipId; + + private String membershipAdmissionDocumentDate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDate getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValueDate() { + return valueDate; + } + + public void setValueDate(LocalDate valueDate) { + this.valueDate = valueDate; + } + + public ShareAction getAction() { + return action; + } + + public void setAction(ShareAction action) { + this.action = action; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Long getMembershipId() { + return membershipId; + } + + public void setMembershipId(Long membershipId) { + this.membershipId = membershipId; + } + + public String getMembershipAdmissionDocumentDate() { + return membershipAdmissionDocumentDate; + } + + public void setMembershipAdmissionDocumentDate(String membershipAdmissionDocumentDate) { + this.membershipAdmissionDocumentDate = membershipAdmissionDocumentDate; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + ShareDTO shareDTO = (ShareDTO) o; + if (shareDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), shareDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "ShareDTO{" + + "id=" + getId() + + ", documentDate='" + getDocumentDate() + "'" + + ", valueDate='" + getValueDate() + "'" + + ", action='" + getAction() + "'" + + ", quantity=" + getQuantity() + + ", remark='" + getRemark() + "'" + + ", membership=" + getMembershipId() + + ", 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 new file mode 100644 index 00000000..95ee103d --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java @@ -0,0 +1,29 @@ +package org.hostsharing.hsadminng.service.mapper; + +import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.service.dto.AssetDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity Asset and its DTO AssetDTO. + */ +@Mapper(componentModel = "spring", uses = {MembershipMapper.class}) +public interface AssetMapper extends EntityMapper { + + @Mapping(source = "membership.id", target = "membershipId") + @Mapping(source = "membership.admissionDocumentDate", target = "membershipAdmissionDocumentDate") + AssetDTO toDto(Asset asset); + + @Mapping(source = "membershipId", target = "membership") + Asset toEntity(AssetDTO assetDTO); + + default Asset fromId(Long id) { + if (id == null) { + return null; + } + Asset asset = new Asset(); + asset.setId(id); + return asset; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java new file mode 100644 index 00000000..6c9c204a --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java @@ -0,0 +1,27 @@ +package org.hostsharing.hsadminng.service.mapper; + +import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.service.dto.CustomerDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity Customer and its DTO CustomerDTO. + */ +@Mapper(componentModel = "spring", uses = {}) +public interface CustomerMapper extends EntityMapper { + + + @Mapping(target = "memberships", ignore = true) + @Mapping(target = "sepamandates", ignore = true) + Customer toEntity(CustomerDTO customerDTO); + + default Customer fromId(Long id) { + if (id == null) { + return null; + } + Customer customer = new Customer(); + customer.setId(id); + return customer; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/EntityMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/EntityMapper.java new file mode 100644 index 00000000..65955272 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/EntityMapper.java @@ -0,0 +1,21 @@ +package org.hostsharing.hsadminng.service.mapper; + +import java.util.List; + +/** + * Contract for a generic dto to entity mapper. + * + * @param - DTO type parameter. + * @param - Entity type parameter. + */ + +public interface EntityMapper { + + E toEntity(D dto); + + D toDto(E entity); + + List toEntity(List dtoList); + + List toDto(List entityList); +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java new file mode 100644 index 00000000..02a45ace --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java @@ -0,0 +1,31 @@ +package org.hostsharing.hsadminng.service.mapper; + +import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.service.dto.MembershipDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity Membership and its DTO MembershipDTO. + */ +@Mapper(componentModel = "spring", uses = {CustomerMapper.class}) +public interface MembershipMapper extends EntityMapper { + + @Mapping(source = "customer.id", target = "customerId") + @Mapping(source = "customer.prefix", target = "customerPrefix") + MembershipDTO toDto(Membership membership); + + @Mapping(target = "shares", ignore = true) + @Mapping(target = "assets", ignore = true) + @Mapping(source = "customerId", target = "customer") + Membership toEntity(MembershipDTO membershipDTO); + + default Membership fromId(Long id) { + if (id == null) { + return null; + } + Membership membership = new Membership(); + membership.setId(id); + return membership; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/SepaMandateMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/SepaMandateMapper.java new file mode 100644 index 00000000..cf92eae4 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/SepaMandateMapper.java @@ -0,0 +1,29 @@ +package org.hostsharing.hsadminng.service.mapper; + +import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.service.dto.SepaMandateDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity SepaMandate and its DTO SepaMandateDTO. + */ +@Mapper(componentModel = "spring", uses = {CustomerMapper.class}) +public interface SepaMandateMapper extends EntityMapper { + + @Mapping(source = "customer.id", target = "customerId") + @Mapping(source = "customer.prefix", target = "customerPrefix") + SepaMandateDTO toDto(SepaMandate sepaMandate); + + @Mapping(source = "customerId", target = "customer") + SepaMandate toEntity(SepaMandateDTO sepaMandateDTO); + + default SepaMandate fromId(Long id) { + if (id == null) { + return null; + } + SepaMandate sepaMandate = new SepaMandate(); + sepaMandate.setId(id); + return sepaMandate; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java new file mode 100644 index 00000000..c7a85ab8 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java @@ -0,0 +1,29 @@ +package org.hostsharing.hsadminng.service.mapper; + +import org.hostsharing.hsadminng.domain.*; +import org.hostsharing.hsadminng.service.dto.ShareDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity Share and its DTO ShareDTO. + */ +@Mapper(componentModel = "spring", uses = {MembershipMapper.class}) +public interface ShareMapper extends EntityMapper { + + @Mapping(source = "membership.id", target = "membershipId") + @Mapping(source = "membership.admissionDocumentDate", target = "membershipAdmissionDocumentDate") + ShareDTO toDto(Share share); + + @Mapping(source = "membershipId", target = "membership") + Share toEntity(ShareDTO shareDTO); + + default Share fromId(Long id) { + if (id == null) { + return null; + } + Share share = new Share(); + share.setId(id); + return share; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java new file mode 100644 index 00000000..3e142f28 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java @@ -0,0 +1,138 @@ +package org.hostsharing.hsadminng.web.rest; +import org.hostsharing.hsadminng.service.AssetService; +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; + +/** + * REST controller for managing Asset. + */ +@RestController +@RequestMapping("/api") +public class AssetResource { + + private final Logger log = LoggerFactory.getLogger(AssetResource.class); + + private static final String ENTITY_NAME = "asset"; + + private final AssetService assetService; + + private final AssetQueryService assetQueryService; + + public AssetResource(AssetService assetService, AssetQueryService assetQueryService) { + this.assetService = assetService; + this.assetQueryService = assetQueryService; + } + + /** + * POST /assets : Create a new asset. + * + * @param assetDTO the assetDTO to create + * @return the ResponseEntity with status 201 (Created) and with body the new assetDTO, or with status 400 (Bad Request) if the asset has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/assets") + public ResponseEntity createAsset(@Valid @RequestBody AssetDTO assetDTO) throws URISyntaxException { + log.debug("REST request to save Asset : {}", assetDTO); + if (assetDTO.getId() != null) { + throw new BadRequestAlertException("A new asset cannot already have an ID", ENTITY_NAME, "idexists"); + } + AssetDTO result = assetService.save(assetDTO); + return ResponseEntity.created(new URI("/api/assets/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /assets : Updates an existing asset. + * + * @param assetDTO the assetDTO to update + * @return the ResponseEntity with status 200 (OK) and with body the updated assetDTO, + * or with status 400 (Bad Request) if the assetDTO is not valid, + * or with status 500 (Internal Server Error) if the assetDTO couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @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); + } + + /** + * GET /assets : get all the assets. + * + * @param pageable the pagination information + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the list of assets in body + */ + @GetMapping("/assets") + public ResponseEntity> getAllAssets(AssetCriteria criteria, Pageable pageable) { + log.debug("REST request to get Assets by criteria: {}", criteria); + Page page = assetQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/assets"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * GET /assets/count : count all the assets. + * + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the count in body + */ + @GetMapping("/assets/count") + public ResponseEntity countAssets(AssetCriteria criteria) { + log.debug("REST request to count Assets by criteria: {}", criteria); + return ResponseEntity.ok().body(assetQueryService.countByCriteria(criteria)); + } + + /** + * GET /assets/:id : get the "id" asset. + * + * @param id the id of the assetDTO to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the assetDTO, or with status 404 (Not Found) + */ + @GetMapping("/assets/{id}") + public ResponseEntity getAsset(@PathVariable Long id) { + log.debug("REST request to get Asset : {}", id); + Optional assetDTO = assetService.findOne(id); + return ResponseUtil.wrapOrNotFound(assetDTO); + } + + /** + * DELETE /assets/:id : delete the "id" asset. + * + * @param id the id of the assetDTO to delete + * @return the ResponseEntity with status 200 (OK) + */ + @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(); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerResource.java new file mode 100644 index 00000000..aa5e3710 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerResource.java @@ -0,0 +1,138 @@ +package org.hostsharing.hsadminng.web.rest; +import org.hostsharing.hsadminng.service.CustomerService; +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.CustomerDTO; +import org.hostsharing.hsadminng.service.dto.CustomerCriteria; +import org.hostsharing.hsadminng.service.CustomerQueryService; +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; + +/** + * REST controller for managing Customer. + */ +@RestController +@RequestMapping("/api") +public class CustomerResource { + + private final Logger log = LoggerFactory.getLogger(CustomerResource.class); + + private static final String ENTITY_NAME = "customer"; + + private final CustomerService customerService; + + private final CustomerQueryService customerQueryService; + + public CustomerResource(CustomerService customerService, CustomerQueryService customerQueryService) { + this.customerService = customerService; + this.customerQueryService = customerQueryService; + } + + /** + * POST /customers : Create a new customer. + * + * @param customerDTO the customerDTO to create + * @return the ResponseEntity with status 201 (Created) and with body the new customerDTO, or with status 400 (Bad Request) if the customer has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/customers") + public ResponseEntity createCustomer(@Valid @RequestBody CustomerDTO customerDTO) throws URISyntaxException { + log.debug("REST request to save Customer : {}", customerDTO); + if (customerDTO.getId() != null) { + throw new BadRequestAlertException("A new customer cannot already have an ID", ENTITY_NAME, "idexists"); + } + CustomerDTO result = customerService.save(customerDTO); + return ResponseEntity.created(new URI("/api/customers/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /customers : Updates an existing customer. + * + * @param customerDTO the customerDTO to update + * @return the ResponseEntity with status 200 (OK) and with body the updated customerDTO, + * or with status 400 (Bad Request) if the customerDTO is not valid, + * or with status 500 (Internal Server Error) if the customerDTO couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/customers") + public ResponseEntity updateCustomer(@Valid @RequestBody CustomerDTO customerDTO) throws URISyntaxException { + log.debug("REST request to update Customer : {}", customerDTO); + if (customerDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + CustomerDTO result = customerService.save(customerDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, customerDTO.getId().toString())) + .body(result); + } + + /** + * GET /customers : get all the customers. + * + * @param pageable the pagination information + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the list of customers in body + */ + @GetMapping("/customers") + public ResponseEntity> getAllCustomers(CustomerCriteria criteria, Pageable pageable) { + log.debug("REST request to get Customers by criteria: {}", criteria); + Page page = customerQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/customers"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * GET /customers/count : count all the customers. + * + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the count in body + */ + @GetMapping("/customers/count") + public ResponseEntity countCustomers(CustomerCriteria criteria) { + log.debug("REST request to count Customers by criteria: {}", criteria); + return ResponseEntity.ok().body(customerQueryService.countByCriteria(criteria)); + } + + /** + * GET /customers/:id : get the "id" customer. + * + * @param id the id of the customerDTO to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the customerDTO, or with status 404 (Not Found) + */ + @GetMapping("/customers/{id}") + public ResponseEntity getCustomer(@PathVariable Long id) { + log.debug("REST request to get Customer : {}", id); + Optional customerDTO = customerService.findOne(id); + return ResponseUtil.wrapOrNotFound(customerDTO); + } + + /** + * DELETE /customers/:id : delete the "id" customer. + * + * @param id the id of the customerDTO to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/customers/{id}") + public ResponseEntity deleteCustomer(@PathVariable Long id) { + log.debug("REST request to delete Customer : {}", id); + customerService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/MembershipResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/MembershipResource.java new file mode 100644 index 00000000..befa075f --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/web/rest/MembershipResource.java @@ -0,0 +1,138 @@ +package org.hostsharing.hsadminng.web.rest; +import org.hostsharing.hsadminng.service.MembershipService; +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.MembershipDTO; +import org.hostsharing.hsadminng.service.dto.MembershipCriteria; +import org.hostsharing.hsadminng.service.MembershipQueryService; +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; + +/** + * REST controller for managing Membership. + */ +@RestController +@RequestMapping("/api") +public class MembershipResource { + + private final Logger log = LoggerFactory.getLogger(MembershipResource.class); + + private static final String ENTITY_NAME = "membership"; + + private final MembershipService membershipService; + + private final MembershipQueryService membershipQueryService; + + public MembershipResource(MembershipService membershipService, MembershipQueryService membershipQueryService) { + this.membershipService = membershipService; + this.membershipQueryService = membershipQueryService; + } + + /** + * POST /memberships : Create a new membership. + * + * @param membershipDTO the membershipDTO to create + * @return the ResponseEntity with status 201 (Created) and with body the new membershipDTO, or with status 400 (Bad Request) if the membership has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/memberships") + public ResponseEntity createMembership(@Valid @RequestBody MembershipDTO membershipDTO) throws URISyntaxException { + log.debug("REST request to save Membership : {}", membershipDTO); + if (membershipDTO.getId() != null) { + throw new BadRequestAlertException("A new membership cannot already have an ID", ENTITY_NAME, "idexists"); + } + MembershipDTO result = membershipService.save(membershipDTO); + return ResponseEntity.created(new URI("/api/memberships/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /memberships : Updates an existing membership. + * + * @param membershipDTO the membershipDTO to update + * @return the ResponseEntity with status 200 (OK) and with body the updated membershipDTO, + * or with status 400 (Bad Request) if the membershipDTO is not valid, + * or with status 500 (Internal Server Error) if the membershipDTO couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/memberships") + public ResponseEntity updateMembership(@Valid @RequestBody MembershipDTO membershipDTO) throws URISyntaxException { + log.debug("REST request to update Membership : {}", membershipDTO); + if (membershipDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + MembershipDTO result = membershipService.save(membershipDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, membershipDTO.getId().toString())) + .body(result); + } + + /** + * GET /memberships : get all the memberships. + * + * @param pageable the pagination information + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the list of memberships in body + */ + @GetMapping("/memberships") + public ResponseEntity> getAllMemberships(MembershipCriteria criteria, Pageable pageable) { + log.debug("REST request to get Memberships by criteria: {}", criteria); + Page page = membershipQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/memberships"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * GET /memberships/count : count all the memberships. + * + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the count in body + */ + @GetMapping("/memberships/count") + public ResponseEntity countMemberships(MembershipCriteria criteria) { + log.debug("REST request to count Memberships by criteria: {}", criteria); + return ResponseEntity.ok().body(membershipQueryService.countByCriteria(criteria)); + } + + /** + * GET /memberships/:id : get the "id" membership. + * + * @param id the id of the membershipDTO to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the membershipDTO, or with status 404 (Not Found) + */ + @GetMapping("/memberships/{id}") + public ResponseEntity getMembership(@PathVariable Long id) { + log.debug("REST request to get Membership : {}", id); + Optional membershipDTO = membershipService.findOne(id); + return ResponseUtil.wrapOrNotFound(membershipDTO); + } + + /** + * DELETE /memberships/:id : delete the "id" membership. + * + * @param id the id of the membershipDTO to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/memberships/{id}") + public ResponseEntity deleteMembership(@PathVariable Long id) { + log.debug("REST request to delete Membership : {}", id); + membershipService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/SepaMandateResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/SepaMandateResource.java new file mode 100644 index 00000000..246d845e --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/web/rest/SepaMandateResource.java @@ -0,0 +1,138 @@ +package org.hostsharing.hsadminng.web.rest; +import org.hostsharing.hsadminng.service.SepaMandateService; +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.SepaMandateDTO; +import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria; +import org.hostsharing.hsadminng.service.SepaMandateQueryService; +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; + +/** + * REST controller for managing SepaMandate. + */ +@RestController +@RequestMapping("/api") +public class SepaMandateResource { + + private final Logger log = LoggerFactory.getLogger(SepaMandateResource.class); + + private static final String ENTITY_NAME = "sepaMandate"; + + private final SepaMandateService sepaMandateService; + + private final SepaMandateQueryService sepaMandateQueryService; + + public SepaMandateResource(SepaMandateService sepaMandateService, SepaMandateQueryService sepaMandateQueryService) { + this.sepaMandateService = sepaMandateService; + this.sepaMandateQueryService = sepaMandateQueryService; + } + + /** + * POST /sepa-mandates : Create a new sepaMandate. + * + * @param sepaMandateDTO the sepaMandateDTO to create + * @return the ResponseEntity with status 201 (Created) and with body the new sepaMandateDTO, or with status 400 (Bad Request) if the sepaMandate has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/sepa-mandates") + public ResponseEntity createSepaMandate(@Valid @RequestBody SepaMandateDTO sepaMandateDTO) throws URISyntaxException { + log.debug("REST request to save SepaMandate : {}", sepaMandateDTO); + if (sepaMandateDTO.getId() != null) { + throw new BadRequestAlertException("A new sepaMandate cannot already have an ID", ENTITY_NAME, "idexists"); + } + SepaMandateDTO result = sepaMandateService.save(sepaMandateDTO); + return ResponseEntity.created(new URI("/api/sepa-mandates/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /sepa-mandates : Updates an existing sepaMandate. + * + * @param sepaMandateDTO the sepaMandateDTO to update + * @return the ResponseEntity with status 200 (OK) and with body the updated sepaMandateDTO, + * or with status 400 (Bad Request) if the sepaMandateDTO is not valid, + * or with status 500 (Internal Server Error) if the sepaMandateDTO couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/sepa-mandates") + public ResponseEntity updateSepaMandate(@Valid @RequestBody SepaMandateDTO sepaMandateDTO) throws URISyntaxException { + log.debug("REST request to update SepaMandate : {}", sepaMandateDTO); + if (sepaMandateDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + SepaMandateDTO result = sepaMandateService.save(sepaMandateDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, sepaMandateDTO.getId().toString())) + .body(result); + } + + /** + * GET /sepa-mandates : get all the sepaMandates. + * + * @param pageable the pagination information + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the list of sepaMandates in body + */ + @GetMapping("/sepa-mandates") + public ResponseEntity> getAllSepaMandates(SepaMandateCriteria criteria, Pageable pageable) { + log.debug("REST request to get SepaMandates by criteria: {}", criteria); + Page page = sepaMandateQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/sepa-mandates"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * GET /sepa-mandates/count : count all the sepaMandates. + * + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the count in body + */ + @GetMapping("/sepa-mandates/count") + public ResponseEntity countSepaMandates(SepaMandateCriteria criteria) { + log.debug("REST request to count SepaMandates by criteria: {}", criteria); + return ResponseEntity.ok().body(sepaMandateQueryService.countByCriteria(criteria)); + } + + /** + * GET /sepa-mandates/:id : get the "id" sepaMandate. + * + * @param id the id of the sepaMandateDTO to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the sepaMandateDTO, or with status 404 (Not Found) + */ + @GetMapping("/sepa-mandates/{id}") + public ResponseEntity getSepaMandate(@PathVariable Long id) { + log.debug("REST request to get SepaMandate : {}", id); + Optional sepaMandateDTO = sepaMandateService.findOne(id); + return ResponseUtil.wrapOrNotFound(sepaMandateDTO); + } + + /** + * DELETE /sepa-mandates/:id : delete the "id" sepaMandate. + * + * @param id the id of the sepaMandateDTO to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/sepa-mandates/{id}") + public ResponseEntity deleteSepaMandate(@PathVariable Long id) { + log.debug("REST request to delete SepaMandate : {}", id); + sepaMandateService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/ShareResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/ShareResource.java new file mode 100644 index 00000000..d7c2d2f2 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/web/rest/ShareResource.java @@ -0,0 +1,138 @@ +package org.hostsharing.hsadminng.web.rest; +import org.hostsharing.hsadminng.service.ShareService; +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.ShareDTO; +import org.hostsharing.hsadminng.service.dto.ShareCriteria; +import org.hostsharing.hsadminng.service.ShareQueryService; +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; + +/** + * REST controller for managing Share. + */ +@RestController +@RequestMapping("/api") +public class ShareResource { + + private final Logger log = LoggerFactory.getLogger(ShareResource.class); + + private static final String ENTITY_NAME = "share"; + + private final ShareService shareService; + + private final ShareQueryService shareQueryService; + + public ShareResource(ShareService shareService, ShareQueryService shareQueryService) { + this.shareService = shareService; + this.shareQueryService = shareQueryService; + } + + /** + * POST /shares : Create a new share. + * + * @param shareDTO the shareDTO to create + * @return the ResponseEntity with status 201 (Created) and with body the new shareDTO, or with status 400 (Bad Request) if the share has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/shares") + public ResponseEntity createShare(@Valid @RequestBody ShareDTO shareDTO) throws URISyntaxException { + log.debug("REST request to save Share : {}", shareDTO); + if (shareDTO.getId() != null) { + throw new BadRequestAlertException("A new share cannot already have an ID", ENTITY_NAME, "idexists"); + } + ShareDTO result = shareService.save(shareDTO); + return ResponseEntity.created(new URI("/api/shares/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /shares : Updates an existing share. + * + * @param shareDTO the shareDTO to update + * @return the ResponseEntity with status 200 (OK) and with body the updated shareDTO, + * or with status 400 (Bad Request) if the shareDTO is not valid, + * or with status 500 (Internal Server Error) if the shareDTO couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/shares") + public ResponseEntity updateShare(@Valid @RequestBody ShareDTO shareDTO) throws URISyntaxException { + log.debug("REST request to update Share : {}", shareDTO); + if (shareDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + ShareDTO result = shareService.save(shareDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, shareDTO.getId().toString())) + .body(result); + } + + /** + * GET /shares : get all the shares. + * + * @param pageable the pagination information + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the list of shares in body + */ + @GetMapping("/shares") + public ResponseEntity> getAllShares(ShareCriteria criteria, Pageable pageable) { + log.debug("REST request to get Shares by criteria: {}", criteria); + Page page = shareQueryService.findByCriteria(criteria, pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/shares"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * GET /shares/count : count all the shares. + * + * @param criteria the criterias which the requested entities should match + * @return the ResponseEntity with status 200 (OK) and the count in body + */ + @GetMapping("/shares/count") + public ResponseEntity countShares(ShareCriteria criteria) { + log.debug("REST request to count Shares by criteria: {}", criteria); + return ResponseEntity.ok().body(shareQueryService.countByCriteria(criteria)); + } + + /** + * GET /shares/:id : get the "id" share. + * + * @param id the id of the shareDTO to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the shareDTO, or with status 404 (Not Found) + */ + @GetMapping("/shares/{id}") + public ResponseEntity getShare(@PathVariable Long id) { + log.debug("REST request to get Share : {}", id); + Optional shareDTO = shareService.findOne(id); + return ResponseUtil.wrapOrNotFound(shareDTO); + } + + /** + * DELETE /shares/:id : delete the "id" share. + * + * @param id the id of the shareDTO to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/shares/{id}") + public ResponseEntity deleteShare(@PathVariable Long id) { + log.debug("REST request to delete Share : {}", id); + shareService.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} 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..3b855a94 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123255_added_entity_Customer.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..14a40ce1 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123256_added_entity_Membership.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..6e2bd896 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123257_added_entity_Share.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..4f7570bc --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123258_added_entity_Asset.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..aa602736 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190424123259_added_entity_SepaMandate.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 f2b0b1f7..f191c087 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -5,6 +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-delete-dialog.component.html b/src/main/webapp/app/entities/asset/asset-delete-dialog.component.html new file mode 100644 index 00000000..bd1b9f78 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/asset/asset-delete-dialog.component.ts b/src/main/webapp/app/entities/asset/asset-delete-dialog.component.ts new file mode 100644 index 00000000..ff1dd113 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IAsset } from 'app/shared/model/asset.model'; +import { AssetService } from './asset.service'; + +@Component({ + selector: 'jhi-asset-delete-dialog', + templateUrl: './asset-delete-dialog.component.html' +}) +export class AssetDeleteDialogComponent { + asset: IAsset; + + constructor(protected assetService: AssetService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.assetService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'assetListModification', + content: 'Deleted an asset' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-asset-delete-popup', + template: '' +}) +export class AssetDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ asset }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(AssetDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.asset = asset; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/asset', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/asset', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/asset/asset-detail.component.html b/src/main/webapp/app/entities/asset/asset-detail.component.html new file mode 100644 index 00000000..93f2e7f5 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset-detail.component.html @@ -0,0 +1,49 @@ +
+
+
+

Asset {{asset.id}}

+
+ +
+
Document Date
+
+ {{asset.documentDate}} +
+
Value Date
+
+ {{asset.valueDate}} +
+
Action
+
+ {{asset.action}} +
+
Amount
+
+ {{asset.amount}} +
+
Remark
+
+ {{asset.remark}} +
+
Membership
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/asset/asset-detail.component.ts b/src/main/webapp/app/entities/asset/asset-detail.component.ts new file mode 100644 index 00000000..635ee255 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IAsset } from 'app/shared/model/asset.model'; + +@Component({ + selector: 'jhi-asset-detail', + templateUrl: './asset-detail.component.html' +}) +export class AssetDetailComponent implements OnInit { + asset: IAsset; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ asset }) => { + this.asset = asset; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/asset/asset-update.component.html b/src/main/webapp/app/entities/asset/asset-update.component.html new file mode 100644 index 00000000..3b3a5c43 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset-update.component.html @@ -0,0 +1,112 @@ +
+
+
+

Create or edit a Asset

+
+ +
+ + +
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ + +
+ + This field is required. + +
+
+
+ + +
+ + This field is required. + + + This field should be a number. + +
+
+
+ + +
+ + This field cannot be longer than 160 characters. + +
+
+ +
+ + +
+
+ + This field is required. + +
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/asset/asset-update.component.ts b/src/main/webapp/app/entities/asset/asset-update.component.ts new file mode 100644 index 00000000..a58ab009 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset-update.component.ts @@ -0,0 +1,79 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } 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 { IAsset } from 'app/shared/model/asset.model'; +import { AssetService } from './asset.service'; +import { IMembership } from 'app/shared/model/membership.model'; +import { MembershipService } from 'app/entities/membership'; + +@Component({ + selector: 'jhi-asset-update', + templateUrl: './asset-update.component.html' +}) +export class AssetUpdateComponent implements OnInit { + asset: IAsset; + isSaving: boolean; + + memberships: IMembership[]; + documentDateDp: any; + valueDateDp: any; + + constructor( + protected jhiAlertService: JhiAlertService, + protected assetService: AssetService, + protected membershipService: MembershipService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ asset }) => { + this.asset = asset; + }); + this.membershipService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: IMembership[]) => (this.memberships = res), (res: HttpErrorResponse) => this.onError(res.message)); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.asset.id !== undefined) { + this.subscribeToSaveResponse(this.assetService.update(this.asset)); + } else { + this.subscribeToSaveResponse(this.assetService.create(this.asset)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackMembershipById(index: number, item: IMembership) { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/asset/asset.component.html b/src/main/webapp/app/entities/asset/asset.component.html new file mode 100644 index 00000000..2b918714 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset.component.html @@ -0,0 +1,68 @@ +
+

+ Assets + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ID Document Date Value Date Action Amount Remark Membership
{{asset.id}}{{asset.documentDate | date:'mediumDate'}}{{asset.valueDate | date:'mediumDate'}}{{asset.action}}{{asset.amount}}{{asset.remark}} + + +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/asset/asset.component.ts b/src/main/webapp/app/entities/asset/asset.component.ts new file mode 100644 index 00000000..4a5c8445 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset.component.ts @@ -0,0 +1,108 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; + +import { IAsset } from 'app/shared/model/asset.model'; +import { AccountService } from 'app/core'; + +import { ITEMS_PER_PAGE } from 'app/shared'; +import { AssetService } from './asset.service'; + +@Component({ + selector: 'jhi-asset', + templateUrl: './asset.component.html' +}) +export class AssetComponent implements OnInit, OnDestroy { + assets: IAsset[]; + currentAccount: any; + eventSubscriber: Subscription; + itemsPerPage: number; + links: any; + page: any; + predicate: any; + reverse: any; + totalItems: number; + + constructor( + protected assetService: AssetService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected parseLinks: JhiParseLinks, + protected accountService: AccountService + ) { + this.assets = []; + this.itemsPerPage = ITEMS_PER_PAGE; + this.page = 0; + this.links = { + last: 0 + }; + this.predicate = 'id'; + this.reverse = true; + } + + loadAll() { + this.assetService + .query({ + page: this.page, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.paginateAssets(res.body, res.headers), + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + reset() { + this.page = 0; + this.assets = []; + this.loadAll(); + } + + loadPage(page) { + this.page = page; + this.loadAll(); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInAssets(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: IAsset) { + return item.id; + } + + registerChangeInAssets() { + this.eventSubscriber = this.eventManager.subscribe('assetListModification', response => this.reset()); + } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected paginateAssets(data: IAsset[], headers: HttpHeaders) { + this.links = this.parseLinks.parse(headers.get('link')); + this.totalItems = parseInt(headers.get('X-Total-Count'), 10); + for (let i = 0; i < data.length; i++) { + this.assets.push(data[i]); + } + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/asset/asset.module.ts b/src/main/webapp/app/entities/asset/asset.module.ts new file mode 100644 index 00000000..282a44e4 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset.module.ts @@ -0,0 +1,34 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { JhiLanguageService } from 'ng-jhipster'; +import { JhiLanguageHelper } from 'app/core'; + +import { HsadminNgSharedModule } from 'app/shared'; +import { + AssetComponent, + AssetDetailComponent, + AssetUpdateComponent, + AssetDeletePopupComponent, + AssetDeleteDialogComponent, + assetRoute, + assetPopupRoute +} from './'; + +const ENTITY_STATES = [...assetRoute, ...assetPopupRoute]; + +@NgModule({ + imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [AssetComponent, AssetDetailComponent, AssetUpdateComponent, AssetDeleteDialogComponent, AssetDeletePopupComponent], + entryComponents: [AssetComponent, AssetUpdateComponent, AssetDeleteDialogComponent, AssetDeletePopupComponent], + providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class HsadminNgAssetModule { + constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) { + this.languageHelper.language.subscribe((languageKey: string) => { + if (languageKey !== undefined) { + this.languageService.changeLanguage(languageKey); + } + }); + } +} diff --git a/src/main/webapp/app/entities/asset/asset.route.ts b/src/main/webapp/app/entities/asset/asset.route.ts new file mode 100644 index 00000000..b7e030d8 --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Asset } from 'app/shared/model/asset.model'; +import { AssetService } from './asset.service'; +import { AssetComponent } from './asset.component'; +import { AssetDetailComponent } from './asset-detail.component'; +import { AssetUpdateComponent } from './asset-update.component'; +import { AssetDeletePopupComponent } from './asset-delete-dialog.component'; +import { IAsset } from 'app/shared/model/asset.model'; + +@Injectable({ providedIn: 'root' }) +export class AssetResolve implements Resolve { + constructor(private service: AssetService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((asset: HttpResponse) => asset.body) + ); + } + return of(new Asset()); + } +} + +export const assetRoute: Routes = [ + { + path: '', + component: AssetComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.asset.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: AssetDetailComponent, + resolve: { + asset: AssetResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.asset.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: AssetUpdateComponent, + resolve: { + asset: AssetResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.asset.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: AssetUpdateComponent, + resolve: { + asset: AssetResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.asset.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const assetPopupRoute: Routes = [ + { + path: ':id/delete', + component: AssetDeletePopupComponent, + resolve: { + asset: AssetResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.asset.home.title' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/asset/asset.service.ts b/src/main/webapp/app/entities/asset/asset.service.ts new file mode 100644 index 00000000..379d2cec --- /dev/null +++ b/src/main/webapp/app/entities/asset/asset.service.ts @@ -0,0 +1,77 @@ +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'; +import { IAsset } from 'app/shared/model/asset.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class AssetService { + public resourceUrl = SERVER_API_URL + 'api/assets'; + + constructor(protected http: HttpClient) {} + + create(asset: IAsset): Observable { + const copy = this.convertDateFromClient(asset); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + update(asset: IAsset): Observable { + const copy = this.convertDateFromClient(asset); + 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' }) + .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' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + protected convertDateFromClient(asset: IAsset): IAsset { + const copy: IAsset = Object.assign({}, asset, { + documentDate: asset.documentDate != null && asset.documentDate.isValid() ? asset.documentDate.format(DATE_FORMAT) : null, + valueDate: asset.valueDate != null && asset.valueDate.isValid() ? asset.valueDate.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.valueDate = res.body.valueDate != null ? moment(res.body.valueDate) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((asset: IAsset) => { + asset.documentDate = asset.documentDate != null ? moment(asset.documentDate) : null; + asset.valueDate = asset.valueDate != null ? moment(asset.valueDate) : null; + }); + } + return res; + } +} diff --git a/src/main/webapp/app/entities/asset/index.ts b/src/main/webapp/app/entities/asset/index.ts new file mode 100644 index 00000000..5f865f3d --- /dev/null +++ b/src/main/webapp/app/entities/asset/index.ts @@ -0,0 +1,6 @@ +export * from './asset.service'; +export * from './asset-update.component'; +export * from './asset-delete-dialog.component'; +export * from './asset-detail.component'; +export * from './asset.component'; +export * from './asset.route'; diff --git a/src/main/webapp/app/entities/customer/customer-delete-dialog.component.html b/src/main/webapp/app/entities/customer/customer-delete-dialog.component.html new file mode 100644 index 00000000..b04a8e62 --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/customer/customer-delete-dialog.component.ts b/src/main/webapp/app/entities/customer/customer-delete-dialog.component.ts new file mode 100644 index 00000000..3c96919d --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { ICustomer } from 'app/shared/model/customer.model'; +import { CustomerService } from './customer.service'; + +@Component({ + selector: 'jhi-customer-delete-dialog', + templateUrl: './customer-delete-dialog.component.html' +}) +export class CustomerDeleteDialogComponent { + customer: ICustomer; + + constructor(protected customerService: CustomerService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.customerService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'customerListModification', + content: 'Deleted an customer' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-customer-delete-popup', + template: '' +}) +export class CustomerDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ customer }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(CustomerDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.customer = customer; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/customer', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/customer', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/customer/customer-detail.component.html b/src/main/webapp/app/entities/customer/customer-detail.component.html new file mode 100644 index 00000000..93c22ade --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-detail.component.html @@ -0,0 +1,83 @@ +
+
+
+

Customer {{customer.id}}

+
+ +
+
Reference
+
+ {{customer.reference}} +
+
Prefix
+
+ {{customer.prefix}} +
+
Name
+
+ {{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}} +
+
Contractual Address
+
+ {{customer.contractualAddress}} +
+
Billing Salutation
+
+ {{customer.billingSalutation}} +
+
Billing Address
+
+ {{customer.billingAddress}} +
+
Remark
+
+ {{customer.remark}} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/customer/customer-detail.component.ts b/src/main/webapp/app/entities/customer/customer-detail.component.ts new file mode 100644 index 00000000..da1b94e3 --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { ICustomer } from 'app/shared/model/customer.model'; + +@Component({ + selector: 'jhi-customer-detail', + templateUrl: './customer-detail.component.html' +}) +export class CustomerDetailComponent implements OnInit { + customer: ICustomer; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ customer }) => { + this.customer = customer; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/customer/customer-update.component.html b/src/main/webapp/app/entities/customer/customer-update.component.html new file mode 100644 index 00000000..0a498111 --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-update.component.html @@ -0,0 +1,221 @@ +
+
+
+

Create or edit a Customer

+
+ +
+ + +
+
+ + +
+ + This field is required. + + + This field should be at least 10000. + + + This field cannot be more than 99999. + + + This field should be a number. + +
+
+
+ + +
+ + This field is required. + + + This field cannot be longer than 3 characters. + + + This field should follow pattern for "Prefix". + +
+
+
+ + +
+ + This field is required. + + + This field cannot be longer than 80 characters. + +
+
+
+ + +
+ + 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. + +
+
+
+ + +
+ + This field cannot be longer than 80 characters. + +
+
+
+ + +
+ + This field is required. + + + This field cannot be longer than 400 characters. + +
+
+
+ + +
+ + This field cannot be longer than 80 characters. + +
+
+
+ + +
+ + This field cannot be longer than 400 characters. + +
+
+
+ + +
+ + This field cannot be longer than 160 characters. + +
+
+ +
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/customer/customer-update.component.ts b/src/main/webapp/app/entities/customer/customer-update.component.ts new file mode 100644 index 00000000..33cbdd4f --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-update.component.ts @@ -0,0 +1,53 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import * as moment from 'moment'; +import { ICustomer } from 'app/shared/model/customer.model'; +import { CustomerService } from './customer.service'; + +@Component({ + selector: 'jhi-customer-update', + templateUrl: './customer-update.component.html' +}) +export class CustomerUpdateComponent implements OnInit { + customer: ICustomer; + isSaving: boolean; + birthDateDp: any; + + constructor(protected customerService: CustomerService, protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ customer }) => { + this.customer = customer; + }); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.customer.id !== undefined) { + this.subscribeToSaveResponse(this.customerService.update(this.customer)); + } else { + this.subscribeToSaveResponse(this.customerService.create(this.customer)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } +} diff --git a/src/main/webapp/app/entities/customer/customer.component.html b/src/main/webapp/app/entities/customer/customer.component.html new file mode 100644 index 00000000..afb4fb12 --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer.component.html @@ -0,0 +1,82 @@ +
+

+ Customers + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID Reference Prefix Name Kind Birth Date Birth Place Registration Court Registration Number Vat Region Vat Number Contractual Salutation Contractual Address Billing Salutation Billing Address Remark
{{customer.id}}{{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}}{{customer.billingAddress}}{{customer.remark}} +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/customer/customer.component.ts b/src/main/webapp/app/entities/customer/customer.component.ts new file mode 100644 index 00000000..a1d3ce51 --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer.component.ts @@ -0,0 +1,108 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; + +import { ICustomer } from 'app/shared/model/customer.model'; +import { AccountService } from 'app/core'; + +import { ITEMS_PER_PAGE } from 'app/shared'; +import { CustomerService } from './customer.service'; + +@Component({ + selector: 'jhi-customer', + templateUrl: './customer.component.html' +}) +export class CustomerComponent implements OnInit, OnDestroy { + customers: ICustomer[]; + currentAccount: any; + eventSubscriber: Subscription; + itemsPerPage: number; + links: any; + page: any; + predicate: any; + reverse: any; + totalItems: number; + + constructor( + protected customerService: CustomerService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected parseLinks: JhiParseLinks, + protected accountService: AccountService + ) { + this.customers = []; + this.itemsPerPage = ITEMS_PER_PAGE; + this.page = 0; + this.links = { + last: 0 + }; + this.predicate = 'id'; + this.reverse = true; + } + + loadAll() { + this.customerService + .query({ + page: this.page, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.paginateCustomers(res.body, res.headers), + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + reset() { + this.page = 0; + this.customers = []; + this.loadAll(); + } + + loadPage(page) { + this.page = page; + this.loadAll(); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInCustomers(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: ICustomer) { + return item.id; + } + + registerChangeInCustomers() { + this.eventSubscriber = this.eventManager.subscribe('customerListModification', response => this.reset()); + } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected paginateCustomers(data: ICustomer[], headers: HttpHeaders) { + this.links = this.parseLinks.parse(headers.get('link')); + this.totalItems = parseInt(headers.get('X-Total-Count'), 10); + for (let i = 0; i < data.length; i++) { + this.customers.push(data[i]); + } + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/customer/customer.module.ts b/src/main/webapp/app/entities/customer/customer.module.ts new file mode 100644 index 00000000..8d50348c --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer.module.ts @@ -0,0 +1,40 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { JhiLanguageService } from 'ng-jhipster'; +import { JhiLanguageHelper } from 'app/core'; + +import { HsadminNgSharedModule } from 'app/shared'; +import { + CustomerComponent, + CustomerDetailComponent, + CustomerUpdateComponent, + CustomerDeletePopupComponent, + CustomerDeleteDialogComponent, + customerRoute, + customerPopupRoute +} from './'; + +const ENTITY_STATES = [...customerRoute, ...customerPopupRoute]; + +@NgModule({ + imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ + CustomerComponent, + CustomerDetailComponent, + CustomerUpdateComponent, + CustomerDeleteDialogComponent, + CustomerDeletePopupComponent + ], + entryComponents: [CustomerComponent, CustomerUpdateComponent, CustomerDeleteDialogComponent, CustomerDeletePopupComponent], + providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class HsadminNgCustomerModule { + constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) { + this.languageHelper.language.subscribe((languageKey: string) => { + if (languageKey !== undefined) { + this.languageService.changeLanguage(languageKey); + } + }); + } +} diff --git a/src/main/webapp/app/entities/customer/customer.route.ts b/src/main/webapp/app/entities/customer/customer.route.ts new file mode 100644 index 00000000..269760db --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Customer } from 'app/shared/model/customer.model'; +import { CustomerService } from './customer.service'; +import { CustomerComponent } from './customer.component'; +import { CustomerDetailComponent } from './customer-detail.component'; +import { CustomerUpdateComponent } from './customer-update.component'; +import { CustomerDeletePopupComponent } from './customer-delete-dialog.component'; +import { ICustomer } from 'app/shared/model/customer.model'; + +@Injectable({ providedIn: 'root' }) +export class CustomerResolve implements Resolve { + constructor(private service: CustomerService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((customer: HttpResponse) => customer.body) + ); + } + return of(new Customer()); + } +} + +export const customerRoute: Routes = [ + { + path: '', + component: CustomerComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.customer.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: CustomerDetailComponent, + resolve: { + customer: CustomerResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.customer.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: CustomerUpdateComponent, + resolve: { + customer: CustomerResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.customer.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: CustomerUpdateComponent, + resolve: { + customer: CustomerResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.customer.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const customerPopupRoute: Routes = [ + { + path: ':id/delete', + component: CustomerDeletePopupComponent, + resolve: { + customer: CustomerResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.customer.home.title' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/customer/customer.service.ts b/src/main/webapp/app/entities/customer/customer.service.ts new file mode 100644 index 00000000..7b6951ce --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer.service.ts @@ -0,0 +1,74 @@ +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'; +import { ICustomer } from 'app/shared/model/customer.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class CustomerService { + public resourceUrl = SERVER_API_URL + 'api/customers'; + + constructor(protected http: HttpClient) {} + + create(customer: ICustomer): Observable { + 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 { + 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' }) + .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' }) + .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/customer/index.ts b/src/main/webapp/app/entities/customer/index.ts new file mode 100644 index 00000000..27ae3ca8 --- /dev/null +++ b/src/main/webapp/app/entities/customer/index.ts @@ -0,0 +1,6 @@ +export * from './customer.service'; +export * from './customer-update.component'; +export * from './customer-delete-dialog.component'; +export * from './customer-detail.component'; +export * from './customer.component'; +export * from './customer.route'; diff --git a/src/main/webapp/app/entities/entity.module.ts b/src/main/webapp/app/entities/entity.module.ts index fed9de39..00686b57 100644 --- a/src/main/webapp/app/entities/entity.module.ts +++ b/src/main/webapp/app/entities/entity.module.ts @@ -4,6 +4,26 @@ import { RouterModule } from '@angular/router'; @NgModule({ imports: [ RouterModule.forChild([ + { + path: 'customer', + loadChildren: './customer/customer.module#HsadminNgCustomerModule' + }, + { + path: 'membership', + loadChildren: './membership/membership.module#HsadminNgMembershipModule' + }, + { + path: 'share', + loadChildren: './share/share.module#HsadminNgShareModule' + }, + { + path: 'asset', + loadChildren: './asset/asset.module#HsadminNgAssetModule' + }, + { + path: 'sepa-mandate', + loadChildren: './sepa-mandate/sepa-mandate.module#HsadminNgSepaMandateModule' + } /* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */ ]) ], diff --git a/src/main/webapp/app/entities/membership/index.ts b/src/main/webapp/app/entities/membership/index.ts new file mode 100644 index 00000000..13a7f938 --- /dev/null +++ b/src/main/webapp/app/entities/membership/index.ts @@ -0,0 +1,6 @@ +export * from './membership.service'; +export * from './membership-update.component'; +export * from './membership-delete-dialog.component'; +export * from './membership-detail.component'; +export * from './membership.component'; +export * from './membership.route'; diff --git a/src/main/webapp/app/entities/membership/membership-delete-dialog.component.html b/src/main/webapp/app/entities/membership/membership-delete-dialog.component.html new file mode 100644 index 00000000..8749c4ee --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/membership/membership-delete-dialog.component.ts b/src/main/webapp/app/entities/membership/membership-delete-dialog.component.ts new file mode 100644 index 00000000..ac1787db --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-delete-dialog.component.ts @@ -0,0 +1,69 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IMembership } from 'app/shared/model/membership.model'; +import { MembershipService } from './membership.service'; + +@Component({ + selector: 'jhi-membership-delete-dialog', + templateUrl: './membership-delete-dialog.component.html' +}) +export class MembershipDeleteDialogComponent { + membership: IMembership; + + constructor( + protected membershipService: MembershipService, + public activeModal: NgbActiveModal, + protected eventManager: JhiEventManager + ) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.membershipService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'membershipListModification', + content: 'Deleted an membership' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-membership-delete-popup', + template: '' +}) +export class MembershipDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ membership }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(MembershipDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.membership = membership; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/membership', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/membership', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/membership/membership-detail.component.html b/src/main/webapp/app/entities/membership/membership-detail.component.html new file mode 100644 index 00000000..3115c10a --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-detail.component.html @@ -0,0 +1,49 @@ +
+
+
+

Membership {{membership.id}}

+
+ +
+
Admission Document Date
+
+ {{membership.admissionDocumentDate}} +
+
Cancellation Document Date
+
+ {{membership.cancellationDocumentDate}} +
+
Member From Date
+
+ {{membership.memberFromDate}} +
+
Member Until Date
+
+ {{membership.memberUntilDate}} +
+
Remark
+
+ {{membership.remark}} +
+
Customer
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/membership/membership-detail.component.ts b/src/main/webapp/app/entities/membership/membership-detail.component.ts new file mode 100644 index 00000000..ed1105eb --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IMembership } from 'app/shared/model/membership.model'; + +@Component({ + selector: 'jhi-membership-detail', + templateUrl: './membership-detail.component.html' +}) +export class MembershipDetailComponent implements OnInit { + membership: IMembership; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ membership }) => { + this.membership = membership; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/membership/membership-update.component.html b/src/main/webapp/app/entities/membership/membership-update.component.html new file mode 100644 index 00000000..118a6127 --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-update.component.html @@ -0,0 +1,100 @@ +
+
+
+

Create or edit a Membership

+
+ +
+ + +
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + This field cannot be longer than 160 characters. + +
+
+ +
+ + +
+
+ + 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 new file mode 100644 index 00000000..d3a72e41 --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-update.component.ts @@ -0,0 +1,81 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } 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'; +import { ICustomer } from 'app/shared/model/customer.model'; +import { CustomerService } from 'app/entities/customer'; + +@Component({ + selector: 'jhi-membership-update', + templateUrl: './membership-update.component.html' +}) +export class MembershipUpdateComponent implements OnInit { + membership: IMembership; + isSaving: boolean; + + customers: ICustomer[]; + admissionDocumentDateDp: any; + cancellationDocumentDateDp: any; + memberFromDateDp: any; + memberUntilDateDp: any; + + constructor( + protected jhiAlertService: JhiAlertService, + protected membershipService: MembershipService, + protected customerService: CustomerService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ membership }) => { + this.membership = membership; + }); + this.customerService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: ICustomer[]) => (this.customers = res), (res: HttpErrorResponse) => this.onError(res.message)); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.membership.id !== undefined) { + this.subscribeToSaveResponse(this.membershipService.update(this.membership)); + } else { + this.subscribeToSaveResponse(this.membershipService.create(this.membership)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackCustomerById(index: number, item: ICustomer) { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/membership/membership.component.html b/src/main/webapp/app/entities/membership/membership.component.html new file mode 100644 index 00000000..82375faf --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership.component.html @@ -0,0 +1,68 @@ +
+

+ Memberships + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ID Admission Document Date Cancellation Document Date Member From Date Member Until Date Remark Customer
{{membership.id}}{{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.component.ts b/src/main/webapp/app/entities/membership/membership.component.ts new file mode 100644 index 00000000..387df20d --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership.component.ts @@ -0,0 +1,108 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; + +import { IMembership } from 'app/shared/model/membership.model'; +import { AccountService } from 'app/core'; + +import { ITEMS_PER_PAGE } from 'app/shared'; +import { MembershipService } from './membership.service'; + +@Component({ + selector: 'jhi-membership', + templateUrl: './membership.component.html' +}) +export class MembershipComponent implements OnInit, OnDestroy { + memberships: IMembership[]; + currentAccount: any; + eventSubscriber: Subscription; + itemsPerPage: number; + links: any; + page: any; + predicate: any; + reverse: any; + totalItems: number; + + constructor( + protected membershipService: MembershipService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected parseLinks: JhiParseLinks, + protected accountService: AccountService + ) { + this.memberships = []; + this.itemsPerPage = ITEMS_PER_PAGE; + this.page = 0; + this.links = { + last: 0 + }; + this.predicate = 'id'; + this.reverse = true; + } + + loadAll() { + this.membershipService + .query({ + page: this.page, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.paginateMemberships(res.body, res.headers), + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + reset() { + this.page = 0; + this.memberships = []; + this.loadAll(); + } + + loadPage(page) { + this.page = page; + this.loadAll(); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInMemberships(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: IMembership) { + return item.id; + } + + registerChangeInMemberships() { + this.eventSubscriber = this.eventManager.subscribe('membershipListModification', response => this.reset()); + } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected paginateMemberships(data: IMembership[], headers: HttpHeaders) { + this.links = this.parseLinks.parse(headers.get('link')); + this.totalItems = parseInt(headers.get('X-Total-Count'), 10); + for (let i = 0; i < data.length; i++) { + this.memberships.push(data[i]); + } + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/membership/membership.module.ts b/src/main/webapp/app/entities/membership/membership.module.ts new file mode 100644 index 00000000..01e0545f --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership.module.ts @@ -0,0 +1,40 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { JhiLanguageService } from 'ng-jhipster'; +import { JhiLanguageHelper } from 'app/core'; + +import { HsadminNgSharedModule } from 'app/shared'; +import { + MembershipComponent, + MembershipDetailComponent, + MembershipUpdateComponent, + MembershipDeletePopupComponent, + MembershipDeleteDialogComponent, + membershipRoute, + membershipPopupRoute +} from './'; + +const ENTITY_STATES = [...membershipRoute, ...membershipPopupRoute]; + +@NgModule({ + imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ + MembershipComponent, + MembershipDetailComponent, + MembershipUpdateComponent, + MembershipDeleteDialogComponent, + MembershipDeletePopupComponent + ], + entryComponents: [MembershipComponent, MembershipUpdateComponent, MembershipDeleteDialogComponent, MembershipDeletePopupComponent], + providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class HsadminNgMembershipModule { + constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) { + this.languageHelper.language.subscribe((languageKey: string) => { + if (languageKey !== undefined) { + this.languageService.changeLanguage(languageKey); + } + }); + } +} diff --git a/src/main/webapp/app/entities/membership/membership.route.ts b/src/main/webapp/app/entities/membership/membership.route.ts new file mode 100644 index 00000000..fbf9f430 --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Membership } from 'app/shared/model/membership.model'; +import { MembershipService } from './membership.service'; +import { MembershipComponent } from './membership.component'; +import { MembershipDetailComponent } from './membership-detail.component'; +import { MembershipUpdateComponent } from './membership-update.component'; +import { MembershipDeletePopupComponent } from './membership-delete-dialog.component'; +import { IMembership } from 'app/shared/model/membership.model'; + +@Injectable({ providedIn: 'root' }) +export class MembershipResolve implements Resolve { + constructor(private service: MembershipService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((membership: HttpResponse) => membership.body) + ); + } + return of(new Membership()); + } +} + +export const membershipRoute: Routes = [ + { + path: '', + component: MembershipComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.membership.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: MembershipDetailComponent, + resolve: { + membership: MembershipResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.membership.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: MembershipUpdateComponent, + resolve: { + membership: MembershipResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.membership.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: MembershipUpdateComponent, + resolve: { + membership: MembershipResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.membership.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const membershipPopupRoute: Routes = [ + { + path: ':id/delete', + component: MembershipDeletePopupComponent, + resolve: { + membership: MembershipResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.membership.home.title' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/membership/membership.service.ts b/src/main/webapp/app/entities/membership/membership.service.ts new file mode 100644 index 00000000..586846eb --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership.service.ts @@ -0,0 +1,98 @@ +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'; +import { IMembership } from 'app/shared/model/membership.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class MembershipService { + public resourceUrl = SERVER_API_URL + 'api/memberships'; + + constructor(protected http: HttpClient) {} + + create(membership: IMembership): Observable { + const copy = this.convertDateFromClient(membership); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + update(membership: IMembership): Observable { + const copy = this.convertDateFromClient(membership); + 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' }) + .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' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + protected convertDateFromClient(membership: IMembership): IMembership { + const copy: IMembership = Object.assign({}, membership, { + 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.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; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((membership: IMembership) => { + 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/index.ts b/src/main/webapp/app/entities/sepa-mandate/index.ts new file mode 100644 index 00000000..f99de152 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/index.ts @@ -0,0 +1,6 @@ +export * from './sepa-mandate.service'; +export * from './sepa-mandate-update.component'; +export * from './sepa-mandate-delete-dialog.component'; +export * from './sepa-mandate-detail.component'; +export * from './sepa-mandate.component'; +export * from './sepa-mandate.route'; diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.html b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.html new file mode 100644 index 00000000..12baf54a --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.ts new file mode 100644 index 00000000..741e2642 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.ts @@ -0,0 +1,72 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; +import { SepaMandateService } from './sepa-mandate.service'; + +@Component({ + selector: 'jhi-sepa-mandate-delete-dialog', + templateUrl: './sepa-mandate-delete-dialog.component.html' +}) +export class SepaMandateDeleteDialogComponent { + sepaMandate: ISepaMandate; + + constructor( + protected sepaMandateService: SepaMandateService, + public activeModal: NgbActiveModal, + protected eventManager: JhiEventManager + ) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.sepaMandateService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'sepaMandateListModification', + content: 'Deleted an sepaMandate' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-sepa-mandate-delete-popup', + template: '' +}) +export class SepaMandateDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ sepaMandate }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(SepaMandateDeleteDialogComponent as Component, { + size: 'lg', + backdrop: 'static' + }); + this.ngbModalRef.componentInstance.sepaMandate = sepaMandate; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/sepa-mandate', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/sepa-mandate', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} 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 new file mode 100644 index 00000000..af5b3bf5 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.html @@ -0,0 +1,65 @@ +
+
+
+

Sepa Mandate {{sepaMandate.id}}

+
+ +
+
Reference
+
+ {{sepaMandate.reference}} +
+
Iban
+
+ {{sepaMandate.iban}} +
+
Bic
+
+ {{sepaMandate.bic}} +
+
Granting Document Date
+
+ {{sepaMandate.grantingDocumentDate}} +
+
Revokation Document Date
+
+ {{sepaMandate.revokationDocumentDate}} +
+
Valid From Date
+
+ {{sepaMandate.validFromDate}} +
+
Valid Until Date
+
+ {{sepaMandate.validUntilDate}} +
+
Last Used Date
+
+ {{sepaMandate.lastUsedDate}} +
+
Remark
+
+ {{sepaMandate.remark}} +
+
Customer
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.ts new file mode 100644 index 00000000..41c98730 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; + +@Component({ + selector: 'jhi-sepa-mandate-detail', + templateUrl: './sepa-mandate-detail.component.html' +}) +export class SepaMandateDetailComponent implements OnInit { + sepaMandate: ISepaMandate; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ sepaMandate }) => { + this.sepaMandate = sepaMandate; + }); + } + + previousState() { + window.history.back(); + } +} 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 new file mode 100644 index 00000000..507750c8 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.html @@ -0,0 +1,147 @@ +
+
+
+

Create or edit a Sepa Mandate

+
+ +
+ + +
+
+ + +
+ + This field is required. + + + This field cannot be longer than 40 characters. + +
+
+
+ + +
+ + This field cannot be longer than 34 characters. + +
+
+
+ + +
+ + This field cannot be longer than 11 characters. + +
+
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+
+ + +
+ + This field cannot be longer than 160 characters. + +
+
+ +
+ + +
+
+ + 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 new file mode 100644 index 00000000..bcafb5b0 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts @@ -0,0 +1,82 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } 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'; +import { ICustomer } from 'app/shared/model/customer.model'; +import { CustomerService } from 'app/entities/customer'; + +@Component({ + selector: 'jhi-sepa-mandate-update', + templateUrl: './sepa-mandate-update.component.html' +}) +export class SepaMandateUpdateComponent implements OnInit { + sepaMandate: ISepaMandate; + isSaving: boolean; + + customers: ICustomer[]; + grantingDocumentDateDp: any; + revokationDocumentDateDp: any; + validFromDateDp: any; + validUntilDateDp: any; + lastUsedDateDp: any; + + constructor( + protected jhiAlertService: JhiAlertService, + protected sepaMandateService: SepaMandateService, + protected customerService: CustomerService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ sepaMandate }) => { + this.sepaMandate = sepaMandate; + }); + this.customerService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: ICustomer[]) => (this.customers = res), (res: HttpErrorResponse) => this.onError(res.message)); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.sepaMandate.id !== undefined) { + this.subscribeToSaveResponse(this.sepaMandateService.update(this.sepaMandate)); + } else { + this.subscribeToSaveResponse(this.sepaMandateService.create(this.sepaMandate)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackCustomerById(index: number, item: ICustomer) { + return item.id; + } +} 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 new file mode 100644 index 00000000..2fca9893 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html @@ -0,0 +1,76 @@ +
+

+ Sepa Mandates + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID Reference Iban Bic Granting Document Date Revokation Document Date Valid From Date Valid Until Date Last Used Date Remark Customer
{{sepaMandate.id}}{{sepaMandate.reference}}{{sepaMandate.iban}}{{sepaMandate.bic}}{{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.component.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.ts new file mode 100644 index 00000000..d7ef209a --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.ts @@ -0,0 +1,108 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; + +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; +import { AccountService } from 'app/core'; + +import { ITEMS_PER_PAGE } from 'app/shared'; +import { SepaMandateService } from './sepa-mandate.service'; + +@Component({ + selector: 'jhi-sepa-mandate', + templateUrl: './sepa-mandate.component.html' +}) +export class SepaMandateComponent implements OnInit, OnDestroy { + sepaMandates: ISepaMandate[]; + currentAccount: any; + eventSubscriber: Subscription; + itemsPerPage: number; + links: any; + page: any; + predicate: any; + reverse: any; + totalItems: number; + + constructor( + protected sepaMandateService: SepaMandateService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected parseLinks: JhiParseLinks, + protected accountService: AccountService + ) { + this.sepaMandates = []; + this.itemsPerPage = ITEMS_PER_PAGE; + this.page = 0; + this.links = { + last: 0 + }; + this.predicate = 'id'; + this.reverse = true; + } + + loadAll() { + this.sepaMandateService + .query({ + page: this.page, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.paginateSepaMandates(res.body, res.headers), + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + reset() { + this.page = 0; + this.sepaMandates = []; + this.loadAll(); + } + + loadPage(page) { + this.page = page; + this.loadAll(); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInSepaMandates(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: ISepaMandate) { + return item.id; + } + + registerChangeInSepaMandates() { + this.eventSubscriber = this.eventManager.subscribe('sepaMandateListModification', response => this.reset()); + } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected paginateSepaMandates(data: ISepaMandate[], headers: HttpHeaders) { + this.links = this.parseLinks.parse(headers.get('link')); + this.totalItems = parseInt(headers.get('X-Total-Count'), 10); + for (let i = 0; i < data.length; i++) { + this.sepaMandates.push(data[i]); + } + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.module.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.module.ts new file mode 100644 index 00000000..f94a5113 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.module.ts @@ -0,0 +1,40 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { JhiLanguageService } from 'ng-jhipster'; +import { JhiLanguageHelper } from 'app/core'; + +import { HsadminNgSharedModule } from 'app/shared'; +import { + SepaMandateComponent, + SepaMandateDetailComponent, + SepaMandateUpdateComponent, + SepaMandateDeletePopupComponent, + SepaMandateDeleteDialogComponent, + sepaMandateRoute, + sepaMandatePopupRoute +} from './'; + +const ENTITY_STATES = [...sepaMandateRoute, ...sepaMandatePopupRoute]; + +@NgModule({ + imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ + SepaMandateComponent, + SepaMandateDetailComponent, + SepaMandateUpdateComponent, + SepaMandateDeleteDialogComponent, + SepaMandateDeletePopupComponent + ], + entryComponents: [SepaMandateComponent, SepaMandateUpdateComponent, SepaMandateDeleteDialogComponent, SepaMandateDeletePopupComponent], + providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class HsadminNgSepaMandateModule { + constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) { + this.languageHelper.language.subscribe((languageKey: string) => { + if (languageKey !== undefined) { + this.languageService.changeLanguage(languageKey); + } + }); + } +} diff --git a/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.route.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.route.ts new file mode 100644 index 00000000..de46aaf3 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { SepaMandate } from 'app/shared/model/sepa-mandate.model'; +import { SepaMandateService } from './sepa-mandate.service'; +import { SepaMandateComponent } from './sepa-mandate.component'; +import { SepaMandateDetailComponent } from './sepa-mandate-detail.component'; +import { SepaMandateUpdateComponent } from './sepa-mandate-update.component'; +import { SepaMandateDeletePopupComponent } from './sepa-mandate-delete-dialog.component'; +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; + +@Injectable({ providedIn: 'root' }) +export class SepaMandateResolve implements Resolve { + constructor(private service: SepaMandateService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((sepaMandate: HttpResponse) => sepaMandate.body) + ); + } + return of(new SepaMandate()); + } +} + +export const sepaMandateRoute: Routes = [ + { + path: '', + component: SepaMandateComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.sepaMandate.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: SepaMandateDetailComponent, + resolve: { + sepaMandate: SepaMandateResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.sepaMandate.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: SepaMandateUpdateComponent, + resolve: { + sepaMandate: SepaMandateResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.sepaMandate.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: SepaMandateUpdateComponent, + resolve: { + sepaMandate: SepaMandateResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.sepaMandate.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const sepaMandatePopupRoute: Routes = [ + { + path: ':id/delete', + component: SepaMandateDeletePopupComponent, + resolve: { + sepaMandate: SepaMandateResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.sepaMandate.home.title' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; 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 new file mode 100644 index 00000000..0cf01c0a --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts @@ -0,0 +1,101 @@ +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'; +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class SepaMandateService { + public resourceUrl = SERVER_API_URL + 'api/sepa-mandates'; + + constructor(protected http: HttpClient) {} + + create(sepaMandate: ISepaMandate): Observable { + const copy = this.convertDateFromClient(sepaMandate); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + update(sepaMandate: ISepaMandate): Observable { + const copy = this.convertDateFromClient(sepaMandate); + 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' }) + .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' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + protected convertDateFromClient(sepaMandate: ISepaMandate): ISepaMandate { + const copy: ISepaMandate = Object.assign({}, sepaMandate, { + grantingDocumentDate: + sepaMandate.grantingDocumentDate != null && sepaMandate.grantingDocumentDate.isValid() + ? sepaMandate.grantingDocumentDate.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.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; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((sepaMandate: ISepaMandate) => { + 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/index.ts b/src/main/webapp/app/entities/share/index.ts new file mode 100644 index 00000000..ecc5eeaa --- /dev/null +++ b/src/main/webapp/app/entities/share/index.ts @@ -0,0 +1,6 @@ +export * from './share.service'; +export * from './share-update.component'; +export * from './share-delete-dialog.component'; +export * from './share-detail.component'; +export * from './share.component'; +export * from './share.route'; diff --git a/src/main/webapp/app/entities/share/share-delete-dialog.component.html b/src/main/webapp/app/entities/share/share-delete-dialog.component.html new file mode 100644 index 00000000..5437602b --- /dev/null +++ b/src/main/webapp/app/entities/share/share-delete-dialog.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/share/share-delete-dialog.component.ts b/src/main/webapp/app/entities/share/share-delete-dialog.component.ts new file mode 100644 index 00000000..34138baa --- /dev/null +++ b/src/main/webapp/app/entities/share/share-delete-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IShare } from 'app/shared/model/share.model'; +import { ShareService } from './share.service'; + +@Component({ + selector: 'jhi-share-delete-dialog', + templateUrl: './share-delete-dialog.component.html' +}) +export class ShareDeleteDialogComponent { + share: IShare; + + constructor(protected shareService: ShareService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + clear() { + this.activeModal.dismiss('cancel'); + } + + confirmDelete(id: number) { + this.shareService.delete(id).subscribe(response => { + this.eventManager.broadcast({ + name: 'shareListModification', + content: 'Deleted an share' + }); + this.activeModal.dismiss(true); + }); + } +} + +@Component({ + selector: 'jhi-share-delete-popup', + template: '' +}) +export class ShareDeletePopupComponent implements OnInit, OnDestroy { + protected ngbModalRef: NgbModalRef; + + constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ share }) => { + setTimeout(() => { + this.ngbModalRef = this.modalService.open(ShareDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); + this.ngbModalRef.componentInstance.share = share; + this.ngbModalRef.result.then( + result => { + this.router.navigate(['/share', { outlets: { popup: null } }]); + this.ngbModalRef = null; + }, + reason => { + this.router.navigate(['/share', { outlets: { popup: null } }]); + this.ngbModalRef = null; + } + ); + }, 0); + }); + } + + ngOnDestroy() { + this.ngbModalRef = null; + } +} diff --git a/src/main/webapp/app/entities/share/share-detail.component.html b/src/main/webapp/app/entities/share/share-detail.component.html new file mode 100644 index 00000000..bd3df716 --- /dev/null +++ b/src/main/webapp/app/entities/share/share-detail.component.html @@ -0,0 +1,49 @@ +
+
+
+

Share {{share.id}}

+
+ +
+
Document Date
+
+ {{share.documentDate}} +
+
Value Date
+
+ {{share.valueDate}} +
+
Action
+
+ {{share.action}} +
+
Quantity
+
+ {{share.quantity}} +
+
Remark
+
+ {{share.remark}} +
+
Membership
+
+ +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/share/share-detail.component.ts b/src/main/webapp/app/entities/share/share-detail.component.ts new file mode 100644 index 00000000..5cd2ed0f --- /dev/null +++ b/src/main/webapp/app/entities/share/share-detail.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IShare } from 'app/shared/model/share.model'; + +@Component({ + selector: 'jhi-share-detail', + templateUrl: './share-detail.component.html' +}) +export class ShareDetailComponent implements OnInit { + share: IShare; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ share }) => { + this.share = share; + }); + } + + previousState() { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/share/share-update.component.html b/src/main/webapp/app/entities/share/share-update.component.html new file mode 100644 index 00000000..4f077e99 --- /dev/null +++ b/src/main/webapp/app/entities/share/share-update.component.html @@ -0,0 +1,108 @@ +
+
+
+

Create or edit a Share

+
+ +
+ + +
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ +
+ + + + +
+
+ + This field is required. + +
+
+
+ + +
+ + This field is required. + +
+
+
+ + +
+ + This field is required. + + + This field should be a number. + +
+
+
+ + +
+ + This field cannot be longer than 160 characters. + +
+
+ +
+ + +
+
+ + This field is required. + +
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/app/entities/share/share-update.component.ts b/src/main/webapp/app/entities/share/share-update.component.ts new file mode 100644 index 00000000..e7301309 --- /dev/null +++ b/src/main/webapp/app/entities/share/share-update.component.ts @@ -0,0 +1,79 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { HttpResponse, HttpErrorResponse } 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 { IShare } from 'app/shared/model/share.model'; +import { ShareService } from './share.service'; +import { IMembership } from 'app/shared/model/membership.model'; +import { MembershipService } from 'app/entities/membership'; + +@Component({ + selector: 'jhi-share-update', + templateUrl: './share-update.component.html' +}) +export class ShareUpdateComponent implements OnInit { + share: IShare; + isSaving: boolean; + + memberships: IMembership[]; + documentDateDp: any; + valueDateDp: any; + + constructor( + protected jhiAlertService: JhiAlertService, + protected shareService: ShareService, + protected membershipService: MembershipService, + protected activatedRoute: ActivatedRoute + ) {} + + ngOnInit() { + this.isSaving = false; + this.activatedRoute.data.subscribe(({ share }) => { + this.share = share; + }); + this.membershipService + .query() + .pipe( + filter((mayBeOk: HttpResponse) => mayBeOk.ok), + map((response: HttpResponse) => response.body) + ) + .subscribe((res: IMembership[]) => (this.memberships = res), (res: HttpErrorResponse) => this.onError(res.message)); + } + + previousState() { + window.history.back(); + } + + save() { + this.isSaving = true; + if (this.share.id !== undefined) { + this.subscribeToSaveResponse(this.shareService.update(this.share)); + } else { + this.subscribeToSaveResponse(this.shareService.create(this.share)); + } + } + + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + } + + protected onSaveSuccess() { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError() { + this.isSaving = false; + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } + + trackMembershipById(index: number, item: IMembership) { + return item.id; + } +} diff --git a/src/main/webapp/app/entities/share/share.component.html b/src/main/webapp/app/entities/share/share.component.html new file mode 100644 index 00000000..d42d00e1 --- /dev/null +++ b/src/main/webapp/app/entities/share/share.component.html @@ -0,0 +1,68 @@ +
+

+ Shares + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
ID Document Date Value Date Action Quantity Remark Membership
{{share.id}}{{share.documentDate | date:'mediumDate'}}{{share.valueDate | date:'mediumDate'}}{{share.action}}{{share.quantity}}{{share.remark}} + + +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/share/share.component.ts b/src/main/webapp/app/entities/share/share.component.ts new file mode 100644 index 00000000..d636295f --- /dev/null +++ b/src/main/webapp/app/entities/share/share.component.ts @@ -0,0 +1,108 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpErrorResponse, HttpHeaders, HttpResponse } from '@angular/common/http'; +import { Subscription } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; + +import { IShare } from 'app/shared/model/share.model'; +import { AccountService } from 'app/core'; + +import { ITEMS_PER_PAGE } from 'app/shared'; +import { ShareService } from './share.service'; + +@Component({ + selector: 'jhi-share', + templateUrl: './share.component.html' +}) +export class ShareComponent implements OnInit, OnDestroy { + shares: IShare[]; + currentAccount: any; + eventSubscriber: Subscription; + itemsPerPage: number; + links: any; + page: any; + predicate: any; + reverse: any; + totalItems: number; + + constructor( + protected shareService: ShareService, + protected jhiAlertService: JhiAlertService, + protected eventManager: JhiEventManager, + protected parseLinks: JhiParseLinks, + protected accountService: AccountService + ) { + this.shares = []; + this.itemsPerPage = ITEMS_PER_PAGE; + this.page = 0; + this.links = { + last: 0 + }; + this.predicate = 'id'; + this.reverse = true; + } + + loadAll() { + this.shareService + .query({ + page: this.page, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.paginateShares(res.body, res.headers), + (res: HttpErrorResponse) => this.onError(res.message) + ); + } + + reset() { + this.page = 0; + this.shares = []; + this.loadAll(); + } + + loadPage(page) { + this.page = page; + this.loadAll(); + } + + ngOnInit() { + this.loadAll(); + this.accountService.identity().then(account => { + this.currentAccount = account; + }); + this.registerChangeInShares(); + } + + ngOnDestroy() { + this.eventManager.destroy(this.eventSubscriber); + } + + trackId(index: number, item: IShare) { + return item.id; + } + + registerChangeInShares() { + this.eventSubscriber = this.eventManager.subscribe('shareListModification', response => this.reset()); + } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected paginateShares(data: IShare[], headers: HttpHeaders) { + this.links = this.parseLinks.parse(headers.get('link')); + this.totalItems = parseInt(headers.get('X-Total-Count'), 10); + for (let i = 0; i < data.length; i++) { + this.shares.push(data[i]); + } + } + + protected onError(errorMessage: string) { + this.jhiAlertService.error(errorMessage, null, null); + } +} diff --git a/src/main/webapp/app/entities/share/share.module.ts b/src/main/webapp/app/entities/share/share.module.ts new file mode 100644 index 00000000..9fb07b3a --- /dev/null +++ b/src/main/webapp/app/entities/share/share.module.ts @@ -0,0 +1,34 @@ +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { JhiLanguageService } from 'ng-jhipster'; +import { JhiLanguageHelper } from 'app/core'; + +import { HsadminNgSharedModule } from 'app/shared'; +import { + ShareComponent, + ShareDetailComponent, + ShareUpdateComponent, + ShareDeletePopupComponent, + ShareDeleteDialogComponent, + shareRoute, + sharePopupRoute +} from './'; + +const ENTITY_STATES = [...shareRoute, ...sharePopupRoute]; + +@NgModule({ + imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], + declarations: [ShareComponent, ShareDetailComponent, ShareUpdateComponent, ShareDeleteDialogComponent, ShareDeletePopupComponent], + entryComponents: [ShareComponent, ShareUpdateComponent, ShareDeleteDialogComponent, ShareDeletePopupComponent], + providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], + schemas: [CUSTOM_ELEMENTS_SCHEMA] +}) +export class HsadminNgShareModule { + constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) { + this.languageHelper.language.subscribe((languageKey: string) => { + if (languageKey !== undefined) { + this.languageService.changeLanguage(languageKey); + } + }); + } +} diff --git a/src/main/webapp/app/entities/share/share.route.ts b/src/main/webapp/app/entities/share/share.route.ts new file mode 100644 index 00000000..36f35a5b --- /dev/null +++ b/src/main/webapp/app/entities/share/share.route.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router'; +import { UserRouteAccessService } from 'app/core'; +import { Observable, of } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; +import { Share } from 'app/shared/model/share.model'; +import { ShareService } from './share.service'; +import { ShareComponent } from './share.component'; +import { ShareDetailComponent } from './share-detail.component'; +import { ShareUpdateComponent } from './share-update.component'; +import { ShareDeletePopupComponent } from './share-delete-dialog.component'; +import { IShare } from 'app/shared/model/share.model'; + +@Injectable({ providedIn: 'root' }) +export class ShareResolve implements Resolve { + constructor(private service: ShareService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + const id = route.params['id'] ? route.params['id'] : null; + if (id) { + return this.service.find(id).pipe( + filter((response: HttpResponse) => response.ok), + map((share: HttpResponse) => share.body) + ); + } + return of(new Share()); + } +} + +export const shareRoute: Routes = [ + { + path: '', + component: ShareComponent, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.share.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: ShareDetailComponent, + resolve: { + share: ShareResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.share.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: ShareUpdateComponent, + resolve: { + share: ShareResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.share.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: ShareUpdateComponent, + resolve: { + share: ShareResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.share.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; + +export const sharePopupRoute: Routes = [ + { + path: ':id/delete', + component: ShareDeletePopupComponent, + resolve: { + share: ShareResolve + }, + data: { + authorities: ['ROLE_USER'], + pageTitle: 'hsadminNgApp.share.home.title' + }, + canActivate: [UserRouteAccessService], + outlet: 'popup' + } +]; diff --git a/src/main/webapp/app/entities/share/share.service.ts b/src/main/webapp/app/entities/share/share.service.ts new file mode 100644 index 00000000..d9bf57ec --- /dev/null +++ b/src/main/webapp/app/entities/share/share.service.ts @@ -0,0 +1,77 @@ +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'; +import { IShare } from 'app/shared/model/share.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class ShareService { + public resourceUrl = SERVER_API_URL + 'api/shares'; + + constructor(protected http: HttpClient) {} + + create(share: IShare): Observable { + const copy = this.convertDateFromClient(share); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + update(share: IShare): Observable { + const copy = this.convertDateFromClient(share); + 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' }) + .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' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + protected convertDateFromClient(share: IShare): IShare { + const copy: IShare = Object.assign({}, share, { + documentDate: share.documentDate != null && share.documentDate.isValid() ? share.documentDate.format(DATE_FORMAT) : null, + valueDate: share.valueDate != null && share.valueDate.isValid() ? share.valueDate.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.valueDate = res.body.valueDate != null ? moment(res.body.valueDate) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((share: IShare) => { + share.documentDate = share.documentDate != null ? moment(share.documentDate) : null; + share.valueDate = share.valueDate != null ? moment(share.valueDate) : null; + }); + } + return res; + } +} diff --git a/src/main/webapp/app/layouts/navbar/navbar.component.html b/src/main/webapp/app/layouts/navbar/navbar.component.html index c6c63c64..9ec42f90 100644 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -27,6 +27,36 @@ diff --git a/src/main/webapp/app/shared/model/asset.model.ts b/src/main/webapp/app/shared/model/asset.model.ts new file mode 100644 index 00000000..f5b8f1d1 --- /dev/null +++ b/src/main/webapp/app/shared/model/asset.model.ts @@ -0,0 +1,34 @@ +import { Moment } from 'moment'; + +export const enum AssetAction { + PAYMENT = 'PAYMENT', + HANDOVER = 'HANDOVER', + ADOPTION = 'ADOPTION', + LOSS = 'LOSS', + CLEARING = 'CLEARING', + PAYBACK = 'PAYBACK' +} + +export interface IAsset { + id?: number; + documentDate?: Moment; + valueDate?: Moment; + action?: AssetAction; + amount?: number; + remark?: string; + membershipAdmissionDocumentDate?: string; + membershipId?: number; +} + +export class Asset implements IAsset { + constructor( + public id?: number, + public documentDate?: Moment, + public valueDate?: Moment, + public action?: AssetAction, + public amount?: number, + public remark?: 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 new file mode 100644 index 00000000..884bbce9 --- /dev/null +++ b/src/main/webapp/app/shared/model/customer.model.ts @@ -0,0 +1,58 @@ +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; + billingAddress?: string; + remark?: string; + memberships?: IMembership[]; + sepamandates?: ISepaMandate[]; +} + +export class Customer implements ICustomer { + constructor( + public id?: number, + 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, + public billingAddress?: string, + public remark?: string, + public memberships?: IMembership[], + public sepamandates?: ISepaMandate[] + ) {} +} diff --git a/src/main/webapp/app/shared/model/membership.model.ts b/src/main/webapp/app/shared/model/membership.model.ts new file mode 100644 index 00000000..27bc7e7a --- /dev/null +++ b/src/main/webapp/app/shared/model/membership.model.ts @@ -0,0 +1,31 @@ +import { Moment } from 'moment'; +import { IShare } from 'app/shared/model/share.model'; +import { IAsset } from 'app/shared/model/asset.model'; + +export interface IMembership { + id?: number; + admissionDocumentDate?: Moment; + cancellationDocumentDate?: Moment; + memberFromDate?: Moment; + memberUntilDate?: Moment; + remark?: string; + shares?: IShare[]; + assets?: IAsset[]; + customerPrefix?: string; + customerId?: number; +} + +export class Membership implements IMembership { + constructor( + public id?: number, + public admissionDocumentDate?: Moment, + public cancellationDocumentDate?: Moment, + public memberFromDate?: Moment, + public memberUntilDate?: Moment, + public remark?: string, + public shares?: IShare[], + public assets?: IAsset[], + public customerPrefix?: string, + public customerId?: number + ) {} +} diff --git a/src/main/webapp/app/shared/model/sepa-mandate.model.ts b/src/main/webapp/app/shared/model/sepa-mandate.model.ts new file mode 100644 index 00000000..5edb606f --- /dev/null +++ b/src/main/webapp/app/shared/model/sepa-mandate.model.ts @@ -0,0 +1,33 @@ +import { Moment } from 'moment'; + +export interface ISepaMandate { + id?: number; + reference?: string; + iban?: string; + bic?: string; + grantingDocumentDate?: Moment; + revokationDocumentDate?: Moment; + validFromDate?: Moment; + validUntilDate?: Moment; + lastUsedDate?: Moment; + remark?: string; + customerPrefix?: string; + customerId?: number; +} + +export class SepaMandate implements ISepaMandate { + constructor( + public id?: number, + public reference?: string, + public iban?: string, + public bic?: string, + 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 new file mode 100644 index 00000000..215243a7 --- /dev/null +++ b/src/main/webapp/app/shared/model/share.model.ts @@ -0,0 +1,30 @@ +import { Moment } from 'moment'; + +export const enum ShareAction { + SUBSCRIPTION = 'SUBSCRIPTION', + CANCELLATION = 'CANCELLATION' +} + +export interface IShare { + id?: number; + documentDate?: Moment; + valueDate?: Moment; + action?: ShareAction; + quantity?: number; + remark?: string; + membershipAdmissionDocumentDate?: string; + membershipId?: number; +} + +export class Share implements IShare { + constructor( + public id?: number, + public documentDate?: Moment, + public valueDate?: Moment, + public action?: ShareAction, + public quantity?: number, + public remark?: 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 new file mode 100644 index 00000000..ff6df7e7 --- /dev/null +++ b/src/main/webapp/i18n/de/asset.json @@ -0,0 +1,26 @@ +{ + "hsadminNgApp": { + "asset": { + "home": { + "title": "Assets", + "createLabel": "Asset erstellen", + "createOrEditLabel": "Asset erstellen oder bearbeiten" + }, + "created": "Asset erstellt mit ID {{ param }}", + "updated": "Asset aktualisiert mit ID {{ param }}", + "deleted": "Asset gelöscht mit ID {{ param }}", + "delete": { + "question": "Soll Asset {{ id }} wirklich dauerhaft gelöscht werden?" + }, + "detail": { + "title": "Asset" + }, + "documentDate": "Document Date", + "valueDate": "Value Date", + "action": "Action", + "amount": "Amount", + "remark": "Remark", + "membership": "Membership" + } + } +} diff --git a/src/main/webapp/i18n/de/assetAction.json b/src/main/webapp/i18n/de/assetAction.json new file mode 100644 index 00000000..d3f1ca77 --- /dev/null +++ b/src/main/webapp/i18n/de/assetAction.json @@ -0,0 +1,13 @@ +{ + "hsadminNgApp": { + "AssetAction": { + "null": "", + "PAYMENT": "PAYMENT", + "HANDOVER": "HANDOVER", + "ADOPTION": "ADOPTION", + "LOSS": "LOSS", + "CLEARING": "CLEARING", + "PAYBACK": "PAYBACK" + } + } +} diff --git a/src/main/webapp/i18n/de/customer.json b/src/main/webapp/i18n/de/customer.json new file mode 100644 index 00000000..af18676c --- /dev/null +++ b/src/main/webapp/i18n/de/customer.json @@ -0,0 +1,37 @@ +{ + "hsadminNgApp": { + "customer": { + "home": { + "title": "Customers", + "createLabel": "Customer erstellen", + "createOrEditLabel": "Customer erstellen oder bearbeiten" + }, + "created": "Customer erstellt mit ID {{ param }}", + "updated": "Customer aktualisiert mit ID {{ param }}", + "deleted": "Customer gelöscht mit ID {{ param }}", + "delete": { + "question": "Soll Customer {{ id }} wirklich dauerhaft gelöscht werden?" + }, + "detail": { + "title": "Customer" + }, + "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", + "billingAddress": "Billing Address", + "remark": "Remark", + "membership": "Membership", + "sepamandate": "Sepamandate" + } + } +} 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/global.json b/src/main/webapp/i18n/de/global.json index 58d44f23..45c16b69 100644 --- a/src/main/webapp/i18n/de/global.json +++ b/src/main/webapp/i18n/de/global.json @@ -7,6 +7,11 @@ "jhipster-needle-menu-add-element": "JHipster will add additional menu entries here (do not translate!)", "entities": { "main": "Entitäten", + "customer": "Customer", + "membership": "Membership", + "share": "Share", + "asset": "Asset", + "sepaMandate": "Sepa Mandate", "jhipster-needle-menu-add-entry": "JHipster will add additional entities here (do not translate!)" }, "account": { diff --git a/src/main/webapp/i18n/de/membership.json b/src/main/webapp/i18n/de/membership.json new file mode 100644 index 00000000..e277b4dc --- /dev/null +++ b/src/main/webapp/i18n/de/membership.json @@ -0,0 +1,28 @@ +{ + "hsadminNgApp": { + "membership": { + "home": { + "title": "Memberships", + "createLabel": "Membership erstellen", + "createOrEditLabel": "Membership erstellen oder bearbeiten" + }, + "created": "Membership erstellt mit ID {{ param }}", + "updated": "Membership aktualisiert mit ID {{ param }}", + "deleted": "Membership gelöscht mit ID {{ param }}", + "delete": { + "question": "Soll Membership {{ id }} wirklich dauerhaft gelöscht werden?" + }, + "detail": { + "title": "Membership" + }, + "admissionDocumentDate": "Admission Document Date", + "cancellationDocumentDate": "Cancellation Document Date", + "memberFromDate": "Member From Date", + "memberUntilDate": "Member Until Date", + "remark": "Remark", + "share": "Share", + "asset": "Asset", + "customer": "Customer" + } + } +} diff --git a/src/main/webapp/i18n/de/sepaMandate.json b/src/main/webapp/i18n/de/sepaMandate.json new file mode 100644 index 00000000..f5ea6b73 --- /dev/null +++ b/src/main/webapp/i18n/de/sepaMandate.json @@ -0,0 +1,30 @@ +{ + "hsadminNgApp": { + "sepaMandate": { + "home": { + "title": "Sepa Mandates", + "createLabel": "Sepa Mandate erstellen", + "createOrEditLabel": "Sepa Mandate erstellen oder bearbeiten" + }, + "created": "Sepa Mandate erstellt mit ID {{ param }}", + "updated": "Sepa Mandate aktualisiert mit ID {{ param }}", + "deleted": "Sepa Mandate gelöscht mit ID {{ param }}", + "delete": { + "question": "Soll Sepa Mandate {{ id }} wirklich dauerhaft gelöscht werden?" + }, + "detail": { + "title": "Sepa Mandate" + }, + "reference": "Reference", + "iban": "Iban", + "bic": "Bic", + "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 new file mode 100644 index 00000000..fdb5dec4 --- /dev/null +++ b/src/main/webapp/i18n/de/share.json @@ -0,0 +1,26 @@ +{ + "hsadminNgApp": { + "share": { + "home": { + "title": "Shares", + "createLabel": "Share erstellen", + "createOrEditLabel": "Share erstellen oder bearbeiten" + }, + "created": "Share erstellt mit ID {{ param }}", + "updated": "Share aktualisiert mit ID {{ param }}", + "deleted": "Share gelöscht mit ID {{ param }}", + "delete": { + "question": "Soll Share {{ id }} wirklich dauerhaft gelöscht werden?" + }, + "detail": { + "title": "Share" + }, + "documentDate": "Document Date", + "valueDate": "Value Date", + "action": "Action", + "quantity": "Quantity", + "remark": "Remark", + "membership": "Membership" + } + } +} diff --git a/src/main/webapp/i18n/de/shareAction.json b/src/main/webapp/i18n/de/shareAction.json new file mode 100644 index 00000000..2016c4bb --- /dev/null +++ b/src/main/webapp/i18n/de/shareAction.json @@ -0,0 +1,9 @@ +{ + "hsadminNgApp": { + "ShareAction": { + "null": "", + "SUBSCRIPTION": "SUBSCRIPTION", + "CANCELLATION": "CANCELLATION" + } + } +} 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 new file mode 100644 index 00000000..ac290fb7 --- /dev/null +++ b/src/main/webapp/i18n/en/asset.json @@ -0,0 +1,26 @@ +{ + "hsadminNgApp": { + "asset": { + "home": { + "title": "Assets", + "createLabel": "Create a new Asset", + "createOrEditLabel": "Create or edit a Asset" + }, + "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 }}", + "delete": { + "question": "Are you sure you want to delete Asset {{ id }}?" + }, + "detail": { + "title": "Asset" + }, + "documentDate": "Document Date", + "valueDate": "Value Date", + "action": "Action", + "amount": "Amount", + "remark": "Remark", + "membership": "Membership" + } + } +} diff --git a/src/main/webapp/i18n/en/assetAction.json b/src/main/webapp/i18n/en/assetAction.json new file mode 100644 index 00000000..d3f1ca77 --- /dev/null +++ b/src/main/webapp/i18n/en/assetAction.json @@ -0,0 +1,13 @@ +{ + "hsadminNgApp": { + "AssetAction": { + "null": "", + "PAYMENT": "PAYMENT", + "HANDOVER": "HANDOVER", + "ADOPTION": "ADOPTION", + "LOSS": "LOSS", + "CLEARING": "CLEARING", + "PAYBACK": "PAYBACK" + } + } +} diff --git a/src/main/webapp/i18n/en/customer.json b/src/main/webapp/i18n/en/customer.json new file mode 100644 index 00000000..6444cda2 --- /dev/null +++ b/src/main/webapp/i18n/en/customer.json @@ -0,0 +1,37 @@ +{ + "hsadminNgApp": { + "customer": { + "home": { + "title": "Customers", + "createLabel": "Create a new Customer", + "createOrEditLabel": "Create or edit a Customer" + }, + "created": "A new Customer is created with identifier {{ param }}", + "updated": "A Customer is updated with identifier {{ param }}", + "deleted": "A Customer is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Customer {{ id }}?" + }, + "detail": { + "title": "Customer" + }, + "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", + "billingAddress": "Billing Address", + "remark": "Remark", + "membership": "Membership", + "sepamandate": "Sepamandate" + } + } +} 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/global.json b/src/main/webapp/i18n/en/global.json index e0927808..0e0124c8 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -7,6 +7,11 @@ "jhipster-needle-menu-add-element": "JHipster will add additional menu entries here (do not translate!)", "entities": { "main": "Entities", + "customer": "Customer", + "membership": "Membership", + "share": "Share", + "asset": "Asset", + "sepaMandate": "Sepa Mandate", "jhipster-needle-menu-add-entry": "JHipster will add additional entities here (do not translate!)" }, "account": { diff --git a/src/main/webapp/i18n/en/membership.json b/src/main/webapp/i18n/en/membership.json new file mode 100644 index 00000000..30388671 --- /dev/null +++ b/src/main/webapp/i18n/en/membership.json @@ -0,0 +1,28 @@ +{ + "hsadminNgApp": { + "membership": { + "home": { + "title": "Memberships", + "createLabel": "Create a new Membership", + "createOrEditLabel": "Create or edit a Membership" + }, + "created": "A new Membership is created with identifier {{ param }}", + "updated": "A Membership is updated with identifier {{ param }}", + "deleted": "A Membership is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Membership {{ id }}?" + }, + "detail": { + "title": "Membership" + }, + "admissionDocumentDate": "Admission Document Date", + "cancellationDocumentDate": "Cancellation Document Date", + "memberFromDate": "Member From Date", + "memberUntilDate": "Member Until Date", + "remark": "Remark", + "share": "Share", + "asset": "Asset", + "customer": "Customer" + } + } +} diff --git a/src/main/webapp/i18n/en/sepaMandate.json b/src/main/webapp/i18n/en/sepaMandate.json new file mode 100644 index 00000000..d9aca2be --- /dev/null +++ b/src/main/webapp/i18n/en/sepaMandate.json @@ -0,0 +1,30 @@ +{ + "hsadminNgApp": { + "sepaMandate": { + "home": { + "title": "Sepa Mandates", + "createLabel": "Create a new Sepa Mandate", + "createOrEditLabel": "Create or edit a Sepa Mandate" + }, + "created": "A new Sepa Mandate is created with identifier {{ param }}", + "updated": "A Sepa Mandate is updated with identifier {{ param }}", + "deleted": "A Sepa Mandate is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Sepa Mandate {{ id }}?" + }, + "detail": { + "title": "Sepa Mandate" + }, + "reference": "Reference", + "iban": "Iban", + "bic": "Bic", + "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 new file mode 100644 index 00000000..5c178744 --- /dev/null +++ b/src/main/webapp/i18n/en/share.json @@ -0,0 +1,26 @@ +{ + "hsadminNgApp": { + "share": { + "home": { + "title": "Shares", + "createLabel": "Create a new Share", + "createOrEditLabel": "Create or edit a Share" + }, + "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 }}", + "delete": { + "question": "Are you sure you want to delete Share {{ id }}?" + }, + "detail": { + "title": "Share" + }, + "documentDate": "Document Date", + "valueDate": "Value Date", + "action": "Action", + "quantity": "Quantity", + "remark": "Remark", + "membership": "Membership" + } + } +} diff --git a/src/main/webapp/i18n/en/shareAction.json b/src/main/webapp/i18n/en/shareAction.json new file mode 100644 index 00000000..2016c4bb --- /dev/null +++ b/src/main/webapp/i18n/en/shareAction.json @@ -0,0 +1,9 @@ +{ + "hsadminNgApp": { + "ShareAction": { + "null": "", + "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/web/rest/AssetResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java new file mode 100644 index 00000000..99a0217f --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java @@ -0,0 +1,716 @@ +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.repository.AssetRepository; +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; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.Validator; + +import javax.persistence.EntityManager; +import java.math.BigDecimal; +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.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. + * + * @see AssetResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = HsadminNgApp.class) +public class AssetResourceIntTest { + + 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_VALUE_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALUE_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final AssetAction DEFAULT_ACTION = AssetAction.PAYMENT; + private static final AssetAction UPDATED_ACTION = AssetAction.HANDOVER; + + private static final BigDecimal DEFAULT_AMOUNT = new BigDecimal(1); + private static final BigDecimal UPDATED_AMOUNT = new BigDecimal(2); + + private static final String DEFAULT_REMARK = "AAAAAAAAAA"; + private static final String UPDATED_REMARK = "BBBBBBBBBB"; + + @Autowired + private AssetRepository assetRepository; + + @Autowired + private AssetMapper assetMapper; + + @Autowired + private AssetService assetService; + + @Autowired + private AssetQueryService assetQueryService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restAssetMockMvc; + + private Asset asset; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final AssetResource assetResource = new AssetResource(assetService, assetQueryService); + this.restAssetMockMvc = MockMvcBuilders.standaloneSetup(assetResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Asset createEntity(EntityManager em) { + Asset asset = new Asset() + .documentDate(DEFAULT_DOCUMENT_DATE) + .valueDate(DEFAULT_VALUE_DATE) + .action(DEFAULT_ACTION) + .amount(DEFAULT_AMOUNT) + .remark(DEFAULT_REMARK); + // Add required entity + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); + em.flush(); + asset.setMembership(membership); + return asset; + } + + @Before + public void initTest() { + asset = createEntity(em); + } + + @Test + @Transactional + public void createAsset() throws Exception { + int databaseSizeBeforeCreate = assetRepository.findAll().size(); + + // Create the Asset + AssetDTO assetDTO = assetMapper.toDto(asset); + restAssetMockMvc.perform(post("/api/assets") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(assetDTO))) + .andExpect(status().isCreated()); + + // Validate the Asset in the database + List assetList = assetRepository.findAll(); + assertThat(assetList).hasSize(databaseSizeBeforeCreate + 1); + Asset testAsset = assetList.get(assetList.size() - 1); + assertThat(testAsset.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE); + assertThat(testAsset.getValueDate()).isEqualTo(DEFAULT_VALUE_DATE); + assertThat(testAsset.getAction()).isEqualTo(DEFAULT_ACTION); + assertThat(testAsset.getAmount()).isEqualTo(DEFAULT_AMOUNT); + assertThat(testAsset.getRemark()).isEqualTo(DEFAULT_REMARK); + } + + @Test + @Transactional + public void createAssetWithExistingId() throws Exception { + int databaseSizeBeforeCreate = assetRepository.findAll().size(); + + // Create the Asset with an existing ID + asset.setId(1L); + AssetDTO assetDTO = assetMapper.toDto(asset); + + // An entity with an existing ID cannot be created, so this API call must fail + restAssetMockMvc.perform(post("/api/assets") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(assetDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Asset in the database + List assetList = assetRepository.findAll(); + assertThat(assetList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void checkDocumentDateIsRequired() throws Exception { + int databaseSizeBeforeTest = assetRepository.findAll().size(); + // set the field null + asset.setDocumentDate(null); + + // Create the Asset, which fails. + AssetDTO assetDTO = assetMapper.toDto(asset); + + restAssetMockMvc.perform(post("/api/assets") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(assetDTO))) + .andExpect(status().isBadRequest()); + + List assetList = assetRepository.findAll(); + assertThat(assetList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkValueDateIsRequired() throws Exception { + int databaseSizeBeforeTest = assetRepository.findAll().size(); + // set the field null + asset.setValueDate(null); + + // Create the Asset, which fails. + AssetDTO assetDTO = assetMapper.toDto(asset); + + restAssetMockMvc.perform(post("/api/assets") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(assetDTO))) + .andExpect(status().isBadRequest()); + + List assetList = assetRepository.findAll(); + assertThat(assetList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkActionIsRequired() throws Exception { + int databaseSizeBeforeTest = assetRepository.findAll().size(); + // set the field null + asset.setAction(null); + + // Create the Asset, which fails. + AssetDTO assetDTO = assetMapper.toDto(asset); + + restAssetMockMvc.perform(post("/api/assets") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(assetDTO))) + .andExpect(status().isBadRequest()); + + List assetList = assetRepository.findAll(); + assertThat(assetList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkAmountIsRequired() throws Exception { + int databaseSizeBeforeTest = assetRepository.findAll().size(); + // set the field null + asset.setAmount(null); + + // Create the Asset, which fails. + AssetDTO assetDTO = assetMapper.toDto(asset); + + restAssetMockMvc.perform(post("/api/assets") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(assetDTO))) + .andExpect(status().isBadRequest()); + + List assetList = assetRepository.findAll(); + assertThat(assetList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllAssets() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList + restAssetMockMvc.perform(get("/api/assets?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(asset.getId().intValue()))) + .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString()))) + .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString()))) + .andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue()))) + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); + } + + @Test + @Transactional + public void getAsset() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get the asset + restAssetMockMvc.perform(get("/api/assets/{id}", asset.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(asset.getId().intValue())) + .andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.valueDate").value(DEFAULT_VALUE_DATE.toString())) + .andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString())) + .andExpect(jsonPath("$.amount").value(DEFAULT_AMOUNT.intValue())) + .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); + } + + @Test + @Transactional + public void getAllAssetsByDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where documentDate equals to DEFAULT_DOCUMENT_DATE + defaultAssetShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); + + // Get all the assetList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultAssetShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllAssetsByDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE + defaultAssetShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE); + + // Get all the assetList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultAssetShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllAssetsByDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where documentDate is not null + defaultAssetShouldBeFound("documentDate.specified=true"); + + // Get all the assetList where documentDate is null + defaultAssetShouldNotBeFound("documentDate.specified=false"); + } + + @Test + @Transactional + public void getAllAssetsByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE + defaultAssetShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the assetList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE + defaultAssetShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllAssetsByDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE + defaultAssetShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the assetList where documentDate less than or equals to UPDATED_DOCUMENT_DATE + defaultAssetShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllAssetsByValueDateIsEqualToSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where valueDate equals to DEFAULT_VALUE_DATE + defaultAssetShouldBeFound("valueDate.equals=" + DEFAULT_VALUE_DATE); + + // Get all the assetList where valueDate equals to UPDATED_VALUE_DATE + defaultAssetShouldNotBeFound("valueDate.equals=" + UPDATED_VALUE_DATE); + } + + @Test + @Transactional + public void getAllAssetsByValueDateIsInShouldWork() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where valueDate in DEFAULT_VALUE_DATE or UPDATED_VALUE_DATE + defaultAssetShouldBeFound("valueDate.in=" + DEFAULT_VALUE_DATE + "," + UPDATED_VALUE_DATE); + + // Get all the assetList where valueDate equals to UPDATED_VALUE_DATE + defaultAssetShouldNotBeFound("valueDate.in=" + UPDATED_VALUE_DATE); + } + + @Test + @Transactional + public void getAllAssetsByValueDateIsNullOrNotNull() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where valueDate is not null + defaultAssetShouldBeFound("valueDate.specified=true"); + + // Get all the assetList where valueDate is null + defaultAssetShouldNotBeFound("valueDate.specified=false"); + } + + @Test + @Transactional + public void getAllAssetsByValueDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where valueDate greater than or equals to DEFAULT_VALUE_DATE + defaultAssetShouldBeFound("valueDate.greaterOrEqualThan=" + DEFAULT_VALUE_DATE); + + // Get all the assetList where valueDate greater than or equals to UPDATED_VALUE_DATE + defaultAssetShouldNotBeFound("valueDate.greaterOrEqualThan=" + UPDATED_VALUE_DATE); + } + + @Test + @Transactional + public void getAllAssetsByValueDateIsLessThanSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where valueDate less than or equals to DEFAULT_VALUE_DATE + defaultAssetShouldNotBeFound("valueDate.lessThan=" + DEFAULT_VALUE_DATE); + + // Get all the assetList where valueDate less than or equals to UPDATED_VALUE_DATE + defaultAssetShouldBeFound("valueDate.lessThan=" + UPDATED_VALUE_DATE); + } + + + @Test + @Transactional + public void getAllAssetsByActionIsEqualToSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where action equals to DEFAULT_ACTION + defaultAssetShouldBeFound("action.equals=" + DEFAULT_ACTION); + + // Get all the assetList where action equals to UPDATED_ACTION + defaultAssetShouldNotBeFound("action.equals=" + UPDATED_ACTION); + } + + @Test + @Transactional + public void getAllAssetsByActionIsInShouldWork() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where action in DEFAULT_ACTION or UPDATED_ACTION + defaultAssetShouldBeFound("action.in=" + DEFAULT_ACTION + "," + UPDATED_ACTION); + + // Get all the assetList where action equals to UPDATED_ACTION + defaultAssetShouldNotBeFound("action.in=" + UPDATED_ACTION); + } + + @Test + @Transactional + public void getAllAssetsByActionIsNullOrNotNull() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where action is not null + defaultAssetShouldBeFound("action.specified=true"); + + // Get all the assetList where action is null + defaultAssetShouldNotBeFound("action.specified=false"); + } + + @Test + @Transactional + public void getAllAssetsByAmountIsEqualToSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where amount equals to DEFAULT_AMOUNT + defaultAssetShouldBeFound("amount.equals=" + DEFAULT_AMOUNT); + + // Get all the assetList where amount equals to UPDATED_AMOUNT + defaultAssetShouldNotBeFound("amount.equals=" + UPDATED_AMOUNT); + } + + @Test + @Transactional + public void getAllAssetsByAmountIsInShouldWork() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where amount in DEFAULT_AMOUNT or UPDATED_AMOUNT + defaultAssetShouldBeFound("amount.in=" + DEFAULT_AMOUNT + "," + UPDATED_AMOUNT); + + // Get all the assetList where amount equals to UPDATED_AMOUNT + defaultAssetShouldNotBeFound("amount.in=" + UPDATED_AMOUNT); + } + + @Test + @Transactional + public void getAllAssetsByAmountIsNullOrNotNull() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where amount is not null + defaultAssetShouldBeFound("amount.specified=true"); + + // Get all the assetList where amount is null + defaultAssetShouldNotBeFound("amount.specified=false"); + } + + @Test + @Transactional + public void getAllAssetsByRemarkIsEqualToSomething() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where remark equals to DEFAULT_REMARK + defaultAssetShouldBeFound("remark.equals=" + DEFAULT_REMARK); + + // Get all the assetList where remark equals to UPDATED_REMARK + defaultAssetShouldNotBeFound("remark.equals=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllAssetsByRemarkIsInShouldWork() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where remark in DEFAULT_REMARK or UPDATED_REMARK + defaultAssetShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK); + + // Get all the assetList where remark equals to UPDATED_REMARK + defaultAssetShouldNotBeFound("remark.in=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllAssetsByRemarkIsNullOrNotNull() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + // Get all the assetList where remark is not null + defaultAssetShouldBeFound("remark.specified=true"); + + // Get all the assetList where remark is null + defaultAssetShouldNotBeFound("remark.specified=false"); + } + + @Test + @Transactional + public void getAllAssetsByMembershipIsEqualToSomething() throws Exception { + // Initialize the database + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); + em.flush(); + asset.setMembership(membership); + assetRepository.saveAndFlush(asset); + Long membershipId = membership.getId(); + + // Get all the assetList where membership equals to membershipId + defaultAssetShouldBeFound("membershipId.equals=" + membershipId); + + // Get all the assetList where membership equals to membershipId + 1 + defaultAssetShouldNotBeFound("membershipId.equals=" + (membershipId + 1)); + } + + /** + * Executes the search, and checks that the default entity is returned + */ + private void defaultAssetShouldBeFound(String filter) throws Exception { + restAssetMockMvc.perform(get("/api/assets?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(asset.getId().intValue()))) + .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString()))) + .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString()))) + .andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue()))) + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK))); + + // Check, that the count call also returns 1 + restAssetMockMvc.perform(get("/api/assets/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned + */ + private void defaultAssetShouldNotBeFound(String filter) throws Exception { + restAssetMockMvc.perform(get("/api/assets?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restAssetMockMvc.perform(get("/api/assets/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("0")); + } + + + @Test + @Transactional + public void getNonExistingAsset() throws Exception { + // Get the asset + restAssetMockMvc.perform(get("/api/assets/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateAsset() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + int databaseSizeBeforeUpdate = assetRepository.findAll().size(); + + // Update the asset + Asset updatedAsset = assetRepository.findById(asset.getId()).get(); + // Disconnect from session so that the updates on updatedAsset are not directly saved in db + em.detach(updatedAsset); + updatedAsset + .documentDate(UPDATED_DOCUMENT_DATE) + .valueDate(UPDATED_VALUE_DATE) + .action(UPDATED_ACTION) + .amount(UPDATED_AMOUNT) + .remark(UPDATED_REMARK); + AssetDTO assetDTO = assetMapper.toDto(updatedAsset); + + restAssetMockMvc.perform(put("/api/assets") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(assetDTO))) + .andExpect(status().isOk()); + + // 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); + } + + @Test + @Transactional + public void updateNonExistingAsset() throws Exception { + int databaseSizeBeforeUpdate = assetRepository.findAll().size(); + + // Create the Asset + AssetDTO assetDTO = assetMapper.toDto(asset); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restAssetMockMvc.perform(put("/api/assets") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(assetDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Asset in the database + List assetList = assetRepository.findAll(); + assertThat(assetList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteAsset() throws Exception { + // Initialize the database + assetRepository.saveAndFlush(asset); + + int databaseSizeBeforeDelete = assetRepository.findAll().size(); + + // Delete the asset + restAssetMockMvc.perform(delete("/api/assets/{id}", asset.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List assetList = assetRepository.findAll(); + assertThat(assetList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Asset.class); + Asset asset1 = new Asset(); + asset1.setId(1L); + Asset asset2 = new Asset(); + asset2.setId(asset1.getId()); + assertThat(asset1).isEqualTo(asset2); + asset2.setId(2L); + assertThat(asset1).isNotEqualTo(asset2); + asset1.setId(null); + assertThat(asset1).isNotEqualTo(asset2); + } + + @Test + @Transactional + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(AssetDTO.class); + AssetDTO assetDTO1 = new AssetDTO(); + assetDTO1.setId(1L); + AssetDTO assetDTO2 = new AssetDTO(); + assertThat(assetDTO1).isNotEqualTo(assetDTO2); + assetDTO2.setId(assetDTO1.getId()); + assertThat(assetDTO1).isEqualTo(assetDTO2); + assetDTO2.setId(2L); + assertThat(assetDTO1).isNotEqualTo(assetDTO2); + assetDTO1.setId(null); + assertThat(assetDTO1).isNotEqualTo(assetDTO2); + } + + @Test + @Transactional + public void testEntityFromId() { + assertThat(assetMapper.fromId(42L).getId()).isEqualTo(42); + assertThat(assetMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java new file mode 100644 index 00000000..d26c25bf --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java @@ -0,0 +1,1259 @@ +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.repository.CustomerRepository; +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; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +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.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import org.hostsharing.hsadminng.domain.enumeration.CustomerKind; +import org.hostsharing.hsadminng.domain.enumeration.VatRegion; +/** + * Test class for the CustomerResource REST controller. + * + * @see CustomerResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = HsadminNgApp.class) +public class CustomerResourceIntTest { + + private static final Integer DEFAULT_REFERENCE = 10000; + private static final Integer UPDATED_REFERENCE = 10001; + + private static final String DEFAULT_PREFIX = "nw"; + private static final String UPDATED_PREFIX = "jq"; + + private static final String DEFAULT_NAME = "AAAAAAAAAA"; + private static final String UPDATED_NAME = "BBBBBBBBBB"; + + private static final CustomerKind DEFAULT_KIND = CustomerKind.NATURAL; + private static final CustomerKind UPDATED_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 String DEFAULT_VAT_NUMBER = "AAAAAAAAAA"; + private static final String UPDATED_VAT_NUMBER = "BBBBBBBBBB"; + + private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA"; + private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB"; + + private static final String DEFAULT_CONTRACTUAL_ADDRESS = "AAAAAAAAAA"; + private static final String UPDATED_CONTRACTUAL_ADDRESS = "BBBBBBBBBB"; + + private static final String DEFAULT_BILLING_SALUTATION = "AAAAAAAAAA"; + private static final String UPDATED_BILLING_SALUTATION = "BBBBBBBBBB"; + + private static final String DEFAULT_BILLING_ADDRESS = "AAAAAAAAAA"; + private static final String UPDATED_BILLING_ADDRESS = "BBBBBBBBBB"; + + private static final String DEFAULT_REMARK = "AAAAAAAAAA"; + private static final String UPDATED_REMARK = "BBBBBBBBBB"; + + @Autowired + private CustomerRepository customerRepository; + + @Autowired + private CustomerMapper customerMapper; + + @Autowired + private CustomerService customerService; + + @Autowired + private CustomerQueryService customerQueryService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restCustomerMockMvc; + + private Customer customer; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final CustomerResource customerResource = new CustomerResource(customerService, customerQueryService); + this.restCustomerMockMvc = MockMvcBuilders.standaloneSetup(customerResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Customer createEntity(EntityManager em) { + Customer customer = new Customer() + .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) + .billingAddress(DEFAULT_BILLING_ADDRESS) + .remark(DEFAULT_REMARK); + return customer; + } + + @Before + public void initTest() { + customer = createEntity(em); + } + + @Test + @Transactional + public void createCustomer() throws Exception { + int databaseSizeBeforeCreate = customerRepository.findAll().size(); + + // Create the Customer + CustomerDTO customerDTO = customerMapper.toDto(customer); + restCustomerMockMvc.perform(post("/api/customers") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(customerDTO))) + .andExpect(status().isCreated()); + + // Validate the Customer in the database + List customerList = customerRepository.findAll(); + assertThat(customerList).hasSize(databaseSizeBeforeCreate + 1); + Customer testCustomer = customerList.get(customerList.size() - 1); + 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); + assertThat(testCustomer.getBillingAddress()).isEqualTo(DEFAULT_BILLING_ADDRESS); + assertThat(testCustomer.getRemark()).isEqualTo(DEFAULT_REMARK); + } + + @Test + @Transactional + public void createCustomerWithExistingId() throws Exception { + int databaseSizeBeforeCreate = customerRepository.findAll().size(); + + // Create the Customer with an existing ID + customer.setId(1L); + CustomerDTO customerDTO = customerMapper.toDto(customer); + + // An entity with an existing ID cannot be created, so this API call must fail + restCustomerMockMvc.perform(post("/api/customers") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(customerDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Customer in the database + List customerList = customerRepository.findAll(); + assertThat(customerList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void checkReferenceIsRequired() throws Exception { + int databaseSizeBeforeTest = customerRepository.findAll().size(); + // set the field null + customer.setReference(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 checkPrefixIsRequired() throws Exception { + int databaseSizeBeforeTest = customerRepository.findAll().size(); + // set the field null + customer.setPrefix(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 checkNameIsRequired() throws Exception { + int databaseSizeBeforeTest = customerRepository.findAll().size(); + // set the field null + customer.setName(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 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 { + int databaseSizeBeforeTest = customerRepository.findAll().size(); + // set the field null + customer.setContractualAddress(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 getAllCustomers() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList + restCustomerMockMvc.perform(get("/api/customers?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(customer.getId().intValue()))) + .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()))) + .andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS.toString()))) + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); + } + + @Test + @Transactional + public void getCustomer() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get the customer + restCustomerMockMvc.perform(get("/api/customers/{id}", customer.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(customer.getId().intValue())) + .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())) + .andExpect(jsonPath("$.billingAddress").value(DEFAULT_BILLING_ADDRESS.toString())) + .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); + } + + @Test + @Transactional + public void getAllCustomersByReferenceIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where reference equals to DEFAULT_REFERENCE + defaultCustomerShouldBeFound("reference.equals=" + DEFAULT_REFERENCE); + + // Get all the customerList where reference equals to UPDATED_REFERENCE + defaultCustomerShouldNotBeFound("reference.equals=" + UPDATED_REFERENCE); + } + + @Test + @Transactional + public void getAllCustomersByReferenceIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where reference in DEFAULT_REFERENCE or UPDATED_REFERENCE + defaultCustomerShouldBeFound("reference.in=" + DEFAULT_REFERENCE + "," + UPDATED_REFERENCE); + + // Get all the customerList where reference equals to UPDATED_REFERENCE + defaultCustomerShouldNotBeFound("reference.in=" + UPDATED_REFERENCE); + } + + @Test + @Transactional + public void getAllCustomersByReferenceIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where reference is not null + defaultCustomerShouldBeFound("reference.specified=true"); + + // Get all the customerList where reference is null + defaultCustomerShouldNotBeFound("reference.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByReferenceIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where reference greater than or equals to DEFAULT_REFERENCE + defaultCustomerShouldBeFound("reference.greaterOrEqualThan=" + DEFAULT_REFERENCE); + + // Get all the customerList where reference greater than or equals to (DEFAULT_REFERENCE + 1) + defaultCustomerShouldNotBeFound("reference.greaterOrEqualThan=" + (DEFAULT_REFERENCE + 1)); + } + + @Test + @Transactional + public void getAllCustomersByReferenceIsLessThanSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where reference less than or equals to DEFAULT_REFERENCE + defaultCustomerShouldNotBeFound("reference.lessThan=" + DEFAULT_REFERENCE); + + // Get all the customerList where reference less than or equals to (DEFAULT_REFERENCE + 1) + defaultCustomerShouldBeFound("reference.lessThan=" + (DEFAULT_REFERENCE + 1)); + } + + + @Test + @Transactional + public void getAllCustomersByPrefixIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where prefix equals to DEFAULT_PREFIX + defaultCustomerShouldBeFound("prefix.equals=" + DEFAULT_PREFIX); + + // Get all the customerList where prefix equals to UPDATED_PREFIX + defaultCustomerShouldNotBeFound("prefix.equals=" + UPDATED_PREFIX); + } + + @Test + @Transactional + public void getAllCustomersByPrefixIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where prefix in DEFAULT_PREFIX or UPDATED_PREFIX + defaultCustomerShouldBeFound("prefix.in=" + DEFAULT_PREFIX + "," + UPDATED_PREFIX); + + // Get all the customerList where prefix equals to UPDATED_PREFIX + defaultCustomerShouldNotBeFound("prefix.in=" + UPDATED_PREFIX); + } + + @Test + @Transactional + public void getAllCustomersByPrefixIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where prefix is not null + defaultCustomerShouldBeFound("prefix.specified=true"); + + // Get all the customerList where prefix is null + defaultCustomerShouldNotBeFound("prefix.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByNameIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where name equals to DEFAULT_NAME + defaultCustomerShouldBeFound("name.equals=" + DEFAULT_NAME); + + // Get all the customerList where name equals to UPDATED_NAME + defaultCustomerShouldNotBeFound("name.equals=" + UPDATED_NAME); + } + + @Test + @Transactional + public void getAllCustomersByNameIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where name in DEFAULT_NAME or UPDATED_NAME + defaultCustomerShouldBeFound("name.in=" + DEFAULT_NAME + "," + UPDATED_NAME); + + // Get all the customerList where name equals to UPDATED_NAME + defaultCustomerShouldNotBeFound("name.in=" + UPDATED_NAME); + } + + @Test + @Transactional + public void getAllCustomersByNameIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where name is not null + defaultCustomerShouldBeFound("name.specified=true"); + + // Get all the customerList where name is null + 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 { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where contractualSalutation equals to DEFAULT_CONTRACTUAL_SALUTATION + defaultCustomerShouldBeFound("contractualSalutation.equals=" + DEFAULT_CONTRACTUAL_SALUTATION); + + // Get all the customerList where contractualSalutation equals to UPDATED_CONTRACTUAL_SALUTATION + defaultCustomerShouldNotBeFound("contractualSalutation.equals=" + UPDATED_CONTRACTUAL_SALUTATION); + } + + @Test + @Transactional + public void getAllCustomersByContractualSalutationIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where contractualSalutation in DEFAULT_CONTRACTUAL_SALUTATION or UPDATED_CONTRACTUAL_SALUTATION + defaultCustomerShouldBeFound("contractualSalutation.in=" + DEFAULT_CONTRACTUAL_SALUTATION + "," + UPDATED_CONTRACTUAL_SALUTATION); + + // Get all the customerList where contractualSalutation equals to UPDATED_CONTRACTUAL_SALUTATION + defaultCustomerShouldNotBeFound("contractualSalutation.in=" + UPDATED_CONTRACTUAL_SALUTATION); + } + + @Test + @Transactional + public void getAllCustomersByContractualSalutationIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where contractualSalutation is not null + defaultCustomerShouldBeFound("contractualSalutation.specified=true"); + + // Get all the customerList where contractualSalutation is null + defaultCustomerShouldNotBeFound("contractualSalutation.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByContractualAddressIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where contractualAddress equals to DEFAULT_CONTRACTUAL_ADDRESS + defaultCustomerShouldBeFound("contractualAddress.equals=" + DEFAULT_CONTRACTUAL_ADDRESS); + + // Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldNotBeFound("contractualAddress.equals=" + UPDATED_CONTRACTUAL_ADDRESS); + } + + @Test + @Transactional + public void getAllCustomersByContractualAddressIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where contractualAddress in DEFAULT_CONTRACTUAL_ADDRESS or UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldBeFound("contractualAddress.in=" + DEFAULT_CONTRACTUAL_ADDRESS + "," + UPDATED_CONTRACTUAL_ADDRESS); + + // Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldNotBeFound("contractualAddress.in=" + UPDATED_CONTRACTUAL_ADDRESS); + } + + @Test + @Transactional + public void getAllCustomersByContractualAddressIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where contractualAddress is not null + defaultCustomerShouldBeFound("contractualAddress.specified=true"); + + // Get all the customerList where contractualAddress is null + defaultCustomerShouldNotBeFound("contractualAddress.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByBillingSalutationIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where billingSalutation equals to DEFAULT_BILLING_SALUTATION + defaultCustomerShouldBeFound("billingSalutation.equals=" + DEFAULT_BILLING_SALUTATION); + + // Get all the customerList where billingSalutation equals to UPDATED_BILLING_SALUTATION + defaultCustomerShouldNotBeFound("billingSalutation.equals=" + UPDATED_BILLING_SALUTATION); + } + + @Test + @Transactional + public void getAllCustomersByBillingSalutationIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where billingSalutation in DEFAULT_BILLING_SALUTATION or UPDATED_BILLING_SALUTATION + defaultCustomerShouldBeFound("billingSalutation.in=" + DEFAULT_BILLING_SALUTATION + "," + UPDATED_BILLING_SALUTATION); + + // Get all the customerList where billingSalutation equals to UPDATED_BILLING_SALUTATION + defaultCustomerShouldNotBeFound("billingSalutation.in=" + UPDATED_BILLING_SALUTATION); + } + + @Test + @Transactional + public void getAllCustomersByBillingSalutationIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where billingSalutation is not null + defaultCustomerShouldBeFound("billingSalutation.specified=true"); + + // Get all the customerList where billingSalutation is null + defaultCustomerShouldNotBeFound("billingSalutation.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where billingAddress equals to DEFAULT_BILLING_ADDRESS + defaultCustomerShouldBeFound("billingAddress.equals=" + DEFAULT_BILLING_ADDRESS); + + // Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS + defaultCustomerShouldNotBeFound("billingAddress.equals=" + UPDATED_BILLING_ADDRESS); + } + + @Test + @Transactional + public void getAllCustomersByBillingAddressIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where billingAddress in DEFAULT_BILLING_ADDRESS or UPDATED_BILLING_ADDRESS + defaultCustomerShouldBeFound("billingAddress.in=" + DEFAULT_BILLING_ADDRESS + "," + UPDATED_BILLING_ADDRESS); + + // Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS + defaultCustomerShouldNotBeFound("billingAddress.in=" + UPDATED_BILLING_ADDRESS); + } + + @Test + @Transactional + public void getAllCustomersByBillingAddressIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where billingAddress is not null + defaultCustomerShouldBeFound("billingAddress.specified=true"); + + // Get all the customerList where billingAddress is null + defaultCustomerShouldNotBeFound("billingAddress.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByRemarkIsEqualToSomething() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where remark equals to DEFAULT_REMARK + defaultCustomerShouldBeFound("remark.equals=" + DEFAULT_REMARK); + + // Get all the customerList where remark equals to UPDATED_REMARK + defaultCustomerShouldNotBeFound("remark.equals=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllCustomersByRemarkIsInShouldWork() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where remark in DEFAULT_REMARK or UPDATED_REMARK + defaultCustomerShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK); + + // Get all the customerList where remark equals to UPDATED_REMARK + defaultCustomerShouldNotBeFound("remark.in=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllCustomersByRemarkIsNullOrNotNull() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + // Get all the customerList where remark is not null + defaultCustomerShouldBeFound("remark.specified=true"); + + // Get all the customerList where remark is null + defaultCustomerShouldNotBeFound("remark.specified=false"); + } + + @Test + @Transactional + public void getAllCustomersByMembershipIsEqualToSomething() throws Exception { + // Initialize the database + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); + em.flush(); + customer.addMembership(membership); + customerRepository.saveAndFlush(customer); + Long membershipId = membership.getId(); + + // Get all the customerList where membership equals to membershipId + defaultCustomerShouldBeFound("membershipId.equals=" + membershipId); + + // Get all the customerList where membership equals to membershipId + 1 + defaultCustomerShouldNotBeFound("membershipId.equals=" + (membershipId + 1)); + } + + + @Test + @Transactional + public void getAllCustomersBySepamandateIsEqualToSomething() throws Exception { + // Initialize the database + SepaMandate sepamandate = SepaMandateResourceIntTest.createEntity(em); + em.persist(sepamandate); + em.flush(); + customer.addSepamandate(sepamandate); + customerRepository.saveAndFlush(customer); + Long sepamandateId = sepamandate.getId(); + + // Get all the customerList where sepamandate equals to sepamandateId + defaultCustomerShouldBeFound("sepamandateId.equals=" + sepamandateId); + + // Get all the customerList where sepamandate equals to sepamandateId + 1 + defaultCustomerShouldNotBeFound("sepamandateId.equals=" + (sepamandateId + 1)); + } + + /** + * Executes the search, and checks that the default entity is returned + */ + private void defaultCustomerShouldBeFound(String filter) throws Exception { + restCustomerMockMvc.perform(get("/api/customers?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(customer.getId().intValue()))) + .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))) + .andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS))) + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK))); + + // Check, that the count call also returns 1 + restCustomerMockMvc.perform(get("/api/customers/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned + */ + private void defaultCustomerShouldNotBeFound(String filter) throws Exception { + restCustomerMockMvc.perform(get("/api/customers?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restCustomerMockMvc.perform(get("/api/customers/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("0")); + } + + + @Test + @Transactional + public void getNonExistingCustomer() throws Exception { + // Get the customer + restCustomerMockMvc.perform(get("/api/customers/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateCustomer() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + int databaseSizeBeforeUpdate = customerRepository.findAll().size(); + + // Update the customer + Customer updatedCustomer = customerRepository.findById(customer.getId()).get(); + // Disconnect from session so that the updates on updatedCustomer are not directly saved in db + em.detach(updatedCustomer); + updatedCustomer + .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) + .billingAddress(UPDATED_BILLING_ADDRESS) + .remark(UPDATED_REMARK); + CustomerDTO customerDTO = customerMapper.toDto(updatedCustomer); + + restCustomerMockMvc.perform(put("/api/customers") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(customerDTO))) + .andExpect(status().isOk()); + + // Validate the Customer in the database + List customerList = customerRepository.findAll(); + assertThat(customerList).hasSize(databaseSizeBeforeUpdate); + Customer testCustomer = customerList.get(customerList.size() - 1); + 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); + assertThat(testCustomer.getBillingAddress()).isEqualTo(UPDATED_BILLING_ADDRESS); + assertThat(testCustomer.getRemark()).isEqualTo(UPDATED_REMARK); + } + + @Test + @Transactional + public void updateNonExistingCustomer() throws Exception { + int databaseSizeBeforeUpdate = customerRepository.findAll().size(); + + // Create the Customer + CustomerDTO customerDTO = customerMapper.toDto(customer); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restCustomerMockMvc.perform(put("/api/customers") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(customerDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Customer in the database + List customerList = customerRepository.findAll(); + assertThat(customerList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteCustomer() throws Exception { + // Initialize the database + customerRepository.saveAndFlush(customer); + + int databaseSizeBeforeDelete = customerRepository.findAll().size(); + + // Delete the customer + restCustomerMockMvc.perform(delete("/api/customers/{id}", customer.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List customerList = customerRepository.findAll(); + assertThat(customerList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Customer.class); + Customer customer1 = new Customer(); + customer1.setId(1L); + Customer customer2 = new Customer(); + customer2.setId(customer1.getId()); + assertThat(customer1).isEqualTo(customer2); + customer2.setId(2L); + assertThat(customer1).isNotEqualTo(customer2); + customer1.setId(null); + assertThat(customer1).isNotEqualTo(customer2); + } + + @Test + @Transactional + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(CustomerDTO.class); + CustomerDTO customerDTO1 = new CustomerDTO(); + customerDTO1.setId(1L); + CustomerDTO customerDTO2 = new CustomerDTO(); + assertThat(customerDTO1).isNotEqualTo(customerDTO2); + customerDTO2.setId(customerDTO1.getId()); + assertThat(customerDTO1).isEqualTo(customerDTO2); + customerDTO2.setId(2L); + assertThat(customerDTO1).isNotEqualTo(customerDTO2); + customerDTO1.setId(null); + assertThat(customerDTO1).isNotEqualTo(customerDTO2); + } + + @Test + @Transactional + public void testEntityFromId() { + assertThat(customerMapper.fromId(42L).getId()).isEqualTo(42); + assertThat(customerMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java new file mode 100644 index 00000000..2a726eb9 --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java @@ -0,0 +1,770 @@ +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.repository.MembershipRepository; +import org.hostsharing.hsadminng.service.MembershipService; +import org.hostsharing.hsadminng.service.dto.MembershipDTO; +import org.hostsharing.hsadminng.service.mapper.MembershipMapper; +import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.MembershipCriteria; +import org.hostsharing.hsadminng.service.MembershipQueryService; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +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.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the MembershipResource REST controller. + * + * @see MembershipResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = HsadminNgApp.class) +public class MembershipResourceIntTest { + + private static final LocalDate DEFAULT_ADMISSION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_ADMISSION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_CANCELLATION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_CANCELLATION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_MEMBER_FROM_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_MEMBER_FROM_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_MEMBER_UNTIL_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_MEMBER_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final String DEFAULT_REMARK = "AAAAAAAAAA"; + private static final String UPDATED_REMARK = "BBBBBBBBBB"; + + @Autowired + private MembershipRepository membershipRepository; + + @Autowired + private MembershipMapper membershipMapper; + + @Autowired + private MembershipService membershipService; + + @Autowired + private MembershipQueryService membershipQueryService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restMembershipMockMvc; + + private Membership membership; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final MembershipResource membershipResource = new MembershipResource(membershipService, membershipQueryService); + this.restMembershipMockMvc = MockMvcBuilders.standaloneSetup(membershipResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Membership createEntity(EntityManager em) { + Membership membership = new Membership() + .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); + em.persist(customer); + em.flush(); + membership.setCustomer(customer); + return membership; + } + + @Before + public void initTest() { + membership = createEntity(em); + } + + @Test + @Transactional + public void createMembership() throws Exception { + int databaseSizeBeforeCreate = membershipRepository.findAll().size(); + + // Create the Membership + MembershipDTO membershipDTO = membershipMapper.toDto(membership); + restMembershipMockMvc.perform(post("/api/memberships") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(membershipDTO))) + .andExpect(status().isCreated()); + + // Validate the Membership in the database + List membershipList = membershipRepository.findAll(); + assertThat(membershipList).hasSize(databaseSizeBeforeCreate + 1); + Membership testMembership = membershipList.get(membershipList.size() - 1); + 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); + } + + @Test + @Transactional + public void createMembershipWithExistingId() throws Exception { + int databaseSizeBeforeCreate = membershipRepository.findAll().size(); + + // Create the Membership with an existing ID + membership.setId(1L); + MembershipDTO membershipDTO = membershipMapper.toDto(membership); + + // An entity with an existing ID cannot be created, so this API call must fail + restMembershipMockMvc.perform(post("/api/memberships") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(membershipDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Membership in the database + List membershipList = membershipRepository.findAll(); + assertThat(membershipList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void checkAdmissionDocumentDateIsRequired() throws Exception { + int databaseSizeBeforeTest = membershipRepository.findAll().size(); + // set the field null + membership.setAdmissionDocumentDate(null); + + // Create the Membership, which fails. + MembershipDTO membershipDTO = membershipMapper.toDto(membership); + + restMembershipMockMvc.perform(post("/api/memberships") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(membershipDTO))) + .andExpect(status().isBadRequest()); + + List membershipList = membershipRepository.findAll(); + assertThat(membershipList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkMemberFromDateIsRequired() throws Exception { + int databaseSizeBeforeTest = membershipRepository.findAll().size(); + // set the field null + membership.setMemberFromDate(null); + + // Create the Membership, which fails. + MembershipDTO membershipDTO = membershipMapper.toDto(membership); + + restMembershipMockMvc.perform(post("/api/memberships") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(membershipDTO))) + .andExpect(status().isBadRequest()); + + List membershipList = membershipRepository.findAll(); + assertThat(membershipList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllMemberships() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList + restMembershipMockMvc.perform(get("/api/memberships?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue()))) + .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 { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get the membership + restMembershipMockMvc.perform(get("/api/memberships/{id}", membership.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(membership.getId().intValue())) + .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 getAllMembershipsByAdmissionDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where admissionDocumentDate equals to DEFAULT_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldBeFound("admissionDocumentDate.equals=" + DEFAULT_ADMISSION_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 getAllMembershipsByAdmissionDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 admissionDocumentDate equals to UPDATED_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("admissionDocumentDate.in=" + UPDATED_ADMISSION_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByAdmissionDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where admissionDocumentDate is not null + defaultMembershipShouldBeFound("admissionDocumentDate.specified=true"); + + // Get all the membershipList where admissionDocumentDate is null + defaultMembershipShouldNotBeFound("admissionDocumentDate.specified=false"); + } + + @Test + @Transactional + public void getAllMembershipsByAdmissionDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 admissionDocumentDate greater than or equals to UPDATED_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("admissionDocumentDate.greaterOrEqualThan=" + UPDATED_ADMISSION_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByAdmissionDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 admissionDocumentDate less than or equals to UPDATED_ADMISSION_DOCUMENT_DATE + defaultMembershipShouldBeFound("admissionDocumentDate.lessThan=" + UPDATED_ADMISSION_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllMembershipsByCancellationDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where cancellationDocumentDate equals to DEFAULT_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldBeFound("cancellationDocumentDate.equals=" + DEFAULT_CANCELLATION_DOCUMENT_DATE); + + // Get all the membershipList where cancellationDocumentDate equals to UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("cancellationDocumentDate.equals=" + UPDATED_CANCELLATION_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByCancellationDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 cancellationDocumentDate equals to UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("cancellationDocumentDate.in=" + UPDATED_CANCELLATION_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByCancellationDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where cancellationDocumentDate is not null + defaultMembershipShouldBeFound("cancellationDocumentDate.specified=true"); + + // Get all the membershipList where cancellationDocumentDate is null + defaultMembershipShouldNotBeFound("cancellationDocumentDate.specified=false"); + } + + @Test + @Transactional + public void getAllMembershipsByCancellationDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 cancellationDocumentDate greater than or equals to UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("cancellationDocumentDate.greaterOrEqualThan=" + UPDATED_CANCELLATION_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByCancellationDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 cancellationDocumentDate less than or equals to UPDATED_CANCELLATION_DOCUMENT_DATE + defaultMembershipShouldBeFound("cancellationDocumentDate.lessThan=" + UPDATED_CANCELLATION_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllMembershipsByMemberFromDateIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberFromDate equals to DEFAULT_MEMBER_FROM_DATE + defaultMembershipShouldBeFound("memberFromDate.equals=" + DEFAULT_MEMBER_FROM_DATE); + + // Get all the membershipList where memberFromDate equals to UPDATED_MEMBER_FROM_DATE + defaultMembershipShouldNotBeFound("memberFromDate.equals=" + UPDATED_MEMBER_FROM_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByMemberFromDateIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 memberFromDate equals to UPDATED_MEMBER_FROM_DATE + defaultMembershipShouldNotBeFound("memberFromDate.in=" + UPDATED_MEMBER_FROM_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByMemberFromDateIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberFromDate is not null + defaultMembershipShouldBeFound("memberFromDate.specified=true"); + + // Get all the membershipList where memberFromDate is null + defaultMembershipShouldNotBeFound("memberFromDate.specified=false"); + } + + @Test + @Transactional + public void getAllMembershipsByMemberFromDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 memberFromDate greater than or equals to UPDATED_MEMBER_FROM_DATE + defaultMembershipShouldNotBeFound("memberFromDate.greaterOrEqualThan=" + UPDATED_MEMBER_FROM_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByMemberFromDateIsLessThanSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // 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 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); + } + + + @Test + @Transactional + public void getAllMembershipsByRemarkIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where remark equals to DEFAULT_REMARK + defaultMembershipShouldBeFound("remark.equals=" + DEFAULT_REMARK); + + // Get all the membershipList where remark equals to UPDATED_REMARK + defaultMembershipShouldNotBeFound("remark.equals=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllMembershipsByRemarkIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where remark in DEFAULT_REMARK or UPDATED_REMARK + defaultMembershipShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK); + + // Get all the membershipList where remark equals to UPDATED_REMARK + defaultMembershipShouldNotBeFound("remark.in=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllMembershipsByRemarkIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where remark is not null + defaultMembershipShouldBeFound("remark.specified=true"); + + // Get all the membershipList where remark is null + defaultMembershipShouldNotBeFound("remark.specified=false"); + } + + @Test + @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); + Long shareId = share.getId(); + + // Get all the membershipList where share equals to shareId + defaultMembershipShouldBeFound("shareId.equals=" + shareId); + + // Get all the membershipList where share equals to shareId + 1 + defaultMembershipShouldNotBeFound("shareId.equals=" + (shareId + 1)); + } + + + @Test + @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); + Long assetId = asset.getId(); + + // Get all the membershipList where asset equals to assetId + defaultMembershipShouldBeFound("assetId.equals=" + assetId); + + // Get all the membershipList where asset equals to assetId + 1 + defaultMembershipShouldNotBeFound("assetId.equals=" + (assetId + 1)); + } + + + @Test + @Transactional + public void getAllMembershipsByCustomerIsEqualToSomething() throws Exception { + // Initialize the database + Customer customer = CustomerResourceIntTest.createEntity(em); + em.persist(customer); + em.flush(); + membership.setCustomer(customer); + membershipRepository.saveAndFlush(membership); + Long customerId = customer.getId(); + + // Get all the membershipList where customer equals to customerId + defaultMembershipShouldBeFound("customerId.equals=" + customerId); + + // Get all the membershipList where customer equals to customerId + 1 + defaultMembershipShouldNotBeFound("customerId.equals=" + (customerId + 1)); + } + + /** + * Executes the search, and checks that the default entity is returned + */ + private void defaultMembershipShouldBeFound(String filter) throws Exception { + restMembershipMockMvc.perform(get("/api/memberships?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue()))) + .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 + restMembershipMockMvc.perform(get("/api/memberships/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned + */ + private void defaultMembershipShouldNotBeFound(String filter) throws Exception { + restMembershipMockMvc.perform(get("/api/memberships?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restMembershipMockMvc.perform(get("/api/memberships/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("0")); + } + + + @Test + @Transactional + public void getNonExistingMembership() throws Exception { + // Get the membership + restMembershipMockMvc.perform(get("/api/memberships/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateMembership() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + int databaseSizeBeforeUpdate = membershipRepository.findAll().size(); + + // Update the membership + Membership updatedMembership = membershipRepository.findById(membership.getId()).get(); + // Disconnect from session so that the updates on updatedMembership are not directly saved in db + em.detach(updatedMembership); + updatedMembership + .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); + + restMembershipMockMvc.perform(put("/api/memberships") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(membershipDTO))) + .andExpect(status().isOk()); + + // Validate the Membership in the database + List membershipList = membershipRepository.findAll(); + assertThat(membershipList).hasSize(databaseSizeBeforeUpdate); + Membership testMembership = membershipList.get(membershipList.size() - 1); + 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); + } + + @Test + @Transactional + public void updateNonExistingMembership() throws Exception { + int databaseSizeBeforeUpdate = membershipRepository.findAll().size(); + + // Create the Membership + MembershipDTO membershipDTO = membershipMapper.toDto(membership); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restMembershipMockMvc.perform(put("/api/memberships") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(membershipDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Membership in the database + List membershipList = membershipRepository.findAll(); + assertThat(membershipList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteMembership() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + int databaseSizeBeforeDelete = membershipRepository.findAll().size(); + + // Delete the membership + restMembershipMockMvc.perform(delete("/api/memberships/{id}", membership.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List membershipList = membershipRepository.findAll(); + assertThat(membershipList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Membership.class); + Membership membership1 = new Membership(); + membership1.setId(1L); + Membership membership2 = new Membership(); + membership2.setId(membership1.getId()); + assertThat(membership1).isEqualTo(membership2); + membership2.setId(2L); + assertThat(membership1).isNotEqualTo(membership2); + membership1.setId(null); + assertThat(membership1).isNotEqualTo(membership2); + } + + @Test + @Transactional + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(MembershipDTO.class); + MembershipDTO membershipDTO1 = new MembershipDTO(); + membershipDTO1.setId(1L); + MembershipDTO membershipDTO2 = new MembershipDTO(); + assertThat(membershipDTO1).isNotEqualTo(membershipDTO2); + membershipDTO2.setId(membershipDTO1.getId()); + assertThat(membershipDTO1).isEqualTo(membershipDTO2); + membershipDTO2.setId(2L); + assertThat(membershipDTO1).isNotEqualTo(membershipDTO2); + membershipDTO1.setId(null); + assertThat(membershipDTO1).isNotEqualTo(membershipDTO2); + } + + @Test + @Transactional + public void testEntityFromId() { + assertThat(membershipMapper.fromId(42L).getId()).isEqualTo(42); + assertThat(membershipMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java new file mode 100644 index 00000000..32b0a1c3 --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java @@ -0,0 +1,972 @@ +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.repository.SepaMandateRepository; +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; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +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.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Test class for the SepaMandateResource REST controller. + * + * @see SepaMandateResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = HsadminNgApp.class) +public class SepaMandateResourceIntTest { + + private static final String DEFAULT_REFERENCE = "AAAAAAAAAA"; + private static final String UPDATED_REFERENCE = "BBBBBBBBBB"; + + private static final String DEFAULT_IBAN = "AAAAAAAAAA"; + private static final String UPDATED_IBAN = "BBBBBBBBBB"; + + private static final String DEFAULT_BIC = "AAAAAAAAAA"; + private static final String UPDATED_BIC = "BBBBBBBBBB"; + + private static final LocalDate DEFAULT_GRANTING_DOCUMENT_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_GRANTING_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_REVOKATION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_REVOKATION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_VALID_FROM_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_FROM_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_VALID_UNTIL_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_LAST_USED_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"; + + @Autowired + private SepaMandateRepository sepaMandateRepository; + + @Autowired + private SepaMandateMapper sepaMandateMapper; + + @Autowired + private SepaMandateService sepaMandateService; + + @Autowired + private SepaMandateQueryService sepaMandateQueryService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restSepaMandateMockMvc; + + private SepaMandate sepaMandate; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final SepaMandateResource sepaMandateResource = new SepaMandateResource(sepaMandateService, sepaMandateQueryService); + this.restSepaMandateMockMvc = MockMvcBuilders.standaloneSetup(sepaMandateResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static SepaMandate createEntity(EntityManager em) { + SepaMandate sepaMandate = new SepaMandate() + .reference(DEFAULT_REFERENCE) + .iban(DEFAULT_IBAN) + .bic(DEFAULT_BIC) + .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); + em.persist(customer); + em.flush(); + sepaMandate.setCustomer(customer); + return sepaMandate; + } + + @Before + public void initTest() { + sepaMandate = createEntity(em); + } + + @Test + @Transactional + public void createSepaMandate() throws Exception { + int databaseSizeBeforeCreate = sepaMandateRepository.findAll().size(); + + // Create the SepaMandate + SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate); + restSepaMandateMockMvc.perform(post("/api/sepa-mandates") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO))) + .andExpect(status().isCreated()); + + // Validate the SepaMandate in the database + List sepaMandateList = sepaMandateRepository.findAll(); + assertThat(sepaMandateList).hasSize(databaseSizeBeforeCreate + 1); + SepaMandate testSepaMandate = sepaMandateList.get(sepaMandateList.size() - 1); + assertThat(testSepaMandate.getReference()).isEqualTo(DEFAULT_REFERENCE); + assertThat(testSepaMandate.getIban()).isEqualTo(DEFAULT_IBAN); + assertThat(testSepaMandate.getBic()).isEqualTo(DEFAULT_BIC); + 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); + } + + @Test + @Transactional + public void createSepaMandateWithExistingId() throws Exception { + int databaseSizeBeforeCreate = sepaMandateRepository.findAll().size(); + + // Create the SepaMandate with an existing ID + sepaMandate.setId(1L); + SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate); + + // An entity with an existing ID cannot be created, so this API call must fail + restSepaMandateMockMvc.perform(post("/api/sepa-mandates") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO))) + .andExpect(status().isBadRequest()); + + // Validate the SepaMandate in the database + List sepaMandateList = sepaMandateRepository.findAll(); + assertThat(sepaMandateList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void checkReferenceIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setReference(null); + + // Create the SepaMandate, which fails. + SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate); + + restSepaMandateMockMvc.perform(post("/api/sepa-mandates") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO))) + .andExpect(status().isBadRequest()); + + List sepaMandateList = sepaMandateRepository.findAll(); + assertThat(sepaMandateList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkGrantingDocumentDateIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setGrantingDocumentDate(null); + + // Create the SepaMandate, which fails. + SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate); + + restSepaMandateMockMvc.perform(post("/api/sepa-mandates") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO))) + .andExpect(status().isBadRequest()); + + List sepaMandateList = sepaMandateRepository.findAll(); + assertThat(sepaMandateList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkValidFromDateIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setValidFromDate(null); + + // Create the SepaMandate, which fails. + SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate); + + restSepaMandateMockMvc.perform(post("/api/sepa-mandates") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO))) + .andExpect(status().isBadRequest()); + + List sepaMandateList = sepaMandateRepository.findAll(); + assertThat(sepaMandateList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllSepaMandates() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList + restSepaMandateMockMvc.perform(get("/api/sepa-mandates?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(sepaMandate.getId().intValue()))) + .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("$.[*].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()))); + } + + @Test + @Transactional + public void getSepaMandate() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get the sepaMandate + restSepaMandateMockMvc.perform(get("/api/sepa-mandates/{id}", sepaMandate.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(sepaMandate.getId().intValue())) + .andExpect(jsonPath("$.reference").value(DEFAULT_REFERENCE.toString())) + .andExpect(jsonPath("$.iban").value(DEFAULT_IBAN.toString())) + .andExpect(jsonPath("$.bic").value(DEFAULT_BIC.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())); + } + + @Test + @Transactional + public void getAllSepaMandatesByReferenceIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where reference equals to DEFAULT_REFERENCE + defaultSepaMandateShouldBeFound("reference.equals=" + DEFAULT_REFERENCE); + + // Get all the sepaMandateList where reference equals to UPDATED_REFERENCE + defaultSepaMandateShouldNotBeFound("reference.equals=" + UPDATED_REFERENCE); + } + + @Test + @Transactional + public void getAllSepaMandatesByReferenceIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where reference in DEFAULT_REFERENCE or UPDATED_REFERENCE + defaultSepaMandateShouldBeFound("reference.in=" + DEFAULT_REFERENCE + "," + UPDATED_REFERENCE); + + // Get all the sepaMandateList where reference equals to UPDATED_REFERENCE + defaultSepaMandateShouldNotBeFound("reference.in=" + UPDATED_REFERENCE); + } + + @Test + @Transactional + public void getAllSepaMandatesByReferenceIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where reference is not null + defaultSepaMandateShouldBeFound("reference.specified=true"); + + // Get all the sepaMandateList where reference is null + defaultSepaMandateShouldNotBeFound("reference.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByIbanIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where iban equals to DEFAULT_IBAN + defaultSepaMandateShouldBeFound("iban.equals=" + DEFAULT_IBAN); + + // Get all the sepaMandateList where iban equals to UPDATED_IBAN + defaultSepaMandateShouldNotBeFound("iban.equals=" + UPDATED_IBAN); + } + + @Test + @Transactional + public void getAllSepaMandatesByIbanIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where iban in DEFAULT_IBAN or UPDATED_IBAN + defaultSepaMandateShouldBeFound("iban.in=" + DEFAULT_IBAN + "," + UPDATED_IBAN); + + // Get all the sepaMandateList where iban equals to UPDATED_IBAN + defaultSepaMandateShouldNotBeFound("iban.in=" + UPDATED_IBAN); + } + + @Test + @Transactional + public void getAllSepaMandatesByIbanIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where iban is not null + defaultSepaMandateShouldBeFound("iban.specified=true"); + + // Get all the sepaMandateList where iban is null + defaultSepaMandateShouldNotBeFound("iban.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByBicIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where bic equals to DEFAULT_BIC + defaultSepaMandateShouldBeFound("bic.equals=" + DEFAULT_BIC); + + // Get all the sepaMandateList where bic equals to UPDATED_BIC + defaultSepaMandateShouldNotBeFound("bic.equals=" + UPDATED_BIC); + } + + @Test + @Transactional + public void getAllSepaMandatesByBicIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where bic in DEFAULT_BIC or UPDATED_BIC + defaultSepaMandateShouldBeFound("bic.in=" + DEFAULT_BIC + "," + UPDATED_BIC); + + // Get all the sepaMandateList where bic equals to UPDATED_BIC + defaultSepaMandateShouldNotBeFound("bic.in=" + UPDATED_BIC); + } + + @Test + @Transactional + public void getAllSepaMandatesByBicIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where bic is not null + defaultSepaMandateShouldBeFound("bic.specified=true"); + + // Get all the sepaMandateList where bic is null + defaultSepaMandateShouldNotBeFound("bic.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByGrantingDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where grantingDocumentDate equals to DEFAULT_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("grantingDocumentDate.equals=" + DEFAULT_GRANTING_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 getAllSepaMandatesByGrantingDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 grantingDocumentDate equals to UPDATED_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("grantingDocumentDate.in=" + UPDATED_GRANTING_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByGrantingDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where grantingDocumentDate is not null + defaultSepaMandateShouldBeFound("grantingDocumentDate.specified=true"); + + // Get all the sepaMandateList where grantingDocumentDate is null + defaultSepaMandateShouldNotBeFound("grantingDocumentDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByGrantingDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 grantingDocumentDate greater than or equals to UPDATED_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("grantingDocumentDate.greaterOrEqualThan=" + UPDATED_GRANTING_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByGrantingDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 grantingDocumentDate less than or equals to UPDATED_GRANTING_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("grantingDocumentDate.lessThan=" + UPDATED_GRANTING_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllSepaMandatesByRevokationDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where revokationDocumentDate equals to DEFAULT_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("revokationDocumentDate.equals=" + DEFAULT_REVOKATION_DOCUMENT_DATE); + + // Get all the sepaMandateList where revokationDocumentDate equals to UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.equals=" + UPDATED_REVOKATION_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByRevokationDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 revokationDocumentDate equals to UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.in=" + UPDATED_REVOKATION_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByRevokationDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where revokationDocumentDate is not null + defaultSepaMandateShouldBeFound("revokationDocumentDate.specified=true"); + + // Get all the sepaMandateList where revokationDocumentDate is null + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByRevokationDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 revokationDocumentDate greater than or equals to UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("revokationDocumentDate.greaterOrEqualThan=" + UPDATED_REVOKATION_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByRevokationDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 revokationDocumentDate less than or equals to UPDATED_REVOKATION_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("revokationDocumentDate.lessThan=" + UPDATED_REVOKATION_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllSepaMandatesByValidFromDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFromDate equals to DEFAULT_VALID_FROM_DATE + defaultSepaMandateShouldBeFound("validFromDate.equals=" + DEFAULT_VALID_FROM_DATE); + + // Get all the sepaMandateList where validFromDate equals to UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldNotBeFound("validFromDate.equals=" + UPDATED_VALID_FROM_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 validFromDate equals to UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldNotBeFound("validFromDate.in=" + UPDATED_VALID_FROM_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFromDate is not null + defaultSepaMandateShouldBeFound("validFromDate.specified=true"); + + // Get all the sepaMandateList where validFromDate is null + defaultSepaMandateShouldNotBeFound("validFromDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 validFromDate greater than or equals to UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldNotBeFound("validFromDate.greaterOrEqualThan=" + UPDATED_VALID_FROM_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 validFromDate less than or equals to UPDATED_VALID_FROM_DATE + defaultSepaMandateShouldBeFound("validFromDate.lessThan=" + UPDATED_VALID_FROM_DATE); + } + + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntilDate equals to DEFAULT_VALID_UNTIL_DATE + defaultSepaMandateShouldBeFound("validUntilDate.equals=" + DEFAULT_VALID_UNTIL_DATE); + + // Get all the sepaMandateList where validUntilDate equals to UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldNotBeFound("validUntilDate.equals=" + UPDATED_VALID_UNTIL_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 validUntilDate equals to UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldNotBeFound("validUntilDate.in=" + UPDATED_VALID_UNTIL_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntilDate is not null + defaultSepaMandateShouldBeFound("validUntilDate.specified=true"); + + // Get all the sepaMandateList where validUntilDate is null + defaultSepaMandateShouldNotBeFound("validUntilDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 validUntilDate greater than or equals to UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldNotBeFound("validUntilDate.greaterOrEqualThan=" + UPDATED_VALID_UNTIL_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 validUntilDate less than or equals to UPDATED_VALID_UNTIL_DATE + defaultSepaMandateShouldBeFound("validUntilDate.lessThan=" + UPDATED_VALID_UNTIL_DATE); + } + + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsedDate equals to DEFAULT_LAST_USED_DATE + defaultSepaMandateShouldBeFound("lastUsedDate.equals=" + DEFAULT_LAST_USED_DATE); + + // Get all the sepaMandateList where lastUsedDate equals to UPDATED_LAST_USED_DATE + defaultSepaMandateShouldNotBeFound("lastUsedDate.equals=" + UPDATED_LAST_USED_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 lastUsedDate equals to UPDATED_LAST_USED_DATE + defaultSepaMandateShouldNotBeFound("lastUsedDate.in=" + UPDATED_LAST_USED_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsedDate is not null + defaultSepaMandateShouldBeFound("lastUsedDate.specified=true"); + + // Get all the sepaMandateList where lastUsedDate is null + defaultSepaMandateShouldNotBeFound("lastUsedDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 lastUsedDate greater than or equals to UPDATED_LAST_USED_DATE + defaultSepaMandateShouldNotBeFound("lastUsedDate.greaterOrEqualThan=" + UPDATED_LAST_USED_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // 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 lastUsedDate less than or equals to UPDATED_LAST_USED_DATE + defaultSepaMandateShouldBeFound("lastUsedDate.lessThan=" + UPDATED_LAST_USED_DATE); + } + + + @Test + @Transactional + public void getAllSepaMandatesByRemarkIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where remark equals to DEFAULT_REMARK + defaultSepaMandateShouldBeFound("remark.equals=" + DEFAULT_REMARK); + + // Get all the sepaMandateList where remark equals to UPDATED_REMARK + defaultSepaMandateShouldNotBeFound("remark.equals=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllSepaMandatesByRemarkIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where remark in DEFAULT_REMARK or UPDATED_REMARK + defaultSepaMandateShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK); + + // Get all the sepaMandateList where remark equals to UPDATED_REMARK + defaultSepaMandateShouldNotBeFound("remark.in=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllSepaMandatesByRemarkIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where remark is not null + defaultSepaMandateShouldBeFound("remark.specified=true"); + + // Get all the sepaMandateList where remark is null + defaultSepaMandateShouldNotBeFound("remark.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByCustomerIsEqualToSomething() throws Exception { + // Initialize the database + Customer customer = CustomerResourceIntTest.createEntity(em); + em.persist(customer); + em.flush(); + sepaMandate.setCustomer(customer); + sepaMandateRepository.saveAndFlush(sepaMandate); + Long customerId = customer.getId(); + + // Get all the sepaMandateList where customer equals to customerId + defaultSepaMandateShouldBeFound("customerId.equals=" + customerId); + + // Get all the sepaMandateList where customer equals to customerId + 1 + defaultSepaMandateShouldNotBeFound("customerId.equals=" + (customerId + 1)); + } + + /** + * Executes the search, and checks that the default entity is returned + */ + private void defaultSepaMandateShouldBeFound(String filter) throws Exception { + restSepaMandateMockMvc.perform(get("/api/sepa-mandates?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(sepaMandate.getId().intValue()))) + .andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE))) + .andExpect(jsonPath("$.[*].iban").value(hasItem(DEFAULT_IBAN))) + .andExpect(jsonPath("$.[*].bic").value(hasItem(DEFAULT_BIC))) + .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 + restSepaMandateMockMvc.perform(get("/api/sepa-mandates/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned + */ + private void defaultSepaMandateShouldNotBeFound(String filter) throws Exception { + restSepaMandateMockMvc.perform(get("/api/sepa-mandates?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restSepaMandateMockMvc.perform(get("/api/sepa-mandates/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("0")); + } + + + @Test + @Transactional + public void getNonExistingSepaMandate() throws Exception { + // Get the sepaMandate + restSepaMandateMockMvc.perform(get("/api/sepa-mandates/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateSepaMandate() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + int databaseSizeBeforeUpdate = sepaMandateRepository.findAll().size(); + + // Update the sepaMandate + SepaMandate updatedSepaMandate = sepaMandateRepository.findById(sepaMandate.getId()).get(); + // Disconnect from session so that the updates on updatedSepaMandate are not directly saved in db + em.detach(updatedSepaMandate); + updatedSepaMandate + .reference(UPDATED_REFERENCE) + .iban(UPDATED_IBAN) + .bic(UPDATED_BIC) + .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); + + restSepaMandateMockMvc.perform(put("/api/sepa-mandates") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO))) + .andExpect(status().isOk()); + + // Validate the SepaMandate in the database + List sepaMandateList = sepaMandateRepository.findAll(); + assertThat(sepaMandateList).hasSize(databaseSizeBeforeUpdate); + SepaMandate testSepaMandate = sepaMandateList.get(sepaMandateList.size() - 1); + assertThat(testSepaMandate.getReference()).isEqualTo(UPDATED_REFERENCE); + assertThat(testSepaMandate.getIban()).isEqualTo(UPDATED_IBAN); + assertThat(testSepaMandate.getBic()).isEqualTo(UPDATED_BIC); + 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); + } + + @Test + @Transactional + public void updateNonExistingSepaMandate() throws Exception { + int databaseSizeBeforeUpdate = sepaMandateRepository.findAll().size(); + + // Create the SepaMandate + SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restSepaMandateMockMvc.perform(put("/api/sepa-mandates") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO))) + .andExpect(status().isBadRequest()); + + // Validate the SepaMandate in the database + List sepaMandateList = sepaMandateRepository.findAll(); + assertThat(sepaMandateList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteSepaMandate() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + int databaseSizeBeforeDelete = sepaMandateRepository.findAll().size(); + + // Delete the sepaMandate + restSepaMandateMockMvc.perform(delete("/api/sepa-mandates/{id}", sepaMandate.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List sepaMandateList = sepaMandateRepository.findAll(); + assertThat(sepaMandateList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(SepaMandate.class); + SepaMandate sepaMandate1 = new SepaMandate(); + sepaMandate1.setId(1L); + SepaMandate sepaMandate2 = new SepaMandate(); + sepaMandate2.setId(sepaMandate1.getId()); + assertThat(sepaMandate1).isEqualTo(sepaMandate2); + sepaMandate2.setId(2L); + assertThat(sepaMandate1).isNotEqualTo(sepaMandate2); + sepaMandate1.setId(null); + assertThat(sepaMandate1).isNotEqualTo(sepaMandate2); + } + + @Test + @Transactional + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(SepaMandateDTO.class); + SepaMandateDTO sepaMandateDTO1 = new SepaMandateDTO(); + sepaMandateDTO1.setId(1L); + SepaMandateDTO sepaMandateDTO2 = new SepaMandateDTO(); + assertThat(sepaMandateDTO1).isNotEqualTo(sepaMandateDTO2); + sepaMandateDTO2.setId(sepaMandateDTO1.getId()); + assertThat(sepaMandateDTO1).isEqualTo(sepaMandateDTO2); + sepaMandateDTO2.setId(2L); + assertThat(sepaMandateDTO1).isNotEqualTo(sepaMandateDTO2); + sepaMandateDTO1.setId(null); + assertThat(sepaMandateDTO1).isNotEqualTo(sepaMandateDTO2); + } + + @Test + @Transactional + public void testEntityFromId() { + assertThat(sepaMandateMapper.fromId(42L).getId()).isEqualTo(42); + assertThat(sepaMandateMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java new file mode 100644 index 00000000..3b99a17c --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java @@ -0,0 +1,742 @@ +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.repository.ShareRepository; +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; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +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.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. + * + * @see ShareResource + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = HsadminNgApp.class) +public class ShareResourceIntTest { + + 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_VALUE_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALUE_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final ShareAction DEFAULT_ACTION = ShareAction.SUBSCRIPTION; + private static final ShareAction UPDATED_ACTION = ShareAction.CANCELLATION; + + private static final Integer DEFAULT_QUANTITY = 1; + private static final Integer UPDATED_QUANTITY = 2; + + private static final String DEFAULT_REMARK = "AAAAAAAAAA"; + private static final String UPDATED_REMARK = "BBBBBBBBBB"; + + @Autowired + private ShareRepository shareRepository; + + @Autowired + private ShareMapper shareMapper; + + @Autowired + private ShareService shareService; + + @Autowired + private ShareQueryService shareQueryService; + + @Autowired + private MappingJackson2HttpMessageConverter jacksonMessageConverter; + + @Autowired + private PageableHandlerMethodArgumentResolver pageableArgumentResolver; + + @Autowired + private ExceptionTranslator exceptionTranslator; + + @Autowired + private EntityManager em; + + @Autowired + private Validator validator; + + private MockMvc restShareMockMvc; + + private Share share; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + final ShareResource shareResource = new ShareResource(shareService, shareQueryService); + this.restShareMockMvc = MockMvcBuilders.standaloneSetup(shareResource) + .setCustomArgumentResolvers(pageableArgumentResolver) + .setControllerAdvice(exceptionTranslator) + .setConversionService(createFormattingConversionService()) + .setMessageConverters(jacksonMessageConverter) + .setValidator(validator).build(); + } + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Share createEntity(EntityManager em) { + Share share = new Share() + .documentDate(DEFAULT_DOCUMENT_DATE) + .valueDate(DEFAULT_VALUE_DATE) + .action(DEFAULT_ACTION) + .quantity(DEFAULT_QUANTITY) + .remark(DEFAULT_REMARK); + // Add required entity + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); + em.flush(); + share.setMembership(membership); + return share; + } + + @Before + public void initTest() { + share = createEntity(em); + } + + @Test + @Transactional + public void createShare() throws Exception { + int databaseSizeBeforeCreate = shareRepository.findAll().size(); + + // Create the Share + ShareDTO shareDTO = shareMapper.toDto(share); + restShareMockMvc.perform(post("/api/shares") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(shareDTO))) + .andExpect(status().isCreated()); + + // Validate the Share in the database + List shareList = shareRepository.findAll(); + assertThat(shareList).hasSize(databaseSizeBeforeCreate + 1); + Share testShare = shareList.get(shareList.size() - 1); + 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 + @Transactional + public void createShareWithExistingId() throws Exception { + int databaseSizeBeforeCreate = shareRepository.findAll().size(); + + // Create the Share with an existing ID + share.setId(1L); + ShareDTO shareDTO = shareMapper.toDto(share); + + // An entity with an existing ID cannot be created, so this API call must fail + restShareMockMvc.perform(post("/api/shares") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(shareDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Share in the database + List shareList = shareRepository.findAll(); + assertThat(shareList).hasSize(databaseSizeBeforeCreate); + } + + @Test + @Transactional + public void checkDocumentDateIsRequired() throws Exception { + int databaseSizeBeforeTest = shareRepository.findAll().size(); + // set the field null + share.setDocumentDate(null); + + // Create the Share, which fails. + ShareDTO shareDTO = shareMapper.toDto(share); + + restShareMockMvc.perform(post("/api/shares") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(shareDTO))) + .andExpect(status().isBadRequest()); + + List shareList = shareRepository.findAll(); + assertThat(shareList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkValueDateIsRequired() throws Exception { + int databaseSizeBeforeTest = shareRepository.findAll().size(); + // set the field null + share.setValueDate(null); + + // Create the Share, which fails. + ShareDTO shareDTO = shareMapper.toDto(share); + + restShareMockMvc.perform(post("/api/shares") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(shareDTO))) + .andExpect(status().isBadRequest()); + + List shareList = shareRepository.findAll(); + assertThat(shareList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkActionIsRequired() throws Exception { + int databaseSizeBeforeTest = shareRepository.findAll().size(); + // set the field null + share.setAction(null); + + // Create the Share, which fails. + ShareDTO shareDTO = shareMapper.toDto(share); + + restShareMockMvc.perform(post("/api/shares") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(shareDTO))) + .andExpect(status().isBadRequest()); + + List shareList = shareRepository.findAll(); + assertThat(shareList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkQuantityIsRequired() throws Exception { + int databaseSizeBeforeTest = shareRepository.findAll().size(); + // set the field null + share.setQuantity(null); + + // Create the Share, which fails. + ShareDTO shareDTO = shareMapper.toDto(share); + + restShareMockMvc.perform(post("/api/shares") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(shareDTO))) + .andExpect(status().isBadRequest()); + + List shareList = shareRepository.findAll(); + assertThat(shareList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllShares() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList + restShareMockMvc.perform(get("/api/shares?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(share.getId().intValue()))) + .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString()))) + .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString()))) + .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY))) + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); + } + + @Test + @Transactional + public void getShare() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get the share + restShareMockMvc.perform(get("/api/shares/{id}", share.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.id").value(share.getId().intValue())) + .andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.valueDate").value(DEFAULT_VALUE_DATE.toString())) + .andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString())) + .andExpect(jsonPath("$.quantity").value(DEFAULT_QUANTITY)) + .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); + } + + @Test + @Transactional + public void getAllSharesByDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where documentDate equals to DEFAULT_DOCUMENT_DATE + defaultShareShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); + + // Get all the shareList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultShareShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSharesByDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE + defaultShareShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE); + + // Get all the shareList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultShareShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSharesByDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where documentDate is not null + defaultShareShouldBeFound("documentDate.specified=true"); + + // Get all the shareList where documentDate is null + defaultShareShouldNotBeFound("documentDate.specified=false"); + } + + @Test + @Transactional + public void getAllSharesByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE + defaultShareShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the shareList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE + defaultShareShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSharesByDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE + defaultShareShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the shareList where documentDate less than or equals to UPDATED_DOCUMENT_DATE + defaultShareShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllSharesByValueDateIsEqualToSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where valueDate equals to DEFAULT_VALUE_DATE + defaultShareShouldBeFound("valueDate.equals=" + DEFAULT_VALUE_DATE); + + // Get all the shareList where valueDate equals to UPDATED_VALUE_DATE + defaultShareShouldNotBeFound("valueDate.equals=" + UPDATED_VALUE_DATE); + } + + @Test + @Transactional + public void getAllSharesByValueDateIsInShouldWork() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where valueDate in DEFAULT_VALUE_DATE or UPDATED_VALUE_DATE + defaultShareShouldBeFound("valueDate.in=" + DEFAULT_VALUE_DATE + "," + UPDATED_VALUE_DATE); + + // Get all the shareList where valueDate equals to UPDATED_VALUE_DATE + defaultShareShouldNotBeFound("valueDate.in=" + UPDATED_VALUE_DATE); + } + + @Test + @Transactional + public void getAllSharesByValueDateIsNullOrNotNull() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where valueDate is not null + defaultShareShouldBeFound("valueDate.specified=true"); + + // Get all the shareList where valueDate is null + defaultShareShouldNotBeFound("valueDate.specified=false"); + } + + @Test + @Transactional + public void getAllSharesByValueDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where valueDate greater than or equals to DEFAULT_VALUE_DATE + defaultShareShouldBeFound("valueDate.greaterOrEqualThan=" + DEFAULT_VALUE_DATE); + + // Get all the shareList where valueDate greater than or equals to UPDATED_VALUE_DATE + defaultShareShouldNotBeFound("valueDate.greaterOrEqualThan=" + UPDATED_VALUE_DATE); + } + + @Test + @Transactional + public void getAllSharesByValueDateIsLessThanSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where valueDate less than or equals to DEFAULT_VALUE_DATE + defaultShareShouldNotBeFound("valueDate.lessThan=" + DEFAULT_VALUE_DATE); + + // Get all the shareList where valueDate less than or equals to UPDATED_VALUE_DATE + defaultShareShouldBeFound("valueDate.lessThan=" + UPDATED_VALUE_DATE); + } + + + @Test + @Transactional + public void getAllSharesByActionIsEqualToSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where action equals to DEFAULT_ACTION + defaultShareShouldBeFound("action.equals=" + DEFAULT_ACTION); + + // Get all the shareList where action equals to UPDATED_ACTION + defaultShareShouldNotBeFound("action.equals=" + UPDATED_ACTION); + } + + @Test + @Transactional + public void getAllSharesByActionIsInShouldWork() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where action in DEFAULT_ACTION or UPDATED_ACTION + defaultShareShouldBeFound("action.in=" + DEFAULT_ACTION + "," + UPDATED_ACTION); + + // Get all the shareList where action equals to UPDATED_ACTION + defaultShareShouldNotBeFound("action.in=" + UPDATED_ACTION); + } + + @Test + @Transactional + public void getAllSharesByActionIsNullOrNotNull() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where action is not null + defaultShareShouldBeFound("action.specified=true"); + + // Get all the shareList where action is null + defaultShareShouldNotBeFound("action.specified=false"); + } + + @Test + @Transactional + public void getAllSharesByQuantityIsEqualToSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where quantity equals to DEFAULT_QUANTITY + defaultShareShouldBeFound("quantity.equals=" + DEFAULT_QUANTITY); + + // Get all the shareList where quantity equals to UPDATED_QUANTITY + defaultShareShouldNotBeFound("quantity.equals=" + UPDATED_QUANTITY); + } + + @Test + @Transactional + public void getAllSharesByQuantityIsInShouldWork() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where quantity in DEFAULT_QUANTITY or UPDATED_QUANTITY + defaultShareShouldBeFound("quantity.in=" + DEFAULT_QUANTITY + "," + UPDATED_QUANTITY); + + // Get all the shareList where quantity equals to UPDATED_QUANTITY + defaultShareShouldNotBeFound("quantity.in=" + UPDATED_QUANTITY); + } + + @Test + @Transactional + public void getAllSharesByQuantityIsNullOrNotNull() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where quantity is not null + defaultShareShouldBeFound("quantity.specified=true"); + + // Get all the shareList where quantity is null + defaultShareShouldNotBeFound("quantity.specified=false"); + } + + @Test + @Transactional + public void getAllSharesByQuantityIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where quantity greater than or equals to DEFAULT_QUANTITY + defaultShareShouldBeFound("quantity.greaterOrEqualThan=" + DEFAULT_QUANTITY); + + // Get all the shareList where quantity greater than or equals to UPDATED_QUANTITY + defaultShareShouldNotBeFound("quantity.greaterOrEqualThan=" + UPDATED_QUANTITY); + } + + @Test + @Transactional + public void getAllSharesByQuantityIsLessThanSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where quantity less than or equals to DEFAULT_QUANTITY + defaultShareShouldNotBeFound("quantity.lessThan=" + DEFAULT_QUANTITY); + + // Get all the shareList where quantity less than or equals to UPDATED_QUANTITY + defaultShareShouldBeFound("quantity.lessThan=" + UPDATED_QUANTITY); + } + + + @Test + @Transactional + public void getAllSharesByRemarkIsEqualToSomething() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where remark equals to DEFAULT_REMARK + defaultShareShouldBeFound("remark.equals=" + DEFAULT_REMARK); + + // Get all the shareList where remark equals to UPDATED_REMARK + defaultShareShouldNotBeFound("remark.equals=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllSharesByRemarkIsInShouldWork() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where remark in DEFAULT_REMARK or UPDATED_REMARK + defaultShareShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK); + + // Get all the shareList where remark equals to UPDATED_REMARK + defaultShareShouldNotBeFound("remark.in=" + UPDATED_REMARK); + } + + @Test + @Transactional + public void getAllSharesByRemarkIsNullOrNotNull() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + // Get all the shareList where remark is not null + defaultShareShouldBeFound("remark.specified=true"); + + // Get all the shareList where remark is null + defaultShareShouldNotBeFound("remark.specified=false"); + } + + @Test + @Transactional + public void getAllSharesByMembershipIsEqualToSomething() throws Exception { + // Initialize the database + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); + em.flush(); + share.setMembership(membership); + shareRepository.saveAndFlush(share); + Long membershipId = membership.getId(); + + // Get all the shareList where membership equals to membershipId + defaultShareShouldBeFound("membershipId.equals=" + membershipId); + + // Get all the shareList where membership equals to membershipId + 1 + defaultShareShouldNotBeFound("membershipId.equals=" + (membershipId + 1)); + } + + /** + * Executes the search, and checks that the default entity is returned + */ + private void defaultShareShouldBeFound(String filter) throws Exception { + restShareMockMvc.perform(get("/api/shares?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(share.getId().intValue()))) + .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString()))) + .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString()))) + .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY))) + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK))); + + // Check, that the count call also returns 1 + restShareMockMvc.perform(get("/api/shares/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("1")); + } + + /** + * Executes the search, and checks that the default entity is not returned + */ + private void defaultShareShouldNotBeFound(String filter) throws Exception { + restShareMockMvc.perform(get("/api/shares?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$").isEmpty()); + + // Check, that the count call also returns 0 + restShareMockMvc.perform(get("/api/shares/count?sort=id,desc&" + filter)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().string("0")); + } + + + @Test + @Transactional + public void getNonExistingShare() throws Exception { + // Get the share + restShareMockMvc.perform(get("/api/shares/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateShare() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + int databaseSizeBeforeUpdate = shareRepository.findAll().size(); + + // Update the share + Share updatedShare = shareRepository.findById(share.getId()).get(); + // Disconnect from session so that the updates on updatedShare are not directly saved in db + em.detach(updatedShare); + updatedShare + .documentDate(UPDATED_DOCUMENT_DATE) + .valueDate(UPDATED_VALUE_DATE) + .action(UPDATED_ACTION) + .quantity(UPDATED_QUANTITY) + .remark(UPDATED_REMARK); + ShareDTO shareDTO = shareMapper.toDto(updatedShare); + + restShareMockMvc.perform(put("/api/shares") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(shareDTO))) + .andExpect(status().isOk()); + + // Validate the Share in the database + 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); + } + + @Test + @Transactional + public void updateNonExistingShare() throws Exception { + int databaseSizeBeforeUpdate = shareRepository.findAll().size(); + + // Create the Share + ShareDTO shareDTO = shareMapper.toDto(share); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restShareMockMvc.perform(put("/api/shares") + .contentType(TestUtil.APPLICATION_JSON_UTF8) + .content(TestUtil.convertObjectToJsonBytes(shareDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Share in the database + List shareList = shareRepository.findAll(); + assertThat(shareList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteShare() throws Exception { + // Initialize the database + shareRepository.saveAndFlush(share); + + int databaseSizeBeforeDelete = shareRepository.findAll().size(); + + // Delete the share + restShareMockMvc.perform(delete("/api/shares/{id}", share.getId()) + .accept(TestUtil.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()); + + // Validate the database is empty + List shareList = shareRepository.findAll(); + assertThat(shareList).hasSize(databaseSizeBeforeDelete - 1); + } + + @Test + @Transactional + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Share.class); + Share share1 = new Share(); + share1.setId(1L); + Share share2 = new Share(); + share2.setId(share1.getId()); + assertThat(share1).isEqualTo(share2); + share2.setId(2L); + assertThat(share1).isNotEqualTo(share2); + share1.setId(null); + assertThat(share1).isNotEqualTo(share2); + } + + @Test + @Transactional + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(ShareDTO.class); + ShareDTO shareDTO1 = new ShareDTO(); + shareDTO1.setId(1L); + ShareDTO shareDTO2 = new ShareDTO(); + assertThat(shareDTO1).isNotEqualTo(shareDTO2); + shareDTO2.setId(shareDTO1.getId()); + assertThat(shareDTO1).isEqualTo(shareDTO2); + shareDTO2.setId(2L); + assertThat(shareDTO1).isNotEqualTo(shareDTO2); + shareDTO1.setId(null); + assertThat(shareDTO1).isNotEqualTo(shareDTO2); + } + + @Test + @Transactional + public void testEntityFromId() { + assertThat(shareMapper.fromId(42L).getId()).isEqualTo(42); + assertThat(shareMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/javascript/spec/app/entities/asset/asset-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/asset/asset-delete-dialog.component.spec.ts new file mode 100644 index 00000000..26ab4fb0 --- /dev/null +++ b/src/test/javascript/spec/app/entities/asset/asset-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { AssetDeleteDialogComponent } from 'app/entities/asset/asset-delete-dialog.component'; +import { AssetService } from 'app/entities/asset/asset.service'; + +describe('Component Tests', () => { + describe('Asset Management Delete Component', () => { + let comp: AssetDeleteDialogComponent; + let fixture: ComponentFixture; + let service: AssetService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [AssetDeleteDialogComponent] + }) + .overrideTemplate(AssetDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(AssetDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(AssetService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/asset/asset-detail.component.spec.ts b/src/test/javascript/spec/app/entities/asset/asset-detail.component.spec.ts new file mode 100644 index 00000000..8d176985 --- /dev/null +++ b/src/test/javascript/spec/app/entities/asset/asset-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { AssetDetailComponent } from 'app/entities/asset/asset-detail.component'; +import { Asset } from 'app/shared/model/asset.model'; + +describe('Component Tests', () => { + describe('Asset Management Detail Component', () => { + let comp: AssetDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ asset: new Asset(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [AssetDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(AssetDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(AssetDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.asset).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/asset/asset-update.component.spec.ts b/src/test/javascript/spec/app/entities/asset/asset-update.component.spec.ts new file mode 100644 index 00000000..20bcdf53 --- /dev/null +++ b/src/test/javascript/spec/app/entities/asset/asset-update.component.spec.ts @@ -0,0 +1,60 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { AssetUpdateComponent } from 'app/entities/asset/asset-update.component'; +import { AssetService } from 'app/entities/asset/asset.service'; +import { Asset } from 'app/shared/model/asset.model'; + +describe('Component Tests', () => { + describe('Asset Management Update Component', () => { + let comp: AssetUpdateComponent; + let fixture: ComponentFixture; + let service: AssetService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [AssetUpdateComponent] + }) + .overrideTemplate(AssetUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(AssetUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(AssetService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Asset(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.asset = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Asset(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.asset = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/asset/asset.component.spec.ts b/src/test/javascript/spec/app/entities/asset/asset.component.spec.ts new file mode 100644 index 00000000..c8afd397 --- /dev/null +++ b/src/test/javascript/spec/app/entities/asset/asset.component.spec.ts @@ -0,0 +1,128 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { AssetComponent } from 'app/entities/asset/asset.component'; +import { AssetService } from 'app/entities/asset/asset.service'; +import { Asset } from 'app/shared/model/asset.model'; + +describe('Component Tests', () => { + describe('Asset Management Component', () => { + let comp: AssetComponent; + let fixture: ComponentFixture; + let service: AssetService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [AssetComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(AssetComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(AssetComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(AssetService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Asset(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Asset(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should re-initialize the page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Asset(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + comp.reset(); + + // THEN + expect(comp.page).toEqual(0); + expect(service.query).toHaveBeenCalledTimes(2); + expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + it('should calculate the sort attribute for an id', () => { + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,asc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,asc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/asset/asset.service.spec.ts b/src/test/javascript/spec/app/entities/asset/asset.service.spec.ts new file mode 100644 index 00000000..28250778 --- /dev/null +++ b/src/test/javascript/spec/app/entities/asset/asset.service.spec.ts @@ -0,0 +1,142 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } 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 * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { AssetService } from 'app/entities/asset/asset.service'; +import { IAsset, Asset, AssetAction } from 'app/shared/model/asset.model'; + +describe('Service Tests', () => { + describe('Asset Service', () => { + let injector: TestBed; + let service: AssetService; + let httpMock: HttpTestingController; + let elemDefault: IAsset; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(AssetService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + elemDefault = new Asset(0, currentDate, currentDate, AssetAction.PAYMENT, 0, 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Asset', async () => { + const returnedFromService = Object.assign( + { + id: 0, + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + valueDate: currentDate + }, + returnedFromService + ); + service + .create(new Asset(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Asset', async () => { + const returnedFromService = Object.assign( + { + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT), + action: 'BBBBBB', + amount: 1, + remark: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + documentDate: currentDate, + valueDate: currentDate + }, + returnedFromService + ); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Asset', async () => { + const returnedFromService = Object.assign( + { + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT), + action: 'BBBBBB', + amount: 1, + remark: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + valueDate: currentDate + }, + returnedFromService + ); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Asset', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/customer/customer-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/customer/customer-delete-dialog.component.spec.ts new file mode 100644 index 00000000..7b4f83cc --- /dev/null +++ b/src/test/javascript/spec/app/entities/customer/customer-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { CustomerDeleteDialogComponent } from 'app/entities/customer/customer-delete-dialog.component'; +import { CustomerService } from 'app/entities/customer/customer.service'; + +describe('Component Tests', () => { + describe('Customer Management Delete Component', () => { + let comp: CustomerDeleteDialogComponent; + let fixture: ComponentFixture; + let service: CustomerService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [CustomerDeleteDialogComponent] + }) + .overrideTemplate(CustomerDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(CustomerDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CustomerService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/customer/customer-detail.component.spec.ts b/src/test/javascript/spec/app/entities/customer/customer-detail.component.spec.ts new file mode 100644 index 00000000..1e4506ac --- /dev/null +++ b/src/test/javascript/spec/app/entities/customer/customer-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { CustomerDetailComponent } from 'app/entities/customer/customer-detail.component'; +import { Customer } from 'app/shared/model/customer.model'; + +describe('Component Tests', () => { + describe('Customer Management Detail Component', () => { + let comp: CustomerDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ customer: new Customer(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [CustomerDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(CustomerDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(CustomerDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.customer).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/customer/customer-update.component.spec.ts b/src/test/javascript/spec/app/entities/customer/customer-update.component.spec.ts new file mode 100644 index 00000000..e50a46df --- /dev/null +++ b/src/test/javascript/spec/app/entities/customer/customer-update.component.spec.ts @@ -0,0 +1,60 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { CustomerUpdateComponent } from 'app/entities/customer/customer-update.component'; +import { CustomerService } from 'app/entities/customer/customer.service'; +import { Customer } from 'app/shared/model/customer.model'; + +describe('Component Tests', () => { + describe('Customer Management Update Component', () => { + let comp: CustomerUpdateComponent; + let fixture: ComponentFixture; + let service: CustomerService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [CustomerUpdateComponent] + }) + .overrideTemplate(CustomerUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(CustomerUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CustomerService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Customer(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.customer = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Customer(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.customer = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/customer/customer.component.spec.ts b/src/test/javascript/spec/app/entities/customer/customer.component.spec.ts new file mode 100644 index 00000000..414db92f --- /dev/null +++ b/src/test/javascript/spec/app/entities/customer/customer.component.spec.ts @@ -0,0 +1,128 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { CustomerComponent } from 'app/entities/customer/customer.component'; +import { CustomerService } from 'app/entities/customer/customer.service'; +import { Customer } from 'app/shared/model/customer.model'; + +describe('Component Tests', () => { + describe('Customer Management Component', () => { + let comp: CustomerComponent; + let fixture: ComponentFixture; + let service: CustomerService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [CustomerComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(CustomerComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(CustomerComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CustomerService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Customer(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Customer(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should re-initialize the page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Customer(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + comp.reset(); + + // THEN + expect(comp.page).toEqual(0); + expect(service.query).toHaveBeenCalledTimes(2); + expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + it('should calculate the sort attribute for an id', () => { + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,asc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,asc', 'id']); + }); + }); +}); 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 new file mode 100644 index 00000000..6bd1b1d1 --- /dev/null +++ b/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts @@ -0,0 +1,174 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } 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 * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { CustomerService } from 'app/entities/customer/customer.service'; +import { ICustomer, Customer, CustomerKind, VatRegion } from 'app/shared/model/customer.model'; + +describe('Service Tests', () => { + describe('Customer Service', () => { + let injector: TestBed; + let service: CustomerService; + let httpMock: HttpTestingController; + let elemDefault: ICustomer; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(CustomerService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + 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( + { + birthDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Customer', async () => { + const returnedFromService = Object.assign( + { + id: 0, + birthDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); + service + .create(new Customer(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Customer', async () => { + const returnedFromService = Object.assign( + { + 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', + billingAddress: 'BBBBBB', + remark: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Customer', async () => { + const returnedFromService = Object.assign( + { + 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', + billingAddress: 'BBBBBB', + remark: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Customer', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/membership/membership-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/membership/membership-delete-dialog.component.spec.ts new file mode 100644 index 00000000..9b396b77 --- /dev/null +++ b/src/test/javascript/spec/app/entities/membership/membership-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { MembershipDeleteDialogComponent } from 'app/entities/membership/membership-delete-dialog.component'; +import { MembershipService } from 'app/entities/membership/membership.service'; + +describe('Component Tests', () => { + describe('Membership Management Delete Component', () => { + let comp: MembershipDeleteDialogComponent; + let fixture: ComponentFixture; + let service: MembershipService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [MembershipDeleteDialogComponent] + }) + .overrideTemplate(MembershipDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(MembershipDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(MembershipService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/membership/membership-detail.component.spec.ts b/src/test/javascript/spec/app/entities/membership/membership-detail.component.spec.ts new file mode 100644 index 00000000..a66f96f5 --- /dev/null +++ b/src/test/javascript/spec/app/entities/membership/membership-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { MembershipDetailComponent } from 'app/entities/membership/membership-detail.component'; +import { Membership } from 'app/shared/model/membership.model'; + +describe('Component Tests', () => { + describe('Membership Management Detail Component', () => { + let comp: MembershipDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ membership: new Membership(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [MembershipDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(MembershipDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(MembershipDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.membership).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/membership/membership-update.component.spec.ts b/src/test/javascript/spec/app/entities/membership/membership-update.component.spec.ts new file mode 100644 index 00000000..abd5a5a2 --- /dev/null +++ b/src/test/javascript/spec/app/entities/membership/membership-update.component.spec.ts @@ -0,0 +1,60 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { MembershipUpdateComponent } from 'app/entities/membership/membership-update.component'; +import { MembershipService } from 'app/entities/membership/membership.service'; +import { Membership } from 'app/shared/model/membership.model'; + +describe('Component Tests', () => { + describe('Membership Management Update Component', () => { + let comp: MembershipUpdateComponent; + let fixture: ComponentFixture; + let service: MembershipService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [MembershipUpdateComponent] + }) + .overrideTemplate(MembershipUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(MembershipUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(MembershipService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Membership(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.membership = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Membership(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.membership = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/membership/membership.component.spec.ts b/src/test/javascript/spec/app/entities/membership/membership.component.spec.ts new file mode 100644 index 00000000..a43d6a1c --- /dev/null +++ b/src/test/javascript/spec/app/entities/membership/membership.component.spec.ts @@ -0,0 +1,128 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { MembershipComponent } from 'app/entities/membership/membership.component'; +import { MembershipService } from 'app/entities/membership/membership.service'; +import { Membership } from 'app/shared/model/membership.model'; + +describe('Component Tests', () => { + describe('Membership Management Component', () => { + let comp: MembershipComponent; + let fixture: ComponentFixture; + let service: MembershipService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [MembershipComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(MembershipComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(MembershipComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(MembershipService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Membership(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Membership(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should re-initialize the page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Membership(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + comp.reset(); + + // THEN + expect(comp.page).toEqual(0); + expect(service.query).toHaveBeenCalledTimes(2); + expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + it('should calculate the sort attribute for an id', () => { + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,asc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,asc', 'id']); + }); + }); +}); 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 new file mode 100644 index 00000000..52064002 --- /dev/null +++ b/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts @@ -0,0 +1,152 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } 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 * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { MembershipService } from 'app/entities/membership/membership.service'; +import { IMembership, Membership } from 'app/shared/model/membership.model'; + +describe('Service Tests', () => { + describe('Membership Service', () => { + let injector: TestBed; + let service: MembershipService; + let httpMock: HttpTestingController; + let elemDefault: IMembership; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(MembershipService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + elemDefault = new Membership(0, currentDate, currentDate, currentDate, currentDate, 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + admissionDocumentDate: currentDate.format(DATE_FORMAT), + cancellationDocumentDate: currentDate.format(DATE_FORMAT), + memberFromDate: currentDate.format(DATE_FORMAT), + memberUntilDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Membership', async () => { + const returnedFromService = Object.assign( + { + id: 0, + 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( + { + admissionDocumentDate: currentDate, + cancellationDocumentDate: currentDate, + memberFromDate: currentDate, + memberUntilDate: currentDate + }, + returnedFromService + ); + service + .create(new Membership(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Membership', async () => { + const returnedFromService = Object.assign( + { + 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( + { + admissionDocumentDate: currentDate, + cancellationDocumentDate: currentDate, + memberFromDate: currentDate, + memberUntilDate: currentDate + }, + returnedFromService + ); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Membership', async () => { + const returnedFromService = Object.assign( + { + 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( + { + admissionDocumentDate: currentDate, + cancellationDocumentDate: currentDate, + memberFromDate: currentDate, + memberUntilDate: currentDate + }, + returnedFromService + ); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Membership', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts new file mode 100644 index 00000000..6dec0e0e --- /dev/null +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { SepaMandateDeleteDialogComponent } from 'app/entities/sepa-mandate/sepa-mandate-delete-dialog.component'; +import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service'; + +describe('Component Tests', () => { + describe('SepaMandate Management Delete Component', () => { + let comp: SepaMandateDeleteDialogComponent; + let fixture: ComponentFixture; + let service: SepaMandateService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [SepaMandateDeleteDialogComponent] + }) + .overrideTemplate(SepaMandateDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(SepaMandateDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(SepaMandateService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-detail.component.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-detail.component.spec.ts new file mode 100644 index 00000000..ba8ffcb2 --- /dev/null +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { SepaMandateDetailComponent } from 'app/entities/sepa-mandate/sepa-mandate-detail.component'; +import { SepaMandate } from 'app/shared/model/sepa-mandate.model'; + +describe('Component Tests', () => { + describe('SepaMandate Management Detail Component', () => { + let comp: SepaMandateDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ sepaMandate: new SepaMandate(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [SepaMandateDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(SepaMandateDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(SepaMandateDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.sepaMandate).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-update.component.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-update.component.spec.ts new file mode 100644 index 00000000..c2246524 --- /dev/null +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-update.component.spec.ts @@ -0,0 +1,60 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { SepaMandateUpdateComponent } from 'app/entities/sepa-mandate/sepa-mandate-update.component'; +import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service'; +import { SepaMandate } from 'app/shared/model/sepa-mandate.model'; + +describe('Component Tests', () => { + describe('SepaMandate Management Update Component', () => { + let comp: SepaMandateUpdateComponent; + let fixture: ComponentFixture; + let service: SepaMandateService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [SepaMandateUpdateComponent] + }) + .overrideTemplate(SepaMandateUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(SepaMandateUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(SepaMandateService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new SepaMandate(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.sepaMandate = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new SepaMandate(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.sepaMandate = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.component.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.component.spec.ts new file mode 100644 index 00000000..66ce50bd --- /dev/null +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.component.spec.ts @@ -0,0 +1,128 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { SepaMandateComponent } from 'app/entities/sepa-mandate/sepa-mandate.component'; +import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service'; +import { SepaMandate } from 'app/shared/model/sepa-mandate.model'; + +describe('Component Tests', () => { + describe('SepaMandate Management Component', () => { + let comp: SepaMandateComponent; + let fixture: ComponentFixture; + let service: SepaMandateService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [SepaMandateComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(SepaMandateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(SepaMandateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(SepaMandateService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new SepaMandate(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new SepaMandate(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should re-initialize the page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new SepaMandate(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + comp.reset(); + + // THEN + expect(comp.page).toEqual(0); + expect(service.query).toHaveBeenCalledTimes(2); + expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + it('should calculate the sort attribute for an id', () => { + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,asc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,asc', 'id']); + }); + }); +}); 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 new file mode 100644 index 00000000..cbe6e89b --- /dev/null +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.service.spec.ts @@ -0,0 +1,176 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } 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 * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service'; +import { ISepaMandate, SepaMandate } from 'app/shared/model/sepa-mandate.model'; + +describe('Service Tests', () => { + describe('SepaMandate Service', () => { + let injector: TestBed; + let service: SepaMandateService; + let httpMock: HttpTestingController; + let elemDefault: ISepaMandate; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(SepaMandateService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + elemDefault = new SepaMandate( + 0, + 'AAAAAAA', + 'AAAAAAA', + 'AAAAAAA', + currentDate, + currentDate, + currentDate, + currentDate, + currentDate, + 'AAAAAAA' + ); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + 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 + ); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a SepaMandate', async () => { + const returnedFromService = Object.assign( + { + id: 0, + 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( + { + grantingDocumentDate: currentDate, + revokationDocumentDate: currentDate, + validFromDate: currentDate, + validUntilDate: currentDate, + lastUsedDate: currentDate + }, + returnedFromService + ); + service + .create(new SepaMandate(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a SepaMandate', async () => { + const returnedFromService = Object.assign( + { + reference: 'BBBBBB', + iban: 'BBBBBB', + bic: 'BBBBBB', + 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( + { + grantingDocumentDate: currentDate, + revokationDocumentDate: currentDate, + validFromDate: currentDate, + validUntilDate: currentDate, + lastUsedDate: currentDate + }, + returnedFromService + ); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of SepaMandate', async () => { + const returnedFromService = Object.assign( + { + reference: 'BBBBBB', + iban: 'BBBBBB', + bic: 'BBBBBB', + 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( + { + grantingDocumentDate: currentDate, + revokationDocumentDate: currentDate, + validFromDate: currentDate, + validUntilDate: currentDate, + lastUsedDate: currentDate + }, + returnedFromService + ); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a SepaMandate', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/share/share-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/share/share-delete-dialog.component.spec.ts new file mode 100644 index 00000000..7e1c8acb --- /dev/null +++ b/src/test/javascript/spec/app/entities/share/share-delete-dialog.component.spec.ts @@ -0,0 +1,52 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { Observable, of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { ShareDeleteDialogComponent } from 'app/entities/share/share-delete-dialog.component'; +import { ShareService } from 'app/entities/share/share.service'; + +describe('Component Tests', () => { + describe('Share Management Delete Component', () => { + let comp: ShareDeleteDialogComponent; + let fixture: ComponentFixture; + let service: ShareService; + let mockEventManager: any; + let mockActiveModal: any; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [ShareDeleteDialogComponent] + }) + .overrideTemplate(ShareDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(ShareDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(ShareService); + mockEventManager = fixture.debugElement.injector.get(JhiEventManager); + mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/share/share-detail.component.spec.ts b/src/test/javascript/spec/app/entities/share/share-detail.component.spec.ts new file mode 100644 index 00000000..69de2445 --- /dev/null +++ b/src/test/javascript/spec/app/entities/share/share-detail.component.spec.ts @@ -0,0 +1,40 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { ShareDetailComponent } from 'app/entities/share/share-detail.component'; +import { Share } from 'app/shared/model/share.model'; + +describe('Component Tests', () => { + describe('Share Management Detail Component', () => { + let comp: ShareDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ share: new Share(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [ShareDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(ShareDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(ShareDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.share).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/share/share-update.component.spec.ts b/src/test/javascript/spec/app/entities/share/share-update.component.spec.ts new file mode 100644 index 00000000..279be464 --- /dev/null +++ b/src/test/javascript/spec/app/entities/share/share-update.component.spec.ts @@ -0,0 +1,60 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { Observable, of } from 'rxjs'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { ShareUpdateComponent } from 'app/entities/share/share-update.component'; +import { ShareService } from 'app/entities/share/share.service'; +import { Share } from 'app/shared/model/share.model'; + +describe('Component Tests', () => { + describe('Share Management Update Component', () => { + let comp: ShareUpdateComponent; + let fixture: ComponentFixture; + let service: ShareService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [ShareUpdateComponent] + }) + .overrideTemplate(ShareUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(ShareUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(ShareService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Share(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.share = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Share(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.share = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/share/share.component.spec.ts b/src/test/javascript/spec/app/entities/share/share.component.spec.ts new file mode 100644 index 00000000..ab0e60bb --- /dev/null +++ b/src/test/javascript/spec/app/entities/share/share.component.spec.ts @@ -0,0 +1,128 @@ +/* tslint:disable max-line-length */ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { Observable, of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HsadminNgTestModule } from '../../../test.module'; +import { ShareComponent } from 'app/entities/share/share.component'; +import { ShareService } from 'app/entities/share/share.service'; +import { Share } from 'app/shared/model/share.model'; + +describe('Component Tests', () => { + describe('Share Management Component', () => { + let comp: ShareComponent; + let fixture: ComponentFixture; + let service: ShareService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HsadminNgTestModule], + declarations: [ShareComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(ShareComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(ShareComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(ShareService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Share(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Share(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should re-initialize the page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Share(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + comp.reset(); + + // THEN + expect(comp.page).toEqual(0); + expect(service.query).toHaveBeenCalledTimes(2); + expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + it('should calculate the sort attribute for an id', () => { + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,asc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,asc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/share/share.service.spec.ts b/src/test/javascript/spec/app/entities/share/share.service.spec.ts new file mode 100644 index 00000000..73bf3281 --- /dev/null +++ b/src/test/javascript/spec/app/entities/share/share.service.spec.ts @@ -0,0 +1,142 @@ +/* tslint:disable max-line-length */ +import { TestBed, getTestBed } 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 * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { ShareService } from 'app/entities/share/share.service'; +import { IShare, Share, ShareAction } from 'app/shared/model/share.model'; + +describe('Service Tests', () => { + describe('Share Service', () => { + let injector: TestBed; + let service: ShareService; + let httpMock: HttpTestingController; + let elemDefault: IShare; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(ShareService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + elemDefault = new Share(0, currentDate, currentDate, ShareAction.SUBSCRIPTION, 0, 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + service + .find(123) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault })); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should create a Share', async () => { + const returnedFromService = Object.assign( + { + id: 0, + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + valueDate: currentDate + }, + returnedFromService + ); + service + .create(new Share(null)) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should update a Share', async () => { + const returnedFromService = Object.assign( + { + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT), + action: 'BBBBBB', + quantity: 1, + remark: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + documentDate: currentDate, + valueDate: currentDate + }, + returnedFromService + ); + service + .update(expected) + .pipe(take(1)) + .subscribe(resp => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); + }); + + it('should return a list of Share', async () => { + const returnedFromService = Object.assign( + { + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT), + action: 'BBBBBB', + quantity: 1, + remark: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + valueDate: currentDate + }, + returnedFromService + ); + service + .query(expected) + .pipe( + take(1), + map(resp => resp.body) + ) + .subscribe(body => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); + httpMock.verify(); + }); + + it('should delete a Share', async () => { + const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +});