From 7f0dfebaa41729b1408d7e4a74cf4322bbe65a92 Mon Sep 17 00:00:00 2001 From: Michael Hierweck Date: Wed, 17 Apr 2019 16:45:43 +0200 Subject: [PATCH 1/5] Model customers. --- .jhipster/Asset.json | 6 +- .jhipster/Contact.json | 49 - .jhipster/Customer.json | 32 +- .jhipster/CustomerContact.json | 40 - .jhipster/Membership.json | 18 +- .jhipster/SepaMandate.json | 84 ++ .jhipster/Share.json | 6 +- .../hostsharing/hsadminng/domain/Asset.java | 21 +- .../hostsharing/hsadminng/domain/Contact.java | 148 --- .../hsadminng/domain/Customer.java | 99 +- .../hsadminng/domain/CustomerContact.java | 119 --- .../hsadminng/domain/Membership.java | 72 +- .../hsadminng/domain/SepaMandate.java | 241 +++++ .../hostsharing/hsadminng/domain/Share.java | 21 +- .../enumeration/CustomerContactRole.java | 8 - .../repository/ContactRepository.java | 15 - .../repository/CustomerContactRepository.java | 15 - .../repository/SepaMandateRepository.java | 15 + .../hsadminng/service/AssetQueryService.java | 6 +- .../service/ContactQueryService.java | 108 -- .../hsadminng/service/ContactService.java | 84 -- .../service/CustomerContactQueryService.java | 106 -- .../service/CustomerContactService.java | 84 -- .../service/CustomerQueryService.java | 39 +- .../service/MembershipQueryService.java | 11 +- .../service/SepaMandateQueryService.java | 126 +++ .../hsadminng/service/SepaMandateService.java | 84 ++ .../hsadminng/service/ShareQueryService.java | 6 +- .../hsadminng/service/dto/AssetCriteria.java | 16 +- .../hsadminng/service/dto/AssetDTO.java | 23 +- .../service/dto/ContactCriteria.java | 115 --- .../hsadminng/service/dto/ContactDTO.java | 88 -- .../service/dto/CustomerContactCriteria.java | 108 -- .../service/dto/CustomerContactDTO.java | 106 -- .../service/dto/CustomerCriteria.java | 94 +- .../hsadminng/service/dto/CustomerDTO.java | 36 +- .../service/dto/MembershipCriteria.java | 45 +- .../hsadminng/service/dto/MembershipDTO.java | 36 +- .../service/dto/SepaMandateCriteria.java | 194 ++++ .../hsadminng/service/dto/SepaMandateDTO.java | 178 ++++ .../hsadminng/service/dto/ShareCriteria.java | 16 +- .../hsadminng/service/dto/ShareDTO.java | 23 +- .../hsadminng/service/mapper/AssetMapper.java | 5 +- .../service/mapper/ContactMapper.java | 26 - .../service/mapper/CustomerContactMapper.java | 32 - .../service/mapper/CustomerMapper.java | 8 +- .../service/mapper/SepaMandateMapper.java | 29 + .../hsadminng/service/mapper/ShareMapper.java | 5 +- .../hsadminng/web/rest/ContactResource.java | 138 --- .../web/rest/CustomerContactResource.java | 138 --- .../web/rest/SepaMandateResource.java | 138 +++ src/main/jdl/customer.jdl | 51 +- ...ded_entity_constraints_CustomerContact.xml | 24 - ...20190403083738_added_entity_Membership.xml | 39 - ... 20190418073043_added_entity_Customer.xml} | 24 +- ...0190418073044_added_entity_Membership.xml} | 16 +- ...4_added_entity_constraints_Membership.xml} | 2 +- ... => 20190418073045_added_entity_Share.xml} | 10 +- ...073045_added_entity_constraints_Share.xml} | 6 +- ... => 20190418073046_added_entity_Asset.xml} | 10 +- ...073046_added_entity_constraints_Asset.xml} | 6 +- ...190418073047_added_entity_SepaMandate.xml} | 40 +- ...7_added_entity_constraints_SepaMandate.xml | 18 + .../resources/config/liquibase/master.xml | 19 +- .../asset/asset-detail.component.html | 6 +- .../asset/asset-update.component.html | 13 +- .../app/entities/asset/asset.component.html | 6 +- .../contact-delete-dialog.component.ts | 65 -- .../contact/contact-detail.component.html | 35 - .../contact/contact-detail.component.ts | 24 - .../contact/contact-update.component.html | 69 -- .../contact/contact-update.component.ts | 51 - .../entities/contact/contact.component.html | 58 -- .../app/entities/contact/contact.route.ts | 93 -- .../app/entities/contact/contact.service.ts | 38 - src/main/webapp/app/entities/contact/index.ts | 6 - ...tomer-contact-delete-dialog.component.html | 19 - .../customer-contact-detail.component.html | 39 - .../customer-contact-detail.component.ts | 24 - .../customer-contact-update.component.html | 64 -- .../customer-contact.component.html | 66 -- .../customer-contact.component.ts | 108 -- .../customer-contact.module.ts | 45 - .../customer-contact.route.ts | 93 -- .../customer-contact.service.ts | 38 - .../app/entities/customer-contact/index.ts | 6 - .../customer/customer-detail.component.html | 12 +- .../customer/customer-update.component.html | 97 +- .../entities/customer/customer.component.html | 25 +- src/main/webapp/app/entities/entity.module.ts | 26 +- .../membership-detail.component.html | 12 +- .../membership-update.component.html | 33 +- .../membership/membership-update.component.ts | 4 +- .../membership/membership.component.html | 10 +- .../entities/membership/membership.service.ts | 12 +- .../webapp/app/entities/sepa-mandate/index.ts | 6 + ...sepa-mandate-delete-dialog.component.html} | 6 +- .../sepa-mandate-delete-dialog.component.ts} | 34 +- .../sepa-mandate-detail.component.html | 65 ++ .../sepa-mandate-detail.component.ts | 24 + .../sepa-mandate-update.component.html | 147 +++ .../sepa-mandate-update.component.ts} | 50 +- .../sepa-mandate/sepa-mandate.component.html | 76 ++ .../sepa-mandate.component.ts} | 34 +- .../sepa-mandate.module.ts} | 30 +- .../sepa-mandate/sepa-mandate.route.ts | 93 ++ .../sepa-mandate/sepa-mandate.service.ts | 86 ++ .../share/share-detail.component.html | 6 +- .../share/share-update.component.html | 13 +- .../app/entities/share/share.component.html | 6 +- .../app/layouts/navbar/navbar.component.html | 18 +- .../webapp/app/shared/model/asset.model.ts | 6 +- .../webapp/app/shared/model/contact.model.ts | 19 - .../shared/model/customer-contact.model.ts | 25 - .../webapp/app/shared/model/customer.model.ts | 16 +- .../app/shared/model/membership.model.ts | 10 +- .../app/shared/model/sepa-mandate.model.ts | 33 + .../webapp/app/shared/model/share.model.ts | 6 +- src/main/webapp/i18n/de/asset.json | 2 +- src/main/webapp/i18n/de/contact.json | 24 - src/main/webapp/i18n/de/customer.json | 8 +- src/main/webapp/i18n/de/customerContact.json | 23 - .../webapp/i18n/de/customerContactRole.json | 10 - src/main/webapp/i18n/de/global.json | 3 +- src/main/webapp/i18n/de/membership.json | 5 +- src/main/webapp/i18n/de/sepaMandate.json | 30 + src/main/webapp/i18n/de/share.json | 2 +- src/main/webapp/i18n/en/asset.json | 2 +- src/main/webapp/i18n/en/contact.json | 24 - src/main/webapp/i18n/en/customer.json | 8 +- src/main/webapp/i18n/en/customerContact.json | 23 - .../webapp/i18n/en/customerContactRole.json | 10 - src/main/webapp/i18n/en/global.json | 3 +- src/main/webapp/i18n/en/membership.json | 5 +- src/main/webapp/i18n/en/sepaMandate.json | 30 + src/main/webapp/i18n/en/share.json | 2 +- .../web/rest/AssetResourceIntTest.java | 31 +- .../web/rest/ContactResourceIntTest.java | 536 ---------- .../rest/CustomerContactResourceIntTest.java | 431 -------- .../web/rest/CustomerResourceIntTest.java | 190 ++-- .../web/rest/MembershipResourceIntTest.java | 201 ++-- .../web/rest/SepaMandateResourceIntTest.java | 972 ++++++++++++++++++ .../web/rest/ShareResourceIntTest.java | 33 +- .../asset/asset-update.component.spec.ts | 4 +- .../entities/contact/contact.service.spec.ts | 108 -- ...er-contact-delete-dialog.component.spec.ts | 52 - .../customer-contact-detail.component.spec.ts | 40 - .../customer-contact-update.component.spec.ts | 60 -- .../customer-contact.component.spec.ts | 128 --- .../customer-contact.service.spec.ts | 104 -- .../customer-update.component.spec.ts | 4 +- .../customer/customer.service.spec.ts | 20 +- .../membership-update.component.spec.ts | 4 +- .../membership/membership.service.spec.ts | 32 +- ...a-mandate-delete-dialog.component.spec.ts} | 20 +- .../sepa-mandate-detail.component.spec.ts} | 20 +- .../sepa-mandate-update.component.spec.ts} | 30 +- .../sepa-mandate.component.spec.ts} | 34 +- .../sepa-mandate/sepa-mandate.service.spec.ts | 176 ++++ .../share/share-update.component.spec.ts | 4 +- 160 files changed, 3911 insertions(+), 5068 deletions(-) delete mode 100644 .jhipster/Contact.json delete mode 100644 .jhipster/CustomerContact.json create mode 100644 .jhipster/SepaMandate.json delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Contact.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/CustomerContact.java create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/SepaMandate.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerContactRole.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/repository/ContactRepository.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/repository/CustomerContactRepository.java create mode 100644 src/main/java/org/hostsharing/hsadminng/repository/SepaMandateRepository.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/ContactQueryService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/ContactService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/CustomerContactQueryService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/CustomerContactService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/SepaMandateService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/ContactCriteria.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/ContactDTO.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactCriteria.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactDTO.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateCriteria.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/ContactMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerContactMapper.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/SepaMandateMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/ContactResource.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/CustomerContactResource.java create mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/SepaMandateResource.java delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml rename src/main/resources/config/liquibase/changelog/{20190403083735_added_entity_Customer.xml => 20190418073043_added_entity_Customer.xml} (79%) rename src/main/resources/config/liquibase/changelog/{20190403083737_added_entity_CustomerContact.xml => 20190418073044_added_entity_Membership.xml} (77%) rename src/main/resources/config/liquibase/changelog/{20190403083738_added_entity_constraints_Membership.xml => 20190418073044_added_entity_constraints_Membership.xml} (93%) rename src/main/resources/config/liquibase/changelog/{20190403083739_added_entity_Share.xml => 20190418073045_added_entity_Share.xml} (81%) rename src/main/resources/config/liquibase/changelog/{20190403083739_added_entity_constraints_Share.xml => 20190418073045_added_entity_constraints_Share.xml} (83%) rename src/main/resources/config/liquibase/changelog/{20190403083740_added_entity_Asset.xml => 20190418073046_added_entity_Asset.xml} (81%) rename src/main/resources/config/liquibase/changelog/{20190403083740_added_entity_constraints_Asset.xml => 20190418073046_added_entity_constraints_Asset.xml} (83%) rename src/main/resources/config/liquibase/changelog/{20190403083736_added_entity_Contact.xml => 20190418073047_added_entity_SepaMandate.xml} (54%) create mode 100644 src/main/resources/config/liquibase/changelog/20190418073047_added_entity_constraints_SepaMandate.xml delete mode 100644 src/main/webapp/app/entities/contact/contact-delete-dialog.component.ts delete mode 100644 src/main/webapp/app/entities/contact/contact-detail.component.html delete mode 100644 src/main/webapp/app/entities/contact/contact-detail.component.ts delete mode 100644 src/main/webapp/app/entities/contact/contact-update.component.html delete mode 100644 src/main/webapp/app/entities/contact/contact-update.component.ts delete mode 100644 src/main/webapp/app/entities/contact/contact.component.html delete mode 100644 src/main/webapp/app/entities/contact/contact.route.ts delete mode 100644 src/main/webapp/app/entities/contact/contact.service.ts delete mode 100644 src/main/webapp/app/entities/contact/index.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.html delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.html delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-update.component.html delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.component.html delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.component.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.module.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.route.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.service.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/index.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/index.ts rename src/main/webapp/app/entities/{contact/contact-delete-dialog.component.html => sepa-mandate/sepa-mandate-delete-dialog.component.html} (67%) rename src/main/webapp/app/entities/{customer-contact/customer-contact-delete-dialog.component.ts => sepa-mandate/sepa-mandate-delete-dialog.component.ts} (52%) create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.html rename src/main/webapp/app/entities/{customer-contact/customer-contact-update.component.ts => sepa-mandate/sepa-mandate-update.component.ts} (51%) create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html rename src/main/webapp/app/entities/{contact/contact.component.ts => sepa-mandate/sepa-mandate.component.ts} (70%) rename src/main/webapp/app/entities/{contact/contact.module.ts => sepa-mandate/sepa-mandate.module.ts} (56%) create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.route.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts delete mode 100644 src/main/webapp/app/shared/model/contact.model.ts delete mode 100644 src/main/webapp/app/shared/model/customer-contact.model.ts create mode 100644 src/main/webapp/app/shared/model/sepa-mandate.model.ts delete mode 100644 src/main/webapp/i18n/de/contact.json delete mode 100644 src/main/webapp/i18n/de/customerContact.json delete mode 100644 src/main/webapp/i18n/de/customerContactRole.json create mode 100644 src/main/webapp/i18n/de/sepaMandate.json delete mode 100644 src/main/webapp/i18n/en/contact.json delete mode 100644 src/main/webapp/i18n/en/customerContact.json delete mode 100644 src/main/webapp/i18n/en/customerContactRole.json create mode 100644 src/main/webapp/i18n/en/sepaMandate.json delete mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java delete mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java create mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java delete mode 100644 src/test/javascript/spec/app/entities/contact/contact.service.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact.service.spec.ts rename src/test/javascript/spec/app/entities/{contact/contact-delete-dialog.component.spec.ts => sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts} (67%) rename src/test/javascript/spec/app/entities/{contact/contact-detail.component.spec.ts => sepa-mandate/sepa-mandate-detail.component.spec.ts} (52%) rename src/test/javascript/spec/app/entities/{contact/contact-update.component.spec.ts => sepa-mandate/sepa-mandate-update.component.spec.ts} (62%) rename src/test/javascript/spec/app/entities/{contact/contact.component.spec.ts => sepa-mandate/sepa-mandate.component.spec.ts} (74%) create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.service.spec.ts diff --git a/.jhipster/Asset.json b/.jhipster/Asset.json index c1e70387..5fb969e8 100644 --- a/.jhipster/Asset.json +++ b/.jhipster/Asset.json @@ -38,11 +38,11 @@ "otherEntityName": "membership", "otherEntityRelationshipName": "asset", "relationshipValidateRules": "required", - "relationshipName": "member", - "otherEntityField": "id" + "relationshipName": "membership", + "otherEntityField": "from" } ], - "changelogDate": "20190403083740", + "changelogDate": "20190418073046", "entityTableName": "asset", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/.jhipster/Contact.json b/.jhipster/Contact.json deleted file mode 100644 index e7aec648..00000000 --- a/.jhipster/Contact.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "Contact", - "fields": [ - { - "fieldName": "firstName", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - }, - { - "fieldName": "lastName", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - }, - { - "fieldName": "email", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - } - ], - "relationships": [ - { - "relationshipType": "one-to-many", - "otherEntityName": "customerContact", - "otherEntityRelationshipName": "contact", - "relationshipName": "role" - } - ], - "changelogDate": "20190403083736", - "entityTableName": "contact", - "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 index 36d7340c..923f2f92 100644 --- a/.jhipster/Customer.json +++ b/.jhipster/Customer.json @@ -32,6 +32,14 @@ ], "fieldValidateRulesMaxlength": 80 }, + { + "fieldName": "contractualSalutation", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 80 + }, { "fieldName": "contractualAddress", "fieldType": "String", @@ -42,7 +50,7 @@ "fieldValidateRulesMaxlength": 400 }, { - "fieldName": "contractualSalutation", + "fieldName": "billingSalutation", "fieldType": "String", "fieldValidateRules": [ "maxlength" @@ -56,31 +64,23 @@ "maxlength" ], "fieldValidateRulesMaxlength": 400 - }, - { - "fieldName": "billingSalutation", - "fieldType": "String", - "fieldValidateRules": [ - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 } ], "relationships": [ - { - "relationshipType": "one-to-many", - "otherEntityName": "customerContact", - "otherEntityRelationshipName": "customer", - "relationshipName": "role" - }, { "relationshipType": "one-to-many", "otherEntityName": "membership", "otherEntityRelationshipName": "customer", "relationshipName": "membership" + }, + { + "relationshipType": "one-to-many", + "otherEntityName": "sepaMandate", + "otherEntityRelationshipName": "customer", + "relationshipName": "sepamandate" } ], - "changelogDate": "20190403083735", + "changelogDate": "20190418073043", "entityTableName": "customer", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/.jhipster/CustomerContact.json b/.jhipster/CustomerContact.json deleted file mode 100644 index 7004cae7..00000000 --- a/.jhipster/CustomerContact.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "CustomerContact", - "fields": [ - { - "fieldName": "role", - "fieldType": "CustomerContactRole", - "fieldValues": "CONTRACTUAL,TECHNICAL,FINANCIAL", - "fieldValidateRules": [ - "required" - ] - } - ], - "relationships": [ - { - "relationshipType": "many-to-one", - "otherEntityName": "contact", - "otherEntityRelationshipName": "role", - "relationshipValidateRules": "required", - "relationshipName": "contact", - "otherEntityField": "email" - }, - { - "relationshipType": "many-to-one", - "otherEntityName": "customer", - "otherEntityRelationshipName": "role", - "relationshipValidateRules": "required", - "relationshipName": "customer", - "otherEntityField": "prefix" - } - ], - "changelogDate": "20190403083737", - "entityTableName": "customer_contact", - "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 index c44a5c77..2497957f 100644 --- a/.jhipster/Membership.json +++ b/.jhipster/Membership.json @@ -2,28 +2,36 @@ "name": "Membership", "fields": [ { - "fieldName": "sinceDate", + "fieldName": "from", "fieldType": "LocalDate", "fieldValidateRules": [ "required" ] }, { - "fieldName": "untilDate", + "fieldName": "to", "fieldType": "LocalDate" + }, + { + "fieldName": "comment", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 160 } ], "relationships": [ { "relationshipType": "one-to-many", "otherEntityName": "share", - "otherEntityRelationshipName": "member", + "otherEntityRelationshipName": "membership", "relationshipName": "share" }, { "relationshipType": "one-to-many", "otherEntityName": "asset", - "otherEntityRelationshipName": "member", + "otherEntityRelationshipName": "membership", "relationshipName": "asset" }, { @@ -35,7 +43,7 @@ "otherEntityField": "prefix" } ], - "changelogDate": "20190403083738", + "changelogDate": "20190418073044", "entityTableName": "membership", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/.jhipster/SepaMandate.json b/.jhipster/SepaMandate.json new file mode 100644 index 00000000..0ffe72d5 --- /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": "created", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "validFrom", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "validTo", + "fieldType": "LocalDate" + }, + { + "fieldName": "lastUsed", + "fieldType": "LocalDate" + }, + { + "fieldName": "cancelled", + "fieldType": "LocalDate" + }, + { + "fieldName": "comment", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 160 + } + ], + "relationships": [ + { + "relationshipType": "many-to-one", + "otherEntityName": "customer", + "otherEntityRelationshipName": "sepamandate", + "relationshipValidateRules": "required", + "relationshipName": "customer", + "otherEntityField": "prefix" + } + ], + "changelogDate": "20190418073047", + "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 index 630f5a24..037cc5d5 100644 --- a/.jhipster/Share.json +++ b/.jhipster/Share.json @@ -38,11 +38,11 @@ "otherEntityName": "membership", "otherEntityRelationshipName": "share", "relationshipValidateRules": "required", - "relationshipName": "member", - "otherEntityField": "id" + "relationshipName": "membership", + "otherEntityField": "from" } ], - "changelogDate": "20190403083739", + "changelogDate": "20190418073045", "entityTableName": "share", "dto": "mapstruct", "pagination": "infinite-scroll", diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java index fa69bb84..d5e60652 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java @@ -2,16 +2,17 @@ package org.hostsharing.hsadminng.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; import javax.persistence.*; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +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. */ @@ -46,7 +47,7 @@ public class Asset implements Serializable { @ManyToOne(optional = false) @NotNull @JsonIgnoreProperties("assets") - private Membership member; + private Membership membership; // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public Long getId() { @@ -109,17 +110,17 @@ public class Asset implements Serializable { this.comment = comment; } - public Membership getMember() { - return member; + public Membership getMembership() { + return membership; } - public Asset member(Membership membership) { - this.member = membership; + public Asset membership(Membership membership) { + this.membership = membership; return this; } - public void setMember(Membership membership) { - this.member = membership; + public void setMembership(Membership membership) { + this.membership = membership; } // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Contact.java b/src/main/java/org/hostsharing/hsadminng/domain/Contact.java deleted file mode 100644 index 761b9b90..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/Contact.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.hostsharing.hsadminng.domain; - - -import com.fasterxml.jackson.annotation.JsonIgnore; - -import javax.persistence.*; -import javax.validation.constraints.*; - -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; -import java.util.Objects; - -/** - * A Contact. - */ -@Entity -@Table(name = "contact") -public class Contact implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") - @SequenceGenerator(name = "sequenceGenerator") - private Long id; - - @NotNull - @Size(max = 80) - @Column(name = "first_name", length = 80, nullable = false) - private String firstName; - - @NotNull - @Size(max = 80) - @Column(name = "last_name", length = 80, nullable = false) - private String lastName; - - @NotNull - @Size(max = 80) - @Column(name = "email", length = 80, nullable = false) - private String email; - - @OneToMany(mappedBy = "contact") - private Set roles = 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 String getFirstName() { - return firstName; - } - - public Contact firstName(String firstName) { - this.firstName = firstName; - return this; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public Contact lastName(String lastName) { - this.lastName = lastName; - return this; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public Contact email(String email) { - this.email = email; - return this; - } - - public void setEmail(String email) { - this.email = email; - } - - public Set getRoles() { - return roles; - } - - public Contact roles(Set customerContacts) { - this.roles = customerContacts; - return this; - } - - public Contact addRole(CustomerContact customerContact) { - this.roles.add(customerContact); - customerContact.setContact(this); - return this; - } - - public Contact removeRole(CustomerContact customerContact) { - this.roles.remove(customerContact); - customerContact.setContact(null); - return this; - } - - public void setRoles(Set customerContacts) { - this.roles = customerContacts; - } - // 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; - } - Contact contact = (Contact) o; - if (contact.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), contact.getId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getId()); - } - - @Override - public String toString() { - return "Contact{" + - "id=" + getId() + - ", firstName='" + getFirstName() + "'" + - ", lastName='" + getLastName() + "'" + - ", email='" + getEmail() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java index de1d9e78..eb7c378a 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java @@ -1,12 +1,15 @@ package org.hostsharing.hsadminng.domain; +import com.fasterxml.jackson.annotation.JsonIgnore; + import javax.persistence.*; import javax.validation.constraints.*; + import java.io.Serializable; import java.util.HashSet; -import java.util.Objects; import java.util.Set; +import java.util.Objects; /** * A Customer. @@ -38,27 +41,27 @@ public class Customer implements Serializable { @Column(name = "name", length = 80, nullable = false) private String name; + @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 = "contractual_salutation", length = 80) - private String contractualSalutation; + @Column(name = "billing_salutation", length = 80) + private String billingSalutation; @Size(max = 400) @Column(name = "billing_address", length = 400) private String billingAddress; - @Size(max = 80) - @Column(name = "billing_salutation", length = 80) - private String billingSalutation; - - @OneToMany(mappedBy = "customer") - private Set roles = new HashSet<>(); @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; @@ -107,19 +110,6 @@ public class Customer implements Serializable { this.name = name; } - 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 getContractualSalutation() { return contractualSalutation; } @@ -133,17 +123,17 @@ public class Customer implements Serializable { this.contractualSalutation = contractualSalutation; } - public String getBillingAddress() { - return billingAddress; + public String getContractualAddress() { + return contractualAddress; } - public Customer billingAddress(String billingAddress) { - this.billingAddress = billingAddress; + public Customer contractualAddress(String contractualAddress) { + this.contractualAddress = contractualAddress; return this; } - public void setBillingAddress(String billingAddress) { - this.billingAddress = billingAddress; + public void setContractualAddress(String contractualAddress) { + this.contractualAddress = contractualAddress; } public String getBillingSalutation() { @@ -159,29 +149,17 @@ public class Customer implements Serializable { this.billingSalutation = billingSalutation; } - public Set getRoles() { - return roles; + public String getBillingAddress() { + return billingAddress; } - public Customer roles(Set customerContacts) { - this.roles = customerContacts; + public Customer billingAddress(String billingAddress) { + this.billingAddress = billingAddress; return this; } - public Customer addRole(CustomerContact customerContact) { - this.roles.add(customerContact); - customerContact.setCustomer(this); - return this; - } - - public Customer removeRole(CustomerContact customerContact) { - this.roles.remove(customerContact); - customerContact.setCustomer(null); - return this; - } - - public void setRoles(Set customerContacts) { - this.roles = customerContacts; + public void setBillingAddress(String billingAddress) { + this.billingAddress = billingAddress; } public Set getMemberships() { @@ -208,6 +186,31 @@ public class Customer implements Serializable { 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 @@ -237,10 +240,10 @@ public class Customer implements Serializable { ", number=" + getNumber() + ", prefix='" + getPrefix() + "'" + ", name='" + getName() + "'" + - ", contractualAddress='" + getContractualAddress() + "'" + ", contractualSalutation='" + getContractualSalutation() + "'" + - ", billingAddress='" + getBillingAddress() + "'" + + ", contractualAddress='" + getContractualAddress() + "'" + ", billingSalutation='" + getBillingSalutation() + "'" + + ", billingAddress='" + getBillingAddress() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/domain/CustomerContact.java b/src/main/java/org/hostsharing/hsadminng/domain/CustomerContact.java deleted file mode 100644 index f740361a..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/CustomerContact.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.hostsharing.hsadminng.domain; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import javax.persistence.*; -import javax.validation.constraints.*; - -import java.io.Serializable; -import java.util.Objects; - -import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole; - -/** - * A CustomerContact. - */ -@Entity -@Table(name = "customer_contact") -public class CustomerContact implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") - @SequenceGenerator(name = "sequenceGenerator") - private Long id; - - @NotNull - @Enumerated(EnumType.STRING) - @Column(name = "jhi_role", nullable = false) - private CustomerContactRole role; - - @ManyToOne(optional = false) - @NotNull - @JsonIgnoreProperties("roles") - private Contact contact; - - @ManyToOne(optional = false) - @NotNull - @JsonIgnoreProperties("roles") - 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 CustomerContactRole getRole() { - return role; - } - - public CustomerContact role(CustomerContactRole role) { - this.role = role; - return this; - } - - public void setRole(CustomerContactRole role) { - this.role = role; - } - - public Contact getContact() { - return contact; - } - - public CustomerContact contact(Contact contact) { - this.contact = contact; - return this; - } - - public void setContact(Contact contact) { - this.contact = contact; - } - - public Customer getCustomer() { - return customer; - } - - public CustomerContact 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; - } - CustomerContact customerContact = (CustomerContact) o; - if (customerContact.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), customerContact.getId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getId()); - } - - @Override - public String toString() { - return "CustomerContact{" + - "id=" + getId() + - ", role='" + getRole() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java index 93f20433..5b6613e7 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java @@ -1,15 +1,17 @@ package org.hostsharing.hsadminng.domain; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.persistence.*; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.*; + import java.io.Serializable; import java.time.LocalDate; import java.util.HashSet; -import java.util.Objects; import java.util.Set; +import java.util.Objects; /** * A Membership. @@ -26,15 +28,19 @@ public class Membership implements Serializable { private Long id; @NotNull - @Column(name = "since_date", nullable = false) - private LocalDate sinceDate; + @Column(name = "jhi_from", nullable = false) + private LocalDate from; - @Column(name = "until_date") - private LocalDate untilDate; + @Column(name = "jhi_to") + private LocalDate to; - @OneToMany(mappedBy = "member") + @Size(max = 160) + @Column(name = "jhi_comment", length = 160) + private String comment; + + @OneToMany(mappedBy = "membership") private Set shares = new HashSet<>(); - @OneToMany(mappedBy = "member") + @OneToMany(mappedBy = "membership") private Set assets = new HashSet<>(); @ManyToOne(optional = false) @NotNull @@ -50,30 +56,43 @@ public class Membership implements Serializable { this.id = id; } - public LocalDate getSinceDate() { - return sinceDate; + public LocalDate getFrom() { + return from; } - public Membership sinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; + public Membership from(LocalDate from) { + this.from = from; return this; } - public void setSinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; + public void setFrom(LocalDate from) { + this.from = from; } - public LocalDate getUntilDate() { - return untilDate; + public LocalDate getTo() { + return to; } - public Membership untilDate(LocalDate untilDate) { - this.untilDate = untilDate; + public Membership to(LocalDate to) { + this.to = to; return this; } - public void setUntilDate(LocalDate untilDate) { - this.untilDate = untilDate; + public void setTo(LocalDate to) { + this.to = to; + } + + public String getComment() { + return comment; + } + + public Membership comment(String comment) { + this.comment = comment; + return this; + } + + public void setComment(String comment) { + this.comment = comment; } public Set getShares() { @@ -87,13 +106,13 @@ public class Membership implements Serializable { public Membership addShare(Share share) { this.shares.add(share); - share.setMember(this); + share.setMembership(this); return this; } public Membership removeShare(Share share) { this.shares.remove(share); - share.setMember(null); + share.setMembership(null); return this; } @@ -112,13 +131,13 @@ public class Membership implements Serializable { public Membership addAsset(Asset asset) { this.assets.add(asset); - asset.setMember(this); + asset.setMembership(this); return this; } public Membership removeAsset(Asset asset) { this.assets.remove(asset); - asset.setMember(null); + asset.setMembership(null); return this; } @@ -164,8 +183,9 @@ public class Membership implements Serializable { public String toString() { return "Membership{" + "id=" + getId() + - ", sinceDate='" + getSinceDate() + "'" + - ", untilDate='" + getUntilDate() + "'" + + ", from='" + getFrom() + "'" + + ", to='" + getTo() + "'" + + ", comment='" + getComment() + "'" + "}"; } } 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..7cee2803 --- /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 = "created", nullable = false) + private LocalDate created; + + @NotNull + @Column(name = "valid_from", nullable = false) + private LocalDate validFrom; + + @Column(name = "valid_to") + private LocalDate validTo; + + @Column(name = "last_used") + private LocalDate lastUsed; + + @Column(name = "cancelled") + private LocalDate cancelled; + + @Size(max = 160) + @Column(name = "jhi_comment", length = 160) + private String comment; + + @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 getCreated() { + return created; + } + + public SepaMandate created(LocalDate created) { + this.created = created; + return this; + } + + public void setCreated(LocalDate created) { + this.created = created; + } + + public LocalDate getValidFrom() { + return validFrom; + } + + public SepaMandate validFrom(LocalDate validFrom) { + this.validFrom = validFrom; + return this; + } + + public void setValidFrom(LocalDate validFrom) { + this.validFrom = validFrom; + } + + public LocalDate getValidTo() { + return validTo; + } + + public SepaMandate validTo(LocalDate validTo) { + this.validTo = validTo; + return this; + } + + public void setValidTo(LocalDate validTo) { + this.validTo = validTo; + } + + public LocalDate getLastUsed() { + return lastUsed; + } + + public SepaMandate lastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + return this; + } + + public void setLastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDate getCancelled() { + return cancelled; + } + + public SepaMandate cancelled(LocalDate cancelled) { + this.cancelled = cancelled; + return this; + } + + public void setCancelled(LocalDate cancelled) { + this.cancelled = cancelled; + } + + public String getComment() { + return comment; + } + + public SepaMandate comment(String comment) { + this.comment = comment; + return this; + } + + public void setComment(String comment) { + this.comment = comment; + } + + 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() + "'" + + ", created='" + getCreated() + "'" + + ", validFrom='" + getValidFrom() + "'" + + ", validTo='" + getValidTo() + "'" + + ", lastUsed='" + getLastUsed() + "'" + + ", cancelled='" + getCancelled() + "'" + + ", comment='" + getComment() + "'" + + "}"; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Share.java b/src/main/java/org/hostsharing/hsadminng/domain/Share.java index 0d91abc1..dbf6e2da 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Share.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Share.java @@ -2,15 +2,16 @@ package org.hostsharing.hsadminng.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.hostsharing.hsadminng.domain.enumeration.ShareAction; import javax.persistence.*; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +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. */ @@ -45,7 +46,7 @@ public class Share implements Serializable { @ManyToOne(optional = false) @NotNull @JsonIgnoreProperties("shares") - private Membership member; + private Membership membership; // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public Long getId() { @@ -108,17 +109,17 @@ public class Share implements Serializable { this.comment = comment; } - public Membership getMember() { - return member; + public Membership getMembership() { + return membership; } - public Share member(Membership membership) { - this.member = membership; + public Share membership(Membership membership) { + this.membership = membership; return this; } - public void setMember(Membership membership) { - this.member = membership; + public void setMembership(Membership membership) { + this.membership = membership; } // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove diff --git a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerContactRole.java b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerContactRole.java deleted file mode 100644 index 736a7ff6..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerContactRole.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.hostsharing.hsadminng.domain.enumeration; - -/** - * The CustomerContactRole enumeration. - */ -public enum CustomerContactRole { - CONTRACTUAL, TECHNICAL, FINANCIAL -} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/ContactRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/ContactRepository.java deleted file mode 100644 index 6bc2d4dc..00000000 --- a/src/main/java/org/hostsharing/hsadminng/repository/ContactRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hostsharing.hsadminng.repository; - -import org.hostsharing.hsadminng.domain.Contact; -import org.springframework.data.jpa.repository.*; -import org.springframework.stereotype.Repository; - - -/** - * Spring Data repository for the Contact entity. - */ -@SuppressWarnings("unused") -@Repository -public interface ContactRepository extends JpaRepository, JpaSpecificationExecutor { - -} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/CustomerContactRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/CustomerContactRepository.java deleted file mode 100644 index 88dba2c9..00000000 --- a/src/main/java/org/hostsharing/hsadminng/repository/CustomerContactRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hostsharing.hsadminng.repository; - -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.springframework.data.jpa.repository.*; -import org.springframework.stereotype.Repository; - - -/** - * Spring Data repository for the CustomerContact entity. - */ -@SuppressWarnings("unused") -@Repository -public interface CustomerContactRepository 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/service/AssetQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java index 81853758..8a823afc 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java @@ -101,9 +101,9 @@ public class AssetQueryService extends QueryService { if (criteria.getComment() != null) { specification = specification.and(buildStringSpecification(criteria.getComment(), Asset_.comment)); } - if (criteria.getMemberId() != null) { - specification = specification.and(buildSpecification(criteria.getMemberId(), - root -> root.join(Asset_.member, JoinType.LEFT).get(Membership_.id))); + 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/ContactQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/ContactQueryService.java deleted file mode 100644 index 6c153b1b..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/ContactQueryService.java +++ /dev/null @@ -1,108 +0,0 @@ -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.Contact; -import org.hostsharing.hsadminng.domain.*; // for static metamodels -import org.hostsharing.hsadminng.repository.ContactRepository; -import org.hostsharing.hsadminng.service.dto.ContactCriteria; -import org.hostsharing.hsadminng.service.dto.ContactDTO; -import org.hostsharing.hsadminng.service.mapper.ContactMapper; - -/** - * Service for executing complex queries for Contact entities in the database. - * The main input is a {@link ContactCriteria} which gets converted to {@link Specification}, - * in a way that all the filters must apply. - * It returns a {@link List} of {@link ContactDTO} or a {@link Page} of {@link ContactDTO} which fulfills the criteria. - */ -@Service -@Transactional(readOnly = true) -public class ContactQueryService extends QueryService { - - private final Logger log = LoggerFactory.getLogger(ContactQueryService.class); - - private final ContactRepository contactRepository; - - private final ContactMapper contactMapper; - - public ContactQueryService(ContactRepository contactRepository, ContactMapper contactMapper) { - this.contactRepository = contactRepository; - this.contactMapper = contactMapper; - } - - /** - * Return a {@link List} of {@link ContactDTO} 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(ContactCriteria criteria) { - log.debug("find by criteria : {}", criteria); - final Specification specification = createSpecification(criteria); - return contactMapper.toDto(contactRepository.findAll(specification)); - } - - /** - * Return a {@link Page} of {@link ContactDTO} 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(ContactCriteria criteria, Pageable page) { - log.debug("find by criteria : {}, page: {}", criteria, page); - final Specification specification = createSpecification(criteria); - return contactRepository.findAll(specification, page) - .map(contactMapper::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(ContactCriteria criteria) { - log.debug("count by criteria : {}", criteria); - final Specification specification = createSpecification(criteria); - return contactRepository.count(specification); - } - - /** - * Function to convert ContactCriteria to a {@link Specification} - */ - private Specification createSpecification(ContactCriteria criteria) { - Specification specification = Specification.where(null); - if (criteria != null) { - if (criteria.getId() != null) { - specification = specification.and(buildSpecification(criteria.getId(), Contact_.id)); - } - if (criteria.getFirstName() != null) { - specification = specification.and(buildStringSpecification(criteria.getFirstName(), Contact_.firstName)); - } - if (criteria.getLastName() != null) { - specification = specification.and(buildStringSpecification(criteria.getLastName(), Contact_.lastName)); - } - if (criteria.getEmail() != null) { - specification = specification.and(buildStringSpecification(criteria.getEmail(), Contact_.email)); - } - if (criteria.getRoleId() != null) { - specification = specification.and(buildSpecification(criteria.getRoleId(), - root -> root.join(Contact_.roles, JoinType.LEFT).get(CustomerContact_.id))); - } - } - return specification; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/ContactService.java b/src/main/java/org/hostsharing/hsadminng/service/ContactService.java deleted file mode 100644 index d75b7fb3..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/ContactService.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.hostsharing.hsadminng.service; - -import org.hostsharing.hsadminng.domain.Contact; -import org.hostsharing.hsadminng.repository.ContactRepository; -import org.hostsharing.hsadminng.service.dto.ContactDTO; -import org.hostsharing.hsadminng.service.mapper.ContactMapper; -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 Contact. - */ -@Service -@Transactional -public class ContactService { - - private final Logger log = LoggerFactory.getLogger(ContactService.class); - - private final ContactRepository contactRepository; - - private final ContactMapper contactMapper; - - public ContactService(ContactRepository contactRepository, ContactMapper contactMapper) { - this.contactRepository = contactRepository; - this.contactMapper = contactMapper; - } - - /** - * Save a contact. - * - * @param contactDTO the entity to save - * @return the persisted entity - */ - public ContactDTO save(ContactDTO contactDTO) { - log.debug("Request to save Contact : {}", contactDTO); - Contact contact = contactMapper.toEntity(contactDTO); - contact = contactRepository.save(contact); - return contactMapper.toDto(contact); - } - - /** - * Get all the contacts. - * - * @param pageable the pagination information - * @return the list of entities - */ - @Transactional(readOnly = true) - public Page findAll(Pageable pageable) { - log.debug("Request to get all Contacts"); - return contactRepository.findAll(pageable) - .map(contactMapper::toDto); - } - - - /** - * Get one contact 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 Contact : {}", id); - return contactRepository.findById(id) - .map(contactMapper::toDto); - } - - /** - * Delete the contact by id. - * - * @param id the id of the entity - */ - public void delete(Long id) { - log.debug("Request to delete Contact : {}", id); - contactRepository.deleteById(id); - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerContactQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerContactQueryService.java deleted file mode 100644 index 3675596d..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerContactQueryService.java +++ /dev/null @@ -1,106 +0,0 @@ -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.CustomerContact; -import org.hostsharing.hsadminng.domain.*; // for static metamodels -import org.hostsharing.hsadminng.repository.CustomerContactRepository; -import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria; -import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper; - -/** - * Service for executing complex queries for CustomerContact entities in the database. - * The main input is a {@link CustomerContactCriteria} which gets converted to {@link Specification}, - * in a way that all the filters must apply. - * It returns a {@link List} of {@link CustomerContactDTO} or a {@link Page} of {@link CustomerContactDTO} which fulfills the criteria. - */ -@Service -@Transactional(readOnly = true) -public class CustomerContactQueryService extends QueryService { - - private final Logger log = LoggerFactory.getLogger(CustomerContactQueryService.class); - - private final CustomerContactRepository customerContactRepository; - - private final CustomerContactMapper customerContactMapper; - - public CustomerContactQueryService(CustomerContactRepository customerContactRepository, CustomerContactMapper customerContactMapper) { - this.customerContactRepository = customerContactRepository; - this.customerContactMapper = customerContactMapper; - } - - /** - * Return a {@link List} of {@link CustomerContactDTO} 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(CustomerContactCriteria criteria) { - log.debug("find by criteria : {}", criteria); - final Specification specification = createSpecification(criteria); - return customerContactMapper.toDto(customerContactRepository.findAll(specification)); - } - - /** - * Return a {@link Page} of {@link CustomerContactDTO} 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(CustomerContactCriteria criteria, Pageable page) { - log.debug("find by criteria : {}, page: {}", criteria, page); - final Specification specification = createSpecification(criteria); - return customerContactRepository.findAll(specification, page) - .map(customerContactMapper::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(CustomerContactCriteria criteria) { - log.debug("count by criteria : {}", criteria); - final Specification specification = createSpecification(criteria); - return customerContactRepository.count(specification); - } - - /** - * Function to convert CustomerContactCriteria to a {@link Specification} - */ - private Specification createSpecification(CustomerContactCriteria criteria) { - Specification specification = Specification.where(null); - if (criteria != null) { - if (criteria.getId() != null) { - specification = specification.and(buildSpecification(criteria.getId(), CustomerContact_.id)); - } - if (criteria.getRole() != null) { - specification = specification.and(buildSpecification(criteria.getRole(), CustomerContact_.role)); - } - if (criteria.getContactId() != null) { - specification = specification.and(buildSpecification(criteria.getContactId(), - root -> root.join(CustomerContact_.contact, JoinType.LEFT).get(Contact_.id))); - } - if (criteria.getCustomerId() != null) { - specification = specification.and(buildSpecification(criteria.getCustomerId(), - root -> root.join(CustomerContact_.customer, JoinType.LEFT).get(Customer_.id))); - } - } - return specification; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerContactService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerContactService.java deleted file mode 100644 index 222ae0a8..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerContactService.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.hostsharing.hsadminng.service; - -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.hostsharing.hsadminng.repository.CustomerContactRepository; -import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper; -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 CustomerContact. - */ -@Service -@Transactional -public class CustomerContactService { - - private final Logger log = LoggerFactory.getLogger(CustomerContactService.class); - - private final CustomerContactRepository customerContactRepository; - - private final CustomerContactMapper customerContactMapper; - - public CustomerContactService(CustomerContactRepository customerContactRepository, CustomerContactMapper customerContactMapper) { - this.customerContactRepository = customerContactRepository; - this.customerContactMapper = customerContactMapper; - } - - /** - * Save a customerContact. - * - * @param customerContactDTO the entity to save - * @return the persisted entity - */ - public CustomerContactDTO save(CustomerContactDTO customerContactDTO) { - log.debug("Request to save CustomerContact : {}", customerContactDTO); - CustomerContact customerContact = customerContactMapper.toEntity(customerContactDTO); - customerContact = customerContactRepository.save(customerContact); - return customerContactMapper.toDto(customerContact); - } - - /** - * Get all the customerContacts. - * - * @param pageable the pagination information - * @return the list of entities - */ - @Transactional(readOnly = true) - public Page findAll(Pageable pageable) { - log.debug("Request to get all CustomerContacts"); - return customerContactRepository.findAll(pageable) - .map(customerContactMapper::toDto); - } - - - /** - * Get one customerContact 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 CustomerContact : {}", id); - return customerContactRepository.findById(id) - .map(customerContactMapper::toDto); - } - - /** - * Delete the customerContact by id. - * - * @param id the id of the entity - */ - public void delete(Long id) { - log.debug("Request to delete CustomerContact : {}", id); - customerContactRepository.deleteById(id); - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java index 214369a7..a3644a4f 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java @@ -1,14 +1,9 @@ package org.hostsharing.hsadminng.service; -import io.github.jhipster.service.QueryService; -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.CustomerContact_; -import org.hostsharing.hsadminng.domain.Customer_; -import org.hostsharing.hsadminng.domain.Membership_; -import org.hostsharing.hsadminng.repository.CustomerRepository; -import org.hostsharing.hsadminng.service.dto.CustomerCriteria; -import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerMapper; +import java.util.List; + +import javax.persistence.criteria.JoinType; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; @@ -17,8 +12,14 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.persistence.criteria.JoinType; -import java.util.List; +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. @@ -97,26 +98,26 @@ public class CustomerQueryService extends QueryService { if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Customer_.name)); } - if (criteria.getContractualAddress() != null) { - specification = specification.and(buildStringSpecification(criteria.getContractualAddress(), Customer_.contractualAddress)); - } if (criteria.getContractualSalutation() != null) { specification = specification.and(buildStringSpecification(criteria.getContractualSalutation(), Customer_.contractualSalutation)); } - if (criteria.getBillingAddress() != null) { - specification = specification.and(buildStringSpecification(criteria.getBillingAddress(), Customer_.billingAddress)); + 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.getRoleId() != null) { - specification = specification.and(buildSpecification(criteria.getRoleId(), - root -> root.join(Customer_.roles, JoinType.LEFT).get(CustomerContact_.id))); + if (criteria.getBillingAddress() != null) { + specification = specification.and(buildStringSpecification(criteria.getBillingAddress(), Customer_.billingAddress)); } 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/MembershipQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java index 66f86f14..b8dd7b49 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java @@ -89,11 +89,14 @@ public class MembershipQueryService extends QueryService { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Membership_.id)); } - if (criteria.getSinceDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getSinceDate(), Membership_.sinceDate)); + if (criteria.getFrom() != null) { + specification = specification.and(buildRangeSpecification(criteria.getFrom(), Membership_.from)); } - if (criteria.getUntilDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getUntilDate(), Membership_.untilDate)); + if (criteria.getTo() != null) { + specification = specification.and(buildRangeSpecification(criteria.getTo(), Membership_.to)); + } + if (criteria.getComment() != null) { + specification = specification.and(buildStringSpecification(criteria.getComment(), Membership_.comment)); } if (criteria.getShareId() != null) { specification = specification.and(buildSpecification(criteria.getShareId(), 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..3cb7e5da --- /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.getCreated() != null) { + specification = specification.and(buildRangeSpecification(criteria.getCreated(), SepaMandate_.created)); + } + if (criteria.getValidFrom() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidFrom(), SepaMandate_.validFrom)); + } + if (criteria.getValidTo() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidTo(), SepaMandate_.validTo)); + } + if (criteria.getLastUsed() != null) { + specification = specification.and(buildRangeSpecification(criteria.getLastUsed(), SepaMandate_.lastUsed)); + } + if (criteria.getCancelled() != null) { + specification = specification.and(buildRangeSpecification(criteria.getCancelled(), SepaMandate_.cancelled)); + } + if (criteria.getComment() != null) { + specification = specification.and(buildStringSpecification(criteria.getComment(), SepaMandate_.comment)); + } + 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 index 17e51676..ddb8f286 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java @@ -101,9 +101,9 @@ public class ShareQueryService extends QueryService { if (criteria.getComment() != null) { specification = specification.and(buildStringSpecification(criteria.getComment(), Share_.comment)); } - if (criteria.getMemberId() != null) { - specification = specification.and(buildSpecification(criteria.getMemberId(), - root -> root.join(Share_.member, JoinType.LEFT).get(Membership_.id))); + 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/dto/AssetCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java index c9898fb9..8eaff96c 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java @@ -40,7 +40,7 @@ public class AssetCriteria implements Serializable { private StringFilter comment; - private LongFilter memberId; + private LongFilter membershipId; public LongFilter getId() { return id; @@ -82,12 +82,12 @@ public class AssetCriteria implements Serializable { this.comment = comment; } - public LongFilter getMemberId() { - return memberId; + public LongFilter getMembershipId() { + return membershipId; } - public void setMemberId(LongFilter memberId) { - this.memberId = memberId; + public void setMembershipId(LongFilter membershipId) { + this.membershipId = membershipId; } @@ -106,7 +106,7 @@ public class AssetCriteria implements Serializable { Objects.equals(action, that.action) && Objects.equals(amount, that.amount) && Objects.equals(comment, that.comment) && - Objects.equals(memberId, that.memberId); + Objects.equals(membershipId, that.membershipId); } @Override @@ -117,7 +117,7 @@ public class AssetCriteria implements Serializable { action, amount, comment, - memberId + membershipId ); } @@ -129,7 +129,7 @@ public class AssetCriteria implements Serializable { (action != null ? "action=" + action + ", " : "") + (amount != null ? "amount=" + amount + ", " : "") + (comment != null ? "comment=" + comment + ", " : "") + - (memberId != null ? "memberId=" + memberId + ", " : "") + + (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 index 9897321a..d1a1965c 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java @@ -26,7 +26,9 @@ public class AssetDTO implements Serializable { private String comment; - private Long memberId; + private Long membershipId; + + private String membershipFrom; public Long getId() { return id; @@ -68,12 +70,20 @@ public class AssetDTO implements Serializable { this.comment = comment; } - public Long getMemberId() { - return memberId; + public Long getMembershipId() { + return membershipId; } - public void setMemberId(Long membershipId) { - this.memberId = membershipId; + public void setMembershipId(Long membershipId) { + this.membershipId = membershipId; + } + + public String getMembershipFrom() { + return membershipFrom; + } + + public void setMembershipFrom(String membershipFrom) { + this.membershipFrom = membershipFrom; } @Override @@ -105,7 +115,8 @@ public class AssetDTO implements Serializable { ", action='" + getAction() + "'" + ", amount=" + getAmount() + ", comment='" + getComment() + "'" + - ", member=" + getMemberId() + + ", membership=" + getMembershipId() + + ", membership='" + getMembershipFrom() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/ContactCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ContactCriteria.java deleted file mode 100644 index 1fe3cbee..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ContactCriteria.java +++ /dev/null @@ -1,115 +0,0 @@ -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; - -/** - * Criteria class for the Contact entity. This class is used in ContactResource to - * receive all the possible filtering options from the Http GET request parameters. - * For example the following could be a valid requests: - * /contacts?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 ContactCriteria implements Serializable { - - private static final long serialVersionUID = 1L; - - private LongFilter id; - - private StringFilter firstName; - - private StringFilter lastName; - - private StringFilter email; - - private LongFilter roleId; - - public LongFilter getId() { - return id; - } - - public void setId(LongFilter id) { - this.id = id; - } - - public StringFilter getFirstName() { - return firstName; - } - - public void setFirstName(StringFilter firstName) { - this.firstName = firstName; - } - - public StringFilter getLastName() { - return lastName; - } - - public void setLastName(StringFilter lastName) { - this.lastName = lastName; - } - - public StringFilter getEmail() { - return email; - } - - public void setEmail(StringFilter email) { - this.email = email; - } - - public LongFilter getRoleId() { - return roleId; - } - - public void setRoleId(LongFilter roleId) { - this.roleId = roleId; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ContactCriteria that = (ContactCriteria) o; - return - Objects.equals(id, that.id) && - Objects.equals(firstName, that.firstName) && - Objects.equals(lastName, that.lastName) && - Objects.equals(email, that.email) && - Objects.equals(roleId, that.roleId); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - firstName, - lastName, - email, - roleId - ); - } - - @Override - public String toString() { - return "ContactCriteria{" + - (id != null ? "id=" + id + ", " : "") + - (firstName != null ? "firstName=" + firstName + ", " : "") + - (lastName != null ? "lastName=" + lastName + ", " : "") + - (email != null ? "email=" + email + ", " : "") + - (roleId != null ? "roleId=" + roleId + ", " : "") + - "}"; - } - -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/ContactDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ContactDTO.java deleted file mode 100644 index c5a7ba0d..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ContactDTO.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.hostsharing.hsadminng.service.dto; -import javax.validation.constraints.*; -import java.io.Serializable; -import java.util.Objects; - -/** - * A DTO for the Contact entity. - */ -public class ContactDTO implements Serializable { - - private Long id; - - @NotNull - @Size(max = 80) - private String firstName; - - @NotNull - @Size(max = 80) - private String lastName; - - @NotNull - @Size(max = 80) - private String email; - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - ContactDTO contactDTO = (ContactDTO) o; - if (contactDTO.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), contactDTO.getId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getId()); - } - - @Override - public String toString() { - return "ContactDTO{" + - "id=" + getId() + - ", firstName='" + getFirstName() + "'" + - ", lastName='" + getLastName() + "'" + - ", email='" + getEmail() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactCriteria.java deleted file mode 100644 index d4173724..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactCriteria.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.hostsharing.hsadminng.service.dto; - -import java.io.Serializable; -import java.util.Objects; -import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole; -import io.github.jhipster.service.filter.BooleanFilter; -import io.github.jhipster.service.filter.DoubleFilter; -import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.FloatFilter; -import io.github.jhipster.service.filter.IntegerFilter; -import io.github.jhipster.service.filter.LongFilter; -import io.github.jhipster.service.filter.StringFilter; - -/** - * Criteria class for the CustomerContact entity. This class is used in CustomerContactResource to - * receive all the possible filtering options from the Http GET request parameters. - * For example the following could be a valid requests: - * /customer-contacts?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 CustomerContactCriteria implements Serializable { - /** - * Class for filtering CustomerContactRole - */ - public static class CustomerContactRoleFilter extends Filter { - } - - private static final long serialVersionUID = 1L; - - private LongFilter id; - - private CustomerContactRoleFilter role; - - private LongFilter contactId; - - private LongFilter customerId; - - public LongFilter getId() { - return id; - } - - public void setId(LongFilter id) { - this.id = id; - } - - public CustomerContactRoleFilter getRole() { - return role; - } - - public void setRole(CustomerContactRoleFilter role) { - this.role = role; - } - - public LongFilter getContactId() { - return contactId; - } - - public void setContactId(LongFilter contactId) { - this.contactId = contactId; - } - - 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 CustomerContactCriteria that = (CustomerContactCriteria) o; - return - Objects.equals(id, that.id) && - Objects.equals(role, that.role) && - Objects.equals(contactId, that.contactId) && - Objects.equals(customerId, that.customerId); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - role, - contactId, - customerId - ); - } - - @Override - public String toString() { - return "CustomerContactCriteria{" + - (id != null ? "id=" + id + ", " : "") + - (role != null ? "role=" + role + ", " : "") + - (contactId != null ? "contactId=" + contactId + ", " : "") + - (customerId != null ? "customerId=" + customerId + ", " : "") + - "}"; - } - -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactDTO.java deleted file mode 100644 index 97fa8f8b..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactDTO.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.hostsharing.hsadminng.service.dto; -import javax.validation.constraints.*; -import java.io.Serializable; -import java.util.Objects; -import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole; - -/** - * A DTO for the CustomerContact entity. - */ -public class CustomerContactDTO implements Serializable { - - private Long id; - - @NotNull - private CustomerContactRole role; - - - private Long contactId; - - private String contactEmail; - - private Long customerId; - - private String customerPrefix; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public CustomerContactRole getRole() { - return role; - } - - public void setRole(CustomerContactRole role) { - this.role = role; - } - - public Long getContactId() { - return contactId; - } - - public void setContactId(Long contactId) { - this.contactId = contactId; - } - - public String getContactEmail() { - return contactEmail; - } - - public void setContactEmail(String contactEmail) { - this.contactEmail = contactEmail; - } - - 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; - } - - CustomerContactDTO customerContactDTO = (CustomerContactDTO) o; - if (customerContactDTO.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), customerContactDTO.getId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getId()); - } - - @Override - public String toString() { - return "CustomerContactDTO{" + - "id=" + getId() + - ", role='" + getRole() + "'" + - ", contact=" + getContactId() + - ", contact='" + getContactEmail() + "'" + - ", customer=" + getCustomerId() + - ", customer='" + getCustomerPrefix() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java index c46dd0d3..9492fb09 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java @@ -1,12 +1,14 @@ package org.hostsharing.hsadminng.service.dto; -import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.IntegerFilter; -import io.github.jhipster.service.filter.LongFilter; -import io.github.jhipster.service.filter.StringFilter; - import java.io.Serializable; import java.util.Objects; +import io.github.jhipster.service.filter.BooleanFilter; +import io.github.jhipster.service.filter.DoubleFilter; +import io.github.jhipster.service.filter.Filter; +import io.github.jhipster.service.filter.FloatFilter; +import io.github.jhipster.service.filter.IntegerFilter; +import io.github.jhipster.service.filter.LongFilter; +import io.github.jhipster.service.filter.StringFilter; /** * Criteria class for the Customer entity. This class is used in CustomerResource to @@ -28,18 +30,18 @@ public class CustomerCriteria implements Serializable { private StringFilter name; - private StringFilter contractualAddress; - private StringFilter contractualSalutation; - private StringFilter billingAddress; + private StringFilter contractualAddress; private StringFilter billingSalutation; - private LongFilter roleId; + private StringFilter billingAddress; private LongFilter membershipId; + private LongFilter sepamandateId; + public LongFilter getId() { return id; } @@ -72,14 +74,6 @@ public class CustomerCriteria implements Serializable { this.name = name; } - public StringFilter getContractualAddress() { - return contractualAddress; - } - - public void setContractualAddress(StringFilter contractualAddress) { - this.contractualAddress = contractualAddress; - } - public StringFilter getContractualSalutation() { return contractualSalutation; } @@ -88,12 +82,12 @@ public class CustomerCriteria implements Serializable { this.contractualSalutation = contractualSalutation; } - public StringFilter getBillingAddress() { - return billingAddress; + public StringFilter getContractualAddress() { + return contractualAddress; } - public void setBillingAddress(StringFilter billingAddress) { - this.billingAddress = billingAddress; + public void setContractualAddress(StringFilter contractualAddress) { + this.contractualAddress = contractualAddress; } public StringFilter getBillingSalutation() { @@ -104,12 +98,12 @@ public class CustomerCriteria implements Serializable { this.billingSalutation = billingSalutation; } - public LongFilter getRoleId() { - return roleId; + public StringFilter getBillingAddress() { + return billingAddress; } - public void setRoleId(LongFilter roleId) { - this.roleId = roleId; + public void setBillingAddress(StringFilter billingAddress) { + this.billingAddress = billingAddress; } public LongFilter getMembershipId() { @@ -120,6 +114,14 @@ public class CustomerCriteria implements Serializable { this.membershipId = membershipId; } + public LongFilter getSepamandateId() { + return sepamandateId; + } + + public void setSepamandateId(LongFilter sepamandateId) { + this.sepamandateId = sepamandateId; + } + @Override public boolean equals(Object o) { @@ -134,13 +136,13 @@ public class CustomerCriteria implements Serializable { Objects.equals(id, that.id) && Objects.equals(number, that.number) && Objects.equals(prefix, that.prefix) && - Objects.equals(name, that.name) && - Objects.equals(contractualAddress, that.contractualAddress) && - Objects.equals(contractualSalutation, that.contractualSalutation) && - Objects.equals(billingAddress, that.billingAddress) && - Objects.equals(billingSalutation, that.billingSalutation) && - Objects.equals(roleId, that.roleId) && - Objects.equals(membershipId, that.membershipId); + Objects.equals(name, that.name) && + Objects.equals(contractualSalutation, that.contractualSalutation) && + Objects.equals(contractualAddress, that.contractualAddress) && + Objects.equals(billingSalutation, that.billingSalutation) && + Objects.equals(billingAddress, that.billingAddress) && + Objects.equals(membershipId, that.membershipId) && + Objects.equals(sepamandateId, that.sepamandateId); } @Override @@ -149,13 +151,13 @@ public class CustomerCriteria implements Serializable { id, number, prefix, - name, - contractualAddress, - contractualSalutation, - billingAddress, - billingSalutation, - roleId, - membershipId + name, + contractualSalutation, + contractualAddress, + billingSalutation, + billingAddress, + membershipId, + sepamandateId ); } @@ -165,13 +167,13 @@ public class CustomerCriteria implements Serializable { (id != null ? "id=" + id + ", " : "") + (number != null ? "number=" + number + ", " : "") + (prefix != null ? "prefix=" + prefix + ", " : "") + - (name != null ? "name=" + name + ", " : "") + - (contractualAddress != null ? "contractualAddress=" + contractualAddress + ", " : "") + - (contractualSalutation != null ? "contractualSalutation=" + contractualSalutation + ", " : "") + - (billingAddress != null ? "billingAddress=" + billingAddress + ", " : "") + - (billingSalutation != null ? "billingSalutation=" + billingSalutation + ", " : "") + - (roleId != null ? "roleId=" + roleId + ", " : "") + - (membershipId != null ? "membershipId=" + membershipId + ", " : "") + + (name != null ? "name=" + name + ", " : "") + + (contractualSalutation != null ? "contractualSalutation=" + contractualSalutation + ", " : "") + + (contractualAddress != null ? "contractualAddress=" + contractualAddress + ", " : "") + + (billingSalutation != null ? "billingSalutation=" + billingSalutation + ", " : "") + + (billingAddress != null ? "billingAddress=" + billingAddress + ", " : "") + + (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 index ff8bf3d8..083c52ff 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java @@ -23,19 +23,19 @@ public class CustomerDTO implements Serializable { @Size(max = 80) private String name; + @Size(max = 80) + private String contractualSalutation; + @NotNull @Size(max = 400) private String contractualAddress; @Size(max = 80) - private String contractualSalutation; + private String billingSalutation; @Size(max = 400) private String billingAddress; - @Size(max = 80) - private String billingSalutation; - public Long getId() { return id; @@ -69,14 +69,6 @@ public class CustomerDTO implements Serializable { this.name = name; } - public String getContractualAddress() { - return contractualAddress; - } - - public void setContractualAddress(String contractualAddress) { - this.contractualAddress = contractualAddress; - } - public String getContractualSalutation() { return contractualSalutation; } @@ -85,12 +77,12 @@ public class CustomerDTO implements Serializable { this.contractualSalutation = contractualSalutation; } - public String getBillingAddress() { - return billingAddress; + public String getContractualAddress() { + return contractualAddress; } - public void setBillingAddress(String billingAddress) { - this.billingAddress = billingAddress; + public void setContractualAddress(String contractualAddress) { + this.contractualAddress = contractualAddress; } public String getBillingSalutation() { @@ -101,6 +93,14 @@ public class CustomerDTO implements Serializable { this.billingSalutation = billingSalutation; } + public String getBillingAddress() { + return billingAddress; + } + + public void setBillingAddress(String billingAddress) { + this.billingAddress = billingAddress; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -129,10 +129,10 @@ public class CustomerDTO implements Serializable { ", number=" + getNumber() + ", prefix='" + getPrefix() + "'" + ", name='" + getName() + "'" + - ", contractualAddress='" + getContractualAddress() + "'" + ", contractualSalutation='" + getContractualSalutation() + "'" + - ", billingAddress='" + getBillingAddress() + "'" + + ", contractualAddress='" + getContractualAddress() + "'" + ", billingSalutation='" + getBillingSalutation() + "'" + + ", billingAddress='" + getBillingAddress() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java index 6e8e7b45..f9b3f4dd 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java @@ -25,9 +25,11 @@ public class MembershipCriteria implements Serializable { private LongFilter id; - private LocalDateFilter sinceDate; + private LocalDateFilter from; - private LocalDateFilter untilDate; + private LocalDateFilter to; + + private StringFilter comment; private LongFilter shareId; @@ -43,20 +45,28 @@ public class MembershipCriteria implements Serializable { this.id = id; } - public LocalDateFilter getSinceDate() { - return sinceDate; + public LocalDateFilter getFrom() { + return from; } - public void setSinceDate(LocalDateFilter sinceDate) { - this.sinceDate = sinceDate; + public void setFrom(LocalDateFilter from) { + this.from = from; } - public LocalDateFilter getUntilDate() { - return untilDate; + public LocalDateFilter getTo() { + return to; } - public void setUntilDate(LocalDateFilter untilDate) { - this.untilDate = untilDate; + public void setTo(LocalDateFilter to) { + this.to = to; + } + + public StringFilter getComment() { + return comment; + } + + public void setComment(StringFilter comment) { + this.comment = comment; } public LongFilter getShareId() { @@ -95,8 +105,9 @@ public class MembershipCriteria implements Serializable { final MembershipCriteria that = (MembershipCriteria) o; return Objects.equals(id, that.id) && - Objects.equals(sinceDate, that.sinceDate) && - Objects.equals(untilDate, that.untilDate) && + Objects.equals(from, that.from) && + Objects.equals(to, that.to) && + Objects.equals(comment, that.comment) && Objects.equals(shareId, that.shareId) && Objects.equals(assetId, that.assetId) && Objects.equals(customerId, that.customerId); @@ -106,8 +117,9 @@ public class MembershipCriteria implements Serializable { public int hashCode() { return Objects.hash( id, - sinceDate, - untilDate, + from, + to, + comment, shareId, assetId, customerId @@ -118,8 +130,9 @@ public class MembershipCriteria implements Serializable { public String toString() { return "MembershipCriteria{" + (id != null ? "id=" + id + ", " : "") + - (sinceDate != null ? "sinceDate=" + sinceDate + ", " : "") + - (untilDate != null ? "untilDate=" + untilDate + ", " : "") + + (from != null ? "from=" + from + ", " : "") + + (to != null ? "to=" + to + ", " : "") + + (comment != null ? "comment=" + comment + ", " : "") + (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 index 12232fed..7f0872a6 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java @@ -12,9 +12,12 @@ public class MembershipDTO implements Serializable { private Long id; @NotNull - private LocalDate sinceDate; + private LocalDate from; - private LocalDate untilDate; + private LocalDate to; + + @Size(max = 160) + private String comment; private Long customerId; @@ -29,20 +32,28 @@ public class MembershipDTO implements Serializable { this.id = id; } - public LocalDate getSinceDate() { - return sinceDate; + public LocalDate getFrom() { + return from; } - public void setSinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; + public void setFrom(LocalDate from) { + this.from = from; } - public LocalDate getUntilDate() { - return untilDate; + public LocalDate getTo() { + return to; } - public void setUntilDate(LocalDate untilDate) { - this.untilDate = untilDate; + public void setTo(LocalDate to) { + this.to = to; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; } public Long getCustomerId() { @@ -86,8 +97,9 @@ public class MembershipDTO implements Serializable { public String toString() { return "MembershipDTO{" + "id=" + getId() + - ", sinceDate='" + getSinceDate() + "'" + - ", untilDate='" + getUntilDate() + "'" + + ", from='" + getFrom() + "'" + + ", to='" + getTo() + "'" + + ", comment='" + getComment() + "'" + ", 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..8f285fe6 --- /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 created; + + private LocalDateFilter validFrom; + + private LocalDateFilter validTo; + + private LocalDateFilter lastUsed; + + private LocalDateFilter cancelled; + + private StringFilter comment; + + 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 getCreated() { + return created; + } + + public void setCreated(LocalDateFilter created) { + this.created = created; + } + + public LocalDateFilter getValidFrom() { + return validFrom; + } + + public void setValidFrom(LocalDateFilter validFrom) { + this.validFrom = validFrom; + } + + public LocalDateFilter getValidTo() { + return validTo; + } + + public void setValidTo(LocalDateFilter validTo) { + this.validTo = validTo; + } + + public LocalDateFilter getLastUsed() { + return lastUsed; + } + + public void setLastUsed(LocalDateFilter lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDateFilter getCancelled() { + return cancelled; + } + + public void setCancelled(LocalDateFilter cancelled) { + this.cancelled = cancelled; + } + + public StringFilter getComment() { + return comment; + } + + public void setComment(StringFilter comment) { + this.comment = comment; + } + + 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(created, that.created) && + Objects.equals(validFrom, that.validFrom) && + Objects.equals(validTo, that.validTo) && + Objects.equals(lastUsed, that.lastUsed) && + Objects.equals(cancelled, that.cancelled) && + Objects.equals(comment, that.comment) && + Objects.equals(customerId, that.customerId); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + reference, + iban, + bic, + created, + validFrom, + validTo, + lastUsed, + cancelled, + comment, + customerId + ); + } + + @Override + public String toString() { + return "SepaMandateCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (reference != null ? "reference=" + reference + ", " : "") + + (iban != null ? "iban=" + iban + ", " : "") + + (bic != null ? "bic=" + bic + ", " : "") + + (created != null ? "created=" + created + ", " : "") + + (validFrom != null ? "validFrom=" + validFrom + ", " : "") + + (validTo != null ? "validTo=" + validTo + ", " : "") + + (lastUsed != null ? "lastUsed=" + lastUsed + ", " : "") + + (cancelled != null ? "cancelled=" + cancelled + ", " : "") + + (comment != null ? "comment=" + comment + ", " : "") + + (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..47864e47 --- /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 created; + + @NotNull + private LocalDate validFrom; + + private LocalDate validTo; + + private LocalDate lastUsed; + + private LocalDate cancelled; + + @Size(max = 160) + private String comment; + + + 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 getCreated() { + return created; + } + + public void setCreated(LocalDate created) { + this.created = created; + } + + public LocalDate getValidFrom() { + return validFrom; + } + + public void setValidFrom(LocalDate validFrom) { + this.validFrom = validFrom; + } + + public LocalDate getValidTo() { + return validTo; + } + + public void setValidTo(LocalDate validTo) { + this.validTo = validTo; + } + + public LocalDate getLastUsed() { + return lastUsed; + } + + public void setLastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDate getCancelled() { + return cancelled; + } + + public void setCancelled(LocalDate cancelled) { + this.cancelled = cancelled; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + 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() + "'" + + ", created='" + getCreated() + "'" + + ", validFrom='" + getValidFrom() + "'" + + ", validTo='" + getValidTo() + "'" + + ", lastUsed='" + getLastUsed() + "'" + + ", cancelled='" + getCancelled() + "'" + + ", comment='" + getComment() + "'" + + ", 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 index 1db1aff5..cf91b036 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java @@ -39,7 +39,7 @@ public class ShareCriteria implements Serializable { private StringFilter comment; - private LongFilter memberId; + private LongFilter membershipId; public LongFilter getId() { return id; @@ -81,12 +81,12 @@ public class ShareCriteria implements Serializable { this.comment = comment; } - public LongFilter getMemberId() { - return memberId; + public LongFilter getMembershipId() { + return membershipId; } - public void setMemberId(LongFilter memberId) { - this.memberId = memberId; + public void setMembershipId(LongFilter membershipId) { + this.membershipId = membershipId; } @@ -105,7 +105,7 @@ public class ShareCriteria implements Serializable { Objects.equals(action, that.action) && Objects.equals(quantity, that.quantity) && Objects.equals(comment, that.comment) && - Objects.equals(memberId, that.memberId); + Objects.equals(membershipId, that.membershipId); } @Override @@ -116,7 +116,7 @@ public class ShareCriteria implements Serializable { action, quantity, comment, - memberId + membershipId ); } @@ -128,7 +128,7 @@ public class ShareCriteria implements Serializable { (action != null ? "action=" + action + ", " : "") + (quantity != null ? "quantity=" + quantity + ", " : "") + (comment != null ? "comment=" + comment + ", " : "") + - (memberId != null ? "memberId=" + memberId + ", " : "") + + (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 index 1ae37049..b172da4b 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java @@ -25,7 +25,9 @@ public class ShareDTO implements Serializable { private String comment; - private Long memberId; + private Long membershipId; + + private String membershipFrom; public Long getId() { return id; @@ -67,12 +69,20 @@ public class ShareDTO implements Serializable { this.comment = comment; } - public Long getMemberId() { - return memberId; + public Long getMembershipId() { + return membershipId; } - public void setMemberId(Long membershipId) { - this.memberId = membershipId; + public void setMembershipId(Long membershipId) { + this.membershipId = membershipId; + } + + public String getMembershipFrom() { + return membershipFrom; + } + + public void setMembershipFrom(String membershipFrom) { + this.membershipFrom = membershipFrom; } @Override @@ -104,7 +114,8 @@ public class ShareDTO implements Serializable { ", action='" + getAction() + "'" + ", quantity=" + getQuantity() + ", comment='" + getComment() + "'" + - ", member=" + getMemberId() + + ", membership=" + getMembershipId() + + ", membership='" + getMembershipFrom() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java index 5d39692e..f5d2b500 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java @@ -11,10 +11,11 @@ import org.mapstruct.*; @Mapper(componentModel = "spring", uses = {MembershipMapper.class}) public interface AssetMapper extends EntityMapper { - @Mapping(source = "member.id", target = "memberId") + @Mapping(source = "membership.id", target = "membershipId") + @Mapping(source = "membership.from", target = "membershipFrom") AssetDTO toDto(Asset asset); - @Mapping(source = "memberId", target = "member") + @Mapping(source = "membershipId", target = "membership") Asset toEntity(AssetDTO assetDTO); default Asset fromId(Long id) { diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/ContactMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/ContactMapper.java deleted file mode 100644 index 26974051..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/ContactMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hostsharing.hsadminng.service.mapper; - -import org.hostsharing.hsadminng.domain.*; -import org.hostsharing.hsadminng.service.dto.ContactDTO; - -import org.mapstruct.*; - -/** - * Mapper for the entity Contact and its DTO ContactDTO. - */ -@Mapper(componentModel = "spring", uses = {}) -public interface ContactMapper extends EntityMapper { - - - @Mapping(target = "roles", ignore = true) - Contact toEntity(ContactDTO contactDTO); - - default Contact fromId(Long id) { - if (id == null) { - return null; - } - Contact contact = new Contact(); - contact.setId(id); - return contact; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerContactMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerContactMapper.java deleted file mode 100644 index 3e4671e2..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerContactMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hostsharing.hsadminng.service.mapper; - -import org.hostsharing.hsadminng.domain.*; -import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; - -import org.mapstruct.*; - -/** - * Mapper for the entity CustomerContact and its DTO CustomerContactDTO. - */ -@Mapper(componentModel = "spring", uses = {ContactMapper.class, CustomerMapper.class}) -public interface CustomerContactMapper extends EntityMapper { - - @Mapping(source = "contact.id", target = "contactId") - @Mapping(source = "contact.email", target = "contactEmail") - @Mapping(source = "customer.id", target = "customerId") - @Mapping(source = "customer.prefix", target = "customerPrefix") - CustomerContactDTO toDto(CustomerContact customerContact); - - @Mapping(source = "contactId", target = "contact") - @Mapping(source = "customerId", target = "customer") - CustomerContact toEntity(CustomerContactDTO customerContactDTO); - - default CustomerContact fromId(Long id) { - if (id == null) { - return null; - } - CustomerContact customerContact = new CustomerContact(); - customerContact.setId(id); - return customerContact; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java index 4bb2f1e9..6c9c204a 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java @@ -1,9 +1,9 @@ package org.hostsharing.hsadminng.service.mapper; -import org.hostsharing.hsadminng.domain.Customer; +import org.hostsharing.hsadminng.domain.*; import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; + +import org.mapstruct.*; /** * Mapper for the entity Customer and its DTO CustomerDTO. @@ -12,8 +12,8 @@ import org.mapstruct.Mapping; public interface CustomerMapper extends EntityMapper { - @Mapping(target = "roles", ignore = true) @Mapping(target = "memberships", ignore = true) + @Mapping(target = "sepamandates", ignore = true) Customer toEntity(CustomerDTO customerDTO); default Customer fromId(Long id) { 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 index c5ed7f33..5c6fa970 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java @@ -11,10 +11,11 @@ import org.mapstruct.*; @Mapper(componentModel = "spring", uses = {MembershipMapper.class}) public interface ShareMapper extends EntityMapper { - @Mapping(source = "member.id", target = "memberId") + @Mapping(source = "membership.id", target = "membershipId") + @Mapping(source = "membership.from", target = "membershipFrom") ShareDTO toDto(Share share); - @Mapping(source = "memberId", target = "member") + @Mapping(source = "membershipId", target = "membership") Share toEntity(ShareDTO shareDTO); default Share fromId(Long id) { diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/ContactResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/ContactResource.java deleted file mode 100644 index df5670f7..00000000 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/ContactResource.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; -import org.hostsharing.hsadminng.service.ContactService; -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.ContactDTO; -import org.hostsharing.hsadminng.service.dto.ContactCriteria; -import org.hostsharing.hsadminng.service.ContactQueryService; -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 Contact. - */ -@RestController -@RequestMapping("/api") -public class ContactResource { - - private final Logger log = LoggerFactory.getLogger(ContactResource.class); - - private static final String ENTITY_NAME = "contact"; - - private final ContactService contactService; - - private final ContactQueryService contactQueryService; - - public ContactResource(ContactService contactService, ContactQueryService contactQueryService) { - this.contactService = contactService; - this.contactQueryService = contactQueryService; - } - - /** - * POST /contacts : Create a new contact. - * - * @param contactDTO the contactDTO to create - * @return the ResponseEntity with status 201 (Created) and with body the new contactDTO, or with status 400 (Bad Request) if the contact has already an ID - * @throws URISyntaxException if the Location URI syntax is incorrect - */ - @PostMapping("/contacts") - public ResponseEntity createContact(@Valid @RequestBody ContactDTO contactDTO) throws URISyntaxException { - log.debug("REST request to save Contact : {}", contactDTO); - if (contactDTO.getId() != null) { - throw new BadRequestAlertException("A new contact cannot already have an ID", ENTITY_NAME, "idexists"); - } - ContactDTO result = contactService.save(contactDTO); - return ResponseEntity.created(new URI("/api/contacts/" + result.getId())) - .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) - .body(result); - } - - /** - * PUT /contacts : Updates an existing contact. - * - * @param contactDTO the contactDTO to update - * @return the ResponseEntity with status 200 (OK) and with body the updated contactDTO, - * or with status 400 (Bad Request) if the contactDTO is not valid, - * or with status 500 (Internal Server Error) if the contactDTO couldn't be updated - * @throws URISyntaxException if the Location URI syntax is incorrect - */ - @PutMapping("/contacts") - public ResponseEntity updateContact(@Valid @RequestBody ContactDTO contactDTO) throws URISyntaxException { - log.debug("REST request to update Contact : {}", contactDTO); - if (contactDTO.getId() == null) { - throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); - } - ContactDTO result = contactService.save(contactDTO); - return ResponseEntity.ok() - .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, contactDTO.getId().toString())) - .body(result); - } - - /** - * GET /contacts : get all the contacts. - * - * @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 contacts in body - */ - @GetMapping("/contacts") - public ResponseEntity> getAllContacts(ContactCriteria criteria, Pageable pageable) { - log.debug("REST request to get Contacts by criteria: {}", criteria); - Page page = contactQueryService.findByCriteria(criteria, pageable); - HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/contacts"); - return ResponseEntity.ok().headers(headers).body(page.getContent()); - } - - /** - * GET /contacts/count : count all the contacts. - * - * @param criteria the criterias which the requested entities should match - * @return the ResponseEntity with status 200 (OK) and the count in body - */ - @GetMapping("/contacts/count") - public ResponseEntity countContacts(ContactCriteria criteria) { - log.debug("REST request to count Contacts by criteria: {}", criteria); - return ResponseEntity.ok().body(contactQueryService.countByCriteria(criteria)); - } - - /** - * GET /contacts/:id : get the "id" contact. - * - * @param id the id of the contactDTO to retrieve - * @return the ResponseEntity with status 200 (OK) and with body the contactDTO, or with status 404 (Not Found) - */ - @GetMapping("/contacts/{id}") - public ResponseEntity getContact(@PathVariable Long id) { - log.debug("REST request to get Contact : {}", id); - Optional contactDTO = contactService.findOne(id); - return ResponseUtil.wrapOrNotFound(contactDTO); - } - - /** - * DELETE /contacts/:id : delete the "id" contact. - * - * @param id the id of the contactDTO to delete - * @return the ResponseEntity with status 200 (OK) - */ - @DeleteMapping("/contacts/{id}") - public ResponseEntity deleteContact(@PathVariable Long id) { - log.debug("REST request to delete Contact : {}", id); - contactService.delete(id); - return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerContactResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerContactResource.java deleted file mode 100644 index 5308c4a3..00000000 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerContactResource.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; -import org.hostsharing.hsadminng.service.CustomerContactService; -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.CustomerContactDTO; -import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria; -import org.hostsharing.hsadminng.service.CustomerContactQueryService; -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 CustomerContact. - */ -@RestController -@RequestMapping("/api") -public class CustomerContactResource { - - private final Logger log = LoggerFactory.getLogger(CustomerContactResource.class); - - private static final String ENTITY_NAME = "customerContact"; - - private final CustomerContactService customerContactService; - - private final CustomerContactQueryService customerContactQueryService; - - public CustomerContactResource(CustomerContactService customerContactService, CustomerContactQueryService customerContactQueryService) { - this.customerContactService = customerContactService; - this.customerContactQueryService = customerContactQueryService; - } - - /** - * POST /customer-contacts : Create a new customerContact. - * - * @param customerContactDTO the customerContactDTO to create - * @return the ResponseEntity with status 201 (Created) and with body the new customerContactDTO, or with status 400 (Bad Request) if the customerContact has already an ID - * @throws URISyntaxException if the Location URI syntax is incorrect - */ - @PostMapping("/customer-contacts") - public ResponseEntity createCustomerContact(@Valid @RequestBody CustomerContactDTO customerContactDTO) throws URISyntaxException { - log.debug("REST request to save CustomerContact : {}", customerContactDTO); - if (customerContactDTO.getId() != null) { - throw new BadRequestAlertException("A new customerContact cannot already have an ID", ENTITY_NAME, "idexists"); - } - CustomerContactDTO result = customerContactService.save(customerContactDTO); - return ResponseEntity.created(new URI("/api/customer-contacts/" + result.getId())) - .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) - .body(result); - } - - /** - * PUT /customer-contacts : Updates an existing customerContact. - * - * @param customerContactDTO the customerContactDTO to update - * @return the ResponseEntity with status 200 (OK) and with body the updated customerContactDTO, - * or with status 400 (Bad Request) if the customerContactDTO is not valid, - * or with status 500 (Internal Server Error) if the customerContactDTO couldn't be updated - * @throws URISyntaxException if the Location URI syntax is incorrect - */ - @PutMapping("/customer-contacts") - public ResponseEntity updateCustomerContact(@Valid @RequestBody CustomerContactDTO customerContactDTO) throws URISyntaxException { - log.debug("REST request to update CustomerContact : {}", customerContactDTO); - if (customerContactDTO.getId() == null) { - throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); - } - CustomerContactDTO result = customerContactService.save(customerContactDTO); - return ResponseEntity.ok() - .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, customerContactDTO.getId().toString())) - .body(result); - } - - /** - * GET /customer-contacts : get all the customerContacts. - * - * @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 customerContacts in body - */ - @GetMapping("/customer-contacts") - public ResponseEntity> getAllCustomerContacts(CustomerContactCriteria criteria, Pageable pageable) { - log.debug("REST request to get CustomerContacts by criteria: {}", criteria); - Page page = customerContactQueryService.findByCriteria(criteria, pageable); - HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/customer-contacts"); - return ResponseEntity.ok().headers(headers).body(page.getContent()); - } - - /** - * GET /customer-contacts/count : count all the customerContacts. - * - * @param criteria the criterias which the requested entities should match - * @return the ResponseEntity with status 200 (OK) and the count in body - */ - @GetMapping("/customer-contacts/count") - public ResponseEntity countCustomerContacts(CustomerContactCriteria criteria) { - log.debug("REST request to count CustomerContacts by criteria: {}", criteria); - return ResponseEntity.ok().body(customerContactQueryService.countByCriteria(criteria)); - } - - /** - * GET /customer-contacts/:id : get the "id" customerContact. - * - * @param id the id of the customerContactDTO to retrieve - * @return the ResponseEntity with status 200 (OK) and with body the customerContactDTO, or with status 404 (Not Found) - */ - @GetMapping("/customer-contacts/{id}") - public ResponseEntity getCustomerContact(@PathVariable Long id) { - log.debug("REST request to get CustomerContact : {}", id); - Optional customerContactDTO = customerContactService.findOne(id); - return ResponseUtil.wrapOrNotFound(customerContactDTO); - } - - /** - * DELETE /customer-contacts/:id : delete the "id" customerContact. - * - * @param id the id of the customerContactDTO to delete - * @return the ResponseEntity with status 200 (OK) - */ - @DeleteMapping("/customer-contacts/{id}") - public ResponseEntity deleteCustomerContact(@PathVariable Long id) { - log.debug("REST request to delete CustomerContact : {}", id); - customerContactService.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/jdl/customer.jdl b/src/main/jdl/customer.jdl index 14b17d8f..86189c72 100644 --- a/src/main/jdl/customer.jdl +++ b/src/main/jdl/customer.jdl @@ -1,37 +1,22 @@ filter all dto all with mapstruct service all with serviceClass -paginate all with infinite-scroll +paginate all with infinite-scroll entity Customer { number Integer required unique min(10000) max(99999), prefix String required unique pattern(/[a-z][a-z0-9]+/), name String required maxlength(80), - contractualAddress String required maxlength(400), contractualSalutation String maxlength(80), - billingAddress String maxlength(400), - billingSalutation String maxlength(80) -} - -entity Contact { - firstName String required maxlength(80), - lastName String required maxlength(80), - email String required maxlength(80) -} - -enum CustomerContactRole { - CONTRACTUAL, - TECHNICAL, - FINANCIAL -} - -entity CustomerContact { - role CustomerContactRole required + contractualAddress String required maxlength(400), + billingSalutation String maxlength(80), + billingAddress String maxlength(400) } entity Membership { - sinceDate LocalDate required, - untilDate LocalDate + from LocalDate required, + to LocalDate, + comment String maxlength(160) } enum ShareAction { @@ -62,11 +47,21 @@ entity Asset { comment String maxlength(160) } -relationship OneToMany { - Contact{role} to CustomerContact{contact(email) required}, - Customer{role} to CustomerContact{customer(prefix) required}, - Customer to Membership{customer(prefix) required}, - Membership to Share{member required}, - Membership to Asset{member required} +entity SepaMandate { + reference String maxlength(40) unique required, + iban String maxlength(34), + bic String maxlength(11), + created LocalDate required, + validFrom LocalDate required, + validTo LocalDate, + lastUsed LocalDate, + cancelled LocalDate, + comment String maxlength(160) } +relationship OneToMany { + Customer{membership} to Membership{customer(prefix) required}, + Customer{sepamandate} to SepaMandate{customer(prefix) required}, + Membership{share} to Share{membership(from) required}, + Membership{asset} to Asset{membership(from) required} +} diff --git a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml b/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml deleted file mode 100644 index bfad5a7e..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml b/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml deleted file mode 100644 index 95973eb5..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml b/src/main/resources/config/liquibase/changelog/20190418073043_added_entity_Customer.xml similarity index 79% rename from src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml rename to src/main/resources/config/liquibase/changelog/20190418073043_added_entity_Customer.xml index b888eebe..806455ff 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml +++ b/src/main/resources/config/liquibase/changelog/20190418073043_added_entity_Customer.xml @@ -1,8 +1,10 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> @@ -14,7 +16,7 @@ - + @@ -28,23 +30,23 @@ - - - - - + - + - - + + - + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml b/src/main/resources/config/liquibase/changelog/20190418073044_added_entity_Membership.xml similarity index 77% rename from src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml rename to src/main/resources/config/liquibase/changelog/20190418073044_added_entity_Membership.xml index f9e6013b..372fc7f4 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml +++ b/src/main/resources/config/liquibase/changelog/20190418073044_added_entity_Membership.xml @@ -14,19 +14,23 @@ - - + + - + - - + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_constraints_Membership.xml b/src/main/resources/config/liquibase/changelog/20190418073044_added_entity_constraints_Membership.xml similarity index 93% rename from src/main/resources/config/liquibase/changelog/20190403083738_added_entity_constraints_Membership.xml rename to src/main/resources/config/liquibase/changelog/20190418073044_added_entity_constraints_Membership.xml index 47849491..91904792 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_constraints_Membership.xml +++ b/src/main/resources/config/liquibase/changelog/20190418073044_added_entity_constraints_Membership.xml @@ -6,7 +6,7 @@ - + + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> @@ -14,7 +16,7 @@ - + @@ -35,8 +37,8 @@ - - + + diff --git a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml b/src/main/resources/config/liquibase/changelog/20190418073045_added_entity_constraints_Share.xml similarity index 83% rename from src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml rename to src/main/resources/config/liquibase/changelog/20190418073045_added_entity_constraints_Share.xml index a5b4cebd..fcd8cdb2 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml +++ b/src/main/resources/config/liquibase/changelog/20190418073045_added_entity_constraints_Share.xml @@ -6,11 +6,11 @@ - + - diff --git a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml b/src/main/resources/config/liquibase/changelog/20190418073046_added_entity_Asset.xml similarity index 81% rename from src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml rename to src/main/resources/config/liquibase/changelog/20190418073046_added_entity_Asset.xml index 682f4e2c..69d32fc5 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml +++ b/src/main/resources/config/liquibase/changelog/20190418073046_added_entity_Asset.xml @@ -1,8 +1,10 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> @@ -14,7 +16,7 @@ - + @@ -35,8 +37,8 @@ - - + + diff --git a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml b/src/main/resources/config/liquibase/changelog/20190418073046_added_entity_constraints_Asset.xml similarity index 83% rename from src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml rename to src/main/resources/config/liquibase/changelog/20190418073046_added_entity_constraints_Asset.xml index 329a22b8..246217d8 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml +++ b/src/main/resources/config/liquibase/changelog/20190418073046_added_entity_constraints_Asset.xml @@ -6,11 +6,11 @@ - + - diff --git a/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml b/src/main/resources/config/liquibase/changelog/20190418073047_added_entity_SepaMandate.xml similarity index 54% rename from src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml rename to src/main/resources/config/liquibase/changelog/20190418073047_added_entity_SepaMandate.xml index da4e0b9d..845deb64 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml +++ b/src/main/resources/config/liquibase/changelog/20190418073047_added_entity_SepaMandate.xml @@ -14,22 +14,50 @@ - - + + - + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418073047_added_entity_constraints_SepaMandate.xml b/src/main/resources/config/liquibase/changelog/20190418073047_added_entity_constraints_SepaMandate.xml new file mode 100644 index 00000000..5f66012d --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418073047_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 97a01937..eca02e30 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -5,16 +5,15 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> - - - - - - + + + + + - - - - + + + + diff --git a/src/main/webapp/app/entities/asset/asset-detail.component.html b/src/main/webapp/app/entities/asset/asset-detail.component.html index 29a4b452..989ab045 100644 --- a/src/main/webapp/app/entities/asset/asset-detail.component.html +++ b/src/main/webapp/app/entities/asset/asset-detail.component.html @@ -21,10 +21,10 @@
{{asset.comment}}
-
Member
+
Membership
-
diff --git a/src/main/webapp/app/entities/asset/asset-update.component.html b/src/main/webapp/app/entities/asset/asset-update.component.html index 0e1fa8d1..dc7a98db 100644 --- a/src/main/webapp/app/entities/asset/asset-update.component.html +++ b/src/main/webapp/app/entities/asset/asset-update.component.html @@ -70,16 +70,15 @@
- - + +
-
+
+ [hidden]="!editForm.controls.membership?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
diff --git a/src/main/webapp/app/entities/asset/asset.component.html b/src/main/webapp/app/entities/asset/asset.component.html index 0ac03e8f..f039d334 100644 --- a/src/main/webapp/app/entities/asset/asset.component.html +++ b/src/main/webapp/app/entities/asset/asset.component.html @@ -19,7 +19,7 @@ Action Amount Comment - Member + Membership @@ -31,8 +31,8 @@ {{asset.amount}} {{asset.comment}} -
- {{asset.memberId}} + diff --git a/src/main/webapp/app/entities/contact/contact-delete-dialog.component.ts b/src/main/webapp/app/entities/contact/contact-delete-dialog.component.ts deleted file mode 100644 index eef90f7f..00000000 --- a/src/main/webapp/app/entities/contact/contact-delete-dialog.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -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 { IContact } from 'app/shared/model/contact.model'; -import { ContactService } from './contact.service'; - -@Component({ - selector: 'jhi-contact-delete-dialog', - templateUrl: './contact-delete-dialog.component.html' -}) -export class ContactDeleteDialogComponent { - contact: IContact; - - constructor(protected contactService: ContactService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} - - clear() { - this.activeModal.dismiss('cancel'); - } - - confirmDelete(id: number) { - this.contactService.delete(id).subscribe(response => { - this.eventManager.broadcast({ - name: 'contactListModification', - content: 'Deleted an contact' - }); - this.activeModal.dismiss(true); - }); - } -} - -@Component({ - selector: 'jhi-contact-delete-popup', - template: '' -}) -export class ContactDeletePopupComponent implements OnInit, OnDestroy { - protected ngbModalRef: NgbModalRef; - - constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} - - ngOnInit() { - this.activatedRoute.data.subscribe(({ contact }) => { - setTimeout(() => { - this.ngbModalRef = this.modalService.open(ContactDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); - this.ngbModalRef.componentInstance.contact = contact; - this.ngbModalRef.result.then( - result => { - this.router.navigate(['/contact', { outlets: { popup: null } }]); - this.ngbModalRef = null; - }, - reason => { - this.router.navigate(['/contact', { outlets: { popup: null } }]); - this.ngbModalRef = null; - } - ); - }, 0); - }); - } - - ngOnDestroy() { - this.ngbModalRef = null; - } -} diff --git a/src/main/webapp/app/entities/contact/contact-detail.component.html b/src/main/webapp/app/entities/contact/contact-detail.component.html deleted file mode 100644 index 37941961..00000000 --- a/src/main/webapp/app/entities/contact/contact-detail.component.html +++ /dev/null @@ -1,35 +0,0 @@ -
-
-
-

Contact {{contact.id}}

-
- -
-
First Name
-
- {{contact.firstName}} -
-
Last Name
-
- {{contact.lastName}} -
-
Email
-
- {{contact.email}} -
-
- - - - -
-
-
diff --git a/src/main/webapp/app/entities/contact/contact-detail.component.ts b/src/main/webapp/app/entities/contact/contact-detail.component.ts deleted file mode 100644 index fc19a9d7..00000000 --- a/src/main/webapp/app/entities/contact/contact-detail.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; - -import { IContact } from 'app/shared/model/contact.model'; - -@Component({ - selector: 'jhi-contact-detail', - templateUrl: './contact-detail.component.html' -}) -export class ContactDetailComponent implements OnInit { - contact: IContact; - - constructor(protected activatedRoute: ActivatedRoute) {} - - ngOnInit() { - this.activatedRoute.data.subscribe(({ contact }) => { - this.contact = contact; - }); - } - - previousState() { - window.history.back(); - } -} diff --git a/src/main/webapp/app/entities/contact/contact-update.component.html b/src/main/webapp/app/entities/contact/contact-update.component.html deleted file mode 100644 index c2410a68..00000000 --- a/src/main/webapp/app/entities/contact/contact-update.component.html +++ /dev/null @@ -1,69 +0,0 @@ -
-
-
-

Create or edit a Contact

-
- -
- - -
-
- - -
- - 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 is required. - - - This field cannot be longer than 80 characters. - -
-
- -
-
- - -
-
-
-
diff --git a/src/main/webapp/app/entities/contact/contact-update.component.ts b/src/main/webapp/app/entities/contact/contact-update.component.ts deleted file mode 100644 index 15960791..00000000 --- a/src/main/webapp/app/entities/contact/contact-update.component.ts +++ /dev/null @@ -1,51 +0,0 @@ -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 { IContact } from 'app/shared/model/contact.model'; -import { ContactService } from './contact.service'; - -@Component({ - selector: 'jhi-contact-update', - templateUrl: './contact-update.component.html' -}) -export class ContactUpdateComponent implements OnInit { - contact: IContact; - isSaving: boolean; - - constructor(protected contactService: ContactService, protected activatedRoute: ActivatedRoute) {} - - ngOnInit() { - this.isSaving = false; - this.activatedRoute.data.subscribe(({ contact }) => { - this.contact = contact; - }); - } - - previousState() { - window.history.back(); - } - - save() { - this.isSaving = true; - if (this.contact.id !== undefined) { - this.subscribeToSaveResponse(this.contactService.update(this.contact)); - } else { - this.subscribeToSaveResponse(this.contactService.create(this.contact)); - } - } - - 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/contact/contact.component.html b/src/main/webapp/app/entities/contact/contact.component.html deleted file mode 100644 index 7a99d963..00000000 --- a/src/main/webapp/app/entities/contact/contact.component.html +++ /dev/null @@ -1,58 +0,0 @@ -
-

- Contacts - -

- -
-
- - - - - - - - - - - - - - - - - - - -
ID First Name Last Name Email
{{contact.id}}{{contact.firstName}}{{contact.lastName}}{{contact.email}} -
- - - -
-
-
-
diff --git a/src/main/webapp/app/entities/contact/contact.route.ts b/src/main/webapp/app/entities/contact/contact.route.ts deleted file mode 100644 index b3e7490e..00000000 --- a/src/main/webapp/app/entities/contact/contact.route.ts +++ /dev/null @@ -1,93 +0,0 @@ -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 { Contact } from 'app/shared/model/contact.model'; -import { ContactService } from './contact.service'; -import { ContactComponent } from './contact.component'; -import { ContactDetailComponent } from './contact-detail.component'; -import { ContactUpdateComponent } from './contact-update.component'; -import { ContactDeletePopupComponent } from './contact-delete-dialog.component'; -import { IContact } from 'app/shared/model/contact.model'; - -@Injectable({ providedIn: 'root' }) -export class ContactResolve implements Resolve { - constructor(private service: ContactService) {} - - 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((contact: HttpResponse) => contact.body) - ); - } - return of(new Contact()); - } -} - -export const contactRoute: Routes = [ - { - path: '', - component: ContactComponent, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: ':id/view', - component: ContactDetailComponent, - resolve: { - contact: ContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: 'new', - component: ContactUpdateComponent, - resolve: { - contact: ContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: ':id/edit', - component: ContactUpdateComponent, - resolve: { - contact: ContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService] - } -]; - -export const contactPopupRoute: Routes = [ - { - path: ':id/delete', - component: ContactDeletePopupComponent, - resolve: { - contact: ContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService], - outlet: 'popup' - } -]; diff --git a/src/main/webapp/app/entities/contact/contact.service.ts b/src/main/webapp/app/entities/contact/contact.service.ts deleted file mode 100644 index 6c516cd4..00000000 --- a/src/main/webapp/app/entities/contact/contact.service.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpResponse } from '@angular/common/http'; -import { Observable } from 'rxjs'; - -import { SERVER_API_URL } from 'app/app.constants'; -import { createRequestOption } from 'app/shared'; -import { IContact } from 'app/shared/model/contact.model'; - -type EntityResponseType = HttpResponse; -type EntityArrayResponseType = HttpResponse; - -@Injectable({ providedIn: 'root' }) -export class ContactService { - public resourceUrl = SERVER_API_URL + 'api/contacts'; - - constructor(protected http: HttpClient) {} - - create(contact: IContact): Observable { - return this.http.post(this.resourceUrl, contact, { observe: 'response' }); - } - - update(contact: IContact): Observable { - return this.http.put(this.resourceUrl, contact, { observe: 'response' }); - } - - find(id: number): Observable { - return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } - - query(req?: any): Observable { - const options = createRequestOption(req); - return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); - } - - delete(id: number): Observable> { - return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } -} diff --git a/src/main/webapp/app/entities/contact/index.ts b/src/main/webapp/app/entities/contact/index.ts deleted file mode 100644 index 08474313..00000000 --- a/src/main/webapp/app/entities/contact/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './contact.service'; -export * from './contact-update.component'; -export * from './contact-delete-dialog.component'; -export * from './contact-detail.component'; -export * from './contact.component'; -export * from './contact.route'; diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.html b/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.html deleted file mode 100644 index d4532275..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
- - - -
diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.html b/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.html deleted file mode 100644 index 8deb192f..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
-
-

Customer Contact {{customerContact.id}}

-
- -
-
Role
-
- {{customerContact.role}} -
-
Contact
-
- -
-
Customer
-
- -
-
- - - - -
-
-
diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.ts b/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.ts deleted file mode 100644 index 655af363..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; - -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; - -@Component({ - selector: 'jhi-customer-contact-detail', - templateUrl: './customer-contact-detail.component.html' -}) -export class CustomerContactDetailComponent implements OnInit { - customerContact: ICustomerContact; - - constructor(protected activatedRoute: ActivatedRoute) {} - - ngOnInit() { - this.activatedRoute.data.subscribe(({ customerContact }) => { - this.customerContact = customerContact; - }); - } - - previousState() { - window.history.back(); - } -} diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.html b/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.html deleted file mode 100644 index f481c079..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.html +++ /dev/null @@ -1,64 +0,0 @@ -
-
-
-

Create or edit a Customer Contact

-
- -
- - -
-
- - -
- - This field is required. - -
-
- -
- - -
-
- - This field is required. - -
-
- - -
-
- - This field is required. - -
-
-
- - -
-
-
-
diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact.component.html b/src/main/webapp/app/entities/customer-contact/customer-contact.component.html deleted file mode 100644 index ac4d18d6..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.component.html +++ /dev/null @@ -1,66 +0,0 @@ -
-

- Customer Contacts - -

- -
-
- - - - - - - - - - - - - - - - - - - -
ID Role Contact Customer
{{customerContact.id}}{{customerContact.role}} - - - - -
- - - -
-
-
-
diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact.component.ts b/src/main/webapp/app/entities/customer-contact/customer-contact.component.ts deleted file mode 100644 index fd174030..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -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 { ICustomerContact } from 'app/shared/model/customer-contact.model'; -import { AccountService } from 'app/core'; - -import { ITEMS_PER_PAGE } from 'app/shared'; -import { CustomerContactService } from './customer-contact.service'; - -@Component({ - selector: 'jhi-customer-contact', - templateUrl: './customer-contact.component.html' -}) -export class CustomerContactComponent implements OnInit, OnDestroy { - customerContacts: ICustomerContact[]; - currentAccount: any; - eventSubscriber: Subscription; - itemsPerPage: number; - links: any; - page: any; - predicate: any; - reverse: any; - totalItems: number; - - constructor( - protected customerContactService: CustomerContactService, - protected jhiAlertService: JhiAlertService, - protected eventManager: JhiEventManager, - protected parseLinks: JhiParseLinks, - protected accountService: AccountService - ) { - this.customerContacts = []; - this.itemsPerPage = ITEMS_PER_PAGE; - this.page = 0; - this.links = { - last: 0 - }; - this.predicate = 'id'; - this.reverse = true; - } - - loadAll() { - this.customerContactService - .query({ - page: this.page, - size: this.itemsPerPage, - sort: this.sort() - }) - .subscribe( - (res: HttpResponse) => this.paginateCustomerContacts(res.body, res.headers), - (res: HttpErrorResponse) => this.onError(res.message) - ); - } - - reset() { - this.page = 0; - this.customerContacts = []; - this.loadAll(); - } - - loadPage(page) { - this.page = page; - this.loadAll(); - } - - ngOnInit() { - this.loadAll(); - this.accountService.identity().then(account => { - this.currentAccount = account; - }); - this.registerChangeInCustomerContacts(); - } - - ngOnDestroy() { - this.eventManager.destroy(this.eventSubscriber); - } - - trackId(index: number, item: ICustomerContact) { - return item.id; - } - - registerChangeInCustomerContacts() { - this.eventSubscriber = this.eventManager.subscribe('customerContactListModification', response => this.reset()); - } - - sort() { - const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; - if (this.predicate !== 'id') { - result.push('id'); - } - return result; - } - - protected paginateCustomerContacts(data: ICustomerContact[], 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.customerContacts.push(data[i]); - } - } - - protected onError(errorMessage: string) { - this.jhiAlertService.error(errorMessage, null, null); - } -} diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact.module.ts b/src/main/webapp/app/entities/customer-contact/customer-contact.module.ts deleted file mode 100644 index 4be5e7cf..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.module.ts +++ /dev/null @@ -1,45 +0,0 @@ -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 { - CustomerContactComponent, - CustomerContactDetailComponent, - CustomerContactUpdateComponent, - CustomerContactDeletePopupComponent, - CustomerContactDeleteDialogComponent, - customerContactRoute, - customerContactPopupRoute -} from './'; - -const ENTITY_STATES = [...customerContactRoute, ...customerContactPopupRoute]; - -@NgModule({ - imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], - declarations: [ - CustomerContactComponent, - CustomerContactDetailComponent, - CustomerContactUpdateComponent, - CustomerContactDeleteDialogComponent, - CustomerContactDeletePopupComponent - ], - entryComponents: [ - CustomerContactComponent, - CustomerContactUpdateComponent, - CustomerContactDeleteDialogComponent, - CustomerContactDeletePopupComponent - ], - providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], - schemas: [CUSTOM_ELEMENTS_SCHEMA] -}) -export class HsadminNgCustomerContactModule { - 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-contact/customer-contact.route.ts b/src/main/webapp/app/entities/customer-contact/customer-contact.route.ts deleted file mode 100644 index 827e2b63..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.route.ts +++ /dev/null @@ -1,93 +0,0 @@ -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 { CustomerContact } from 'app/shared/model/customer-contact.model'; -import { CustomerContactService } from './customer-contact.service'; -import { CustomerContactComponent } from './customer-contact.component'; -import { CustomerContactDetailComponent } from './customer-contact-detail.component'; -import { CustomerContactUpdateComponent } from './customer-contact-update.component'; -import { CustomerContactDeletePopupComponent } from './customer-contact-delete-dialog.component'; -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; - -@Injectable({ providedIn: 'root' }) -export class CustomerContactResolve implements Resolve { - constructor(private service: CustomerContactService) {} - - 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((customerContact: HttpResponse) => customerContact.body) - ); - } - return of(new CustomerContact()); - } -} - -export const customerContactRoute: Routes = [ - { - path: '', - component: CustomerContactComponent, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: ':id/view', - component: CustomerContactDetailComponent, - resolve: { - customerContact: CustomerContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: 'new', - component: CustomerContactUpdateComponent, - resolve: { - customerContact: CustomerContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: ':id/edit', - component: CustomerContactUpdateComponent, - resolve: { - customerContact: CustomerContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService] - } -]; - -export const customerContactPopupRoute: Routes = [ - { - path: ':id/delete', - component: CustomerContactDeletePopupComponent, - resolve: { - customerContact: CustomerContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService], - outlet: 'popup' - } -]; diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact.service.ts b/src/main/webapp/app/entities/customer-contact/customer-contact.service.ts deleted file mode 100644 index 49464888..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.service.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpResponse } from '@angular/common/http'; -import { Observable } from 'rxjs'; - -import { SERVER_API_URL } from 'app/app.constants'; -import { createRequestOption } from 'app/shared'; -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; - -type EntityResponseType = HttpResponse; -type EntityArrayResponseType = HttpResponse; - -@Injectable({ providedIn: 'root' }) -export class CustomerContactService { - public resourceUrl = SERVER_API_URL + 'api/customer-contacts'; - - constructor(protected http: HttpClient) {} - - create(customerContact: ICustomerContact): Observable { - return this.http.post(this.resourceUrl, customerContact, { observe: 'response' }); - } - - update(customerContact: ICustomerContact): Observable { - return this.http.put(this.resourceUrl, customerContact, { observe: 'response' }); - } - - find(id: number): Observable { - return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } - - query(req?: any): Observable { - const options = createRequestOption(req); - return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); - } - - delete(id: number): Observable> { - return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } -} diff --git a/src/main/webapp/app/entities/customer-contact/index.ts b/src/main/webapp/app/entities/customer-contact/index.ts deleted file mode 100644 index 9e0cbba0..00000000 --- a/src/main/webapp/app/entities/customer-contact/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './customer-contact.service'; -export * from './customer-contact-update.component'; -export * from './customer-contact-delete-dialog.component'; -export * from './customer-contact-detail.component'; -export * from './customer-contact.component'; -export * from './customer-contact.route'; diff --git a/src/main/webapp/app/entities/customer/customer-detail.component.html b/src/main/webapp/app/entities/customer/customer-detail.component.html index fbf98ec0..06300ca7 100644 --- a/src/main/webapp/app/entities/customer/customer-detail.component.html +++ b/src/main/webapp/app/entities/customer/customer-detail.component.html @@ -17,22 +17,22 @@
{{customer.name}}
-
Contractual Address
-
- {{customer.contractualAddress}} -
Contractual Salutation
{{customer.contractualSalutation}}
-
Billing Address
+
Contractual Address
- {{customer.billingAddress}} + {{customer.contractualAddress}}
Billing Salutation
{{customer.billingSalutation}}
+
Billing Address
+
+ {{customer.billingAddress}} +
- + + [(ngModel)]="customer.name" required maxlength="80"/>
- This field is required. + [hidden]="!editForm.controls.name?.errors?.required" jhiTranslate="entity.validation.required"> + This field is required. - This field cannot be longer than 80 characters. + [hidden]="!editForm.controls.name?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 80 }"> + This field cannot be longer than 80 characters.
- + + +
+ + This field cannot be longer than 80 characters. + +
+
+
+ -
+ [(ngModel)]="customer.contractualAddress" required maxlength="400"/> +
- This field is required. + [hidden]="!editForm.controls.contractualAddress?.errors?.required" jhiTranslate="entity.validation.required"> + This field is required. - This field cannot be longer than 400 characters. + [hidden]="!editForm.controls.contractualAddress?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 400 }"> + This field cannot be longer than 400 characters.
- - -
- - This field cannot be longer than 80 characters. - -
-
-
- - -
- - This field cannot be longer than 400 characters. - -
-
-
- + -
+ [(ngModel)]="customer.billingSalutation" maxlength="80"/> +
- This field cannot be longer than 80 characters. + [hidden]="!editForm.controls.billingSalutation?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 80 }"> + This field cannot be longer than 80 characters. + +
+
+
+ + +
+ + This field cannot be longer than 400 characters.
diff --git a/src/main/webapp/app/entities/customer/customer.component.html b/src/main/webapp/app/entities/customer/customer.component.html index def61b53..55bbff3e 100644 --- a/src/main/webapp/app/entities/customer/customer.component.html +++ b/src/main/webapp/app/entities/customer/customer.component.html @@ -17,22 +17,11 @@ ID Number Prefix - Name - - - Contractual Address - - - Contractual Salutation - - - Billing Address - - - Billing Salutation - - + Name + Contractual Salutation + Contractual Address + Billing Salutation + Billing Address @@ -42,10 +31,10 @@ {{customer.number}} {{customer.prefix}} {{customer.name}} - {{customer.contractualAddress}} {{customer.contractualSalutation}} - {{customer.billingAddress}} + {{customer.contractualAddress}} {{customer.billingSalutation}} + {{customer.billingAddress}}
- +
- - +
-
+
+ [hidden]="!editForm.controls.from?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
- +
- - +
+
+ + +
+ + This field cannot be longer than 160 characters. + +
+
-
+ [hidden]="!editForm.controls.customer?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
diff --git a/src/main/webapp/app/entities/membership/membership-update.component.ts b/src/main/webapp/app/entities/membership/membership-update.component.ts index 92d41047..9a4c88bb 100644 --- a/src/main/webapp/app/entities/membership/membership-update.component.ts +++ b/src/main/webapp/app/entities/membership/membership-update.component.ts @@ -19,8 +19,8 @@ export class MembershipUpdateComponent implements OnInit { isSaving: boolean; customers: ICustomer[]; - sinceDateDp: any; - untilDateDp: any; + fromDp: any; + toDp: any; constructor( protected jhiAlertService: JhiAlertService, diff --git a/src/main/webapp/app/entities/membership/membership.component.html b/src/main/webapp/app/entities/membership/membership.component.html index 075546a4..16cce281 100644 --- a/src/main/webapp/app/entities/membership/membership.component.html +++ b/src/main/webapp/app/entities/membership/membership.component.html @@ -15,8 +15,9 @@ ID - Since Date - Until Date + From + To + Comment Customer @@ -24,8 +25,9 @@ {{membership.id}} - {{membership.sinceDate | date:'mediumDate'}} - {{membership.untilDate | date:'mediumDate'}} + {{membership.from | date:'mediumDate'}} + {{membership.to | date:'mediumDate'}} + {{membership.comment}}
{{membership.customerPrefix}} diff --git a/src/main/webapp/app/entities/membership/membership.service.ts b/src/main/webapp/app/entities/membership/membership.service.ts index 95388263..9784448f 100644 --- a/src/main/webapp/app/entities/membership/membership.service.ts +++ b/src/main/webapp/app/entities/membership/membership.service.ts @@ -51,16 +51,16 @@ export class MembershipService { protected convertDateFromClient(membership: IMembership): IMembership { const copy: IMembership = Object.assign({}, membership, { - sinceDate: membership.sinceDate != null && membership.sinceDate.isValid() ? membership.sinceDate.format(DATE_FORMAT) : null, - untilDate: membership.untilDate != null && membership.untilDate.isValid() ? membership.untilDate.format(DATE_FORMAT) : null + from: membership.from != null && membership.from.isValid() ? membership.from.format(DATE_FORMAT) : null, + to: membership.to != null && membership.to.isValid() ? membership.to.format(DATE_FORMAT) : null }); return copy; } protected convertDateFromServer(res: EntityResponseType): EntityResponseType { if (res.body) { - res.body.sinceDate = res.body.sinceDate != null ? moment(res.body.sinceDate) : null; - res.body.untilDate = res.body.untilDate != null ? moment(res.body.untilDate) : null; + res.body.from = res.body.from != null ? moment(res.body.from) : null; + res.body.to = res.body.to != null ? moment(res.body.to) : null; } return res; } @@ -68,8 +68,8 @@ export class MembershipService { protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { if (res.body) { res.body.forEach((membership: IMembership) => { - membership.sinceDate = membership.sinceDate != null ? moment(membership.sinceDate) : null; - membership.untilDate = membership.untilDate != null ? moment(membership.untilDate) : null; + membership.from = membership.from != null ? moment(membership.from) : null; + membership.to = membership.to != null ? moment(membership.to) : 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/contact/contact-delete-dialog.component.html b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.html similarity index 67% rename from src/main/webapp/app/entities/contact/contact-delete-dialog.component.html rename to src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.html index 725d215a..12baf54a 100644 --- a/src/main/webapp/app/entities/contact/contact-delete-dialog.component.html +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.html @@ -1,4 +1,4 @@ -
+ diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.ts similarity index 52% rename from src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.ts rename to src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.ts index 1b5157df..741e2642 100644 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.ts +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.ts @@ -4,18 +4,18 @@ import { ActivatedRoute, Router } from '@angular/router'; import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { JhiEventManager } from 'ng-jhipster'; -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; -import { CustomerContactService } from './customer-contact.service'; +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; +import { SepaMandateService } from './sepa-mandate.service'; @Component({ - selector: 'jhi-customer-contact-delete-dialog', - templateUrl: './customer-contact-delete-dialog.component.html' + selector: 'jhi-sepa-mandate-delete-dialog', + templateUrl: './sepa-mandate-delete-dialog.component.html' }) -export class CustomerContactDeleteDialogComponent { - customerContact: ICustomerContact; +export class SepaMandateDeleteDialogComponent { + sepaMandate: ISepaMandate; constructor( - protected customerContactService: CustomerContactService, + protected sepaMandateService: SepaMandateService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager ) {} @@ -25,10 +25,10 @@ export class CustomerContactDeleteDialogComponent { } confirmDelete(id: number) { - this.customerContactService.delete(id).subscribe(response => { + this.sepaMandateService.delete(id).subscribe(response => { this.eventManager.broadcast({ - name: 'customerContactListModification', - content: 'Deleted an customerContact' + name: 'sepaMandateListModification', + content: 'Deleted an sepaMandate' }); this.activeModal.dismiss(true); }); @@ -36,29 +36,29 @@ export class CustomerContactDeleteDialogComponent { } @Component({ - selector: 'jhi-customer-contact-delete-popup', + selector: 'jhi-sepa-mandate-delete-popup', template: '' }) -export class CustomerContactDeletePopupComponent implements OnInit, OnDestroy { +export class SepaMandateDeletePopupComponent implements OnInit, OnDestroy { protected ngbModalRef: NgbModalRef; constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} ngOnInit() { - this.activatedRoute.data.subscribe(({ customerContact }) => { + this.activatedRoute.data.subscribe(({ sepaMandate }) => { setTimeout(() => { - this.ngbModalRef = this.modalService.open(CustomerContactDeleteDialogComponent as Component, { + this.ngbModalRef = this.modalService.open(SepaMandateDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); - this.ngbModalRef.componentInstance.customerContact = customerContact; + this.ngbModalRef.componentInstance.sepaMandate = sepaMandate; this.ngbModalRef.result.then( result => { - this.router.navigate(['/customer-contact', { outlets: { popup: null } }]); + this.router.navigate(['/sepa-mandate', { outlets: { popup: null } }]); this.ngbModalRef = null; }, reason => { - this.router.navigate(['/customer-contact', { outlets: { popup: null } }]); + this.router.navigate(['/sepa-mandate', { outlets: { popup: null } }]); 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..0c38c5e5 --- /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}} +
+
Created
+
+ {{sepaMandate.created}} +
+
Valid From
+
+ {{sepaMandate.validFrom}} +
+
Valid To
+
+ {{sepaMandate.validTo}} +
+
Last Used
+
+ {{sepaMandate.lastUsed}} +
+
Cancelled
+
+ {{sepaMandate.cancelled}} +
+
Comment
+
+ {{sepaMandate.comment}} +
+
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..d4256216 --- /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/customer-contact/customer-contact-update.component.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts similarity index 51% rename from src/main/webapp/app/entities/customer-contact/customer-contact-update.component.ts rename to src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts index 05302d6b..815a3773 100644 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.ts +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts @@ -3,46 +3,40 @@ 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 { ICustomerContact } from 'app/shared/model/customer-contact.model'; -import { CustomerContactService } from './customer-contact.service'; -import { IContact } from 'app/shared/model/contact.model'; -import { ContactService } from 'app/entities/contact'; +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-customer-contact-update', - templateUrl: './customer-contact-update.component.html' + selector: 'jhi-sepa-mandate-update', + templateUrl: './sepa-mandate-update.component.html' }) -export class CustomerContactUpdateComponent implements OnInit { - customerContact: ICustomerContact; +export class SepaMandateUpdateComponent implements OnInit { + sepaMandate: ISepaMandate; isSaving: boolean; - contacts: IContact[]; - customers: ICustomer[]; + createdDp: any; + validFromDp: any; + validToDp: any; + lastUsedDp: any; + cancelledDp: any; constructor( protected jhiAlertService: JhiAlertService, - protected customerContactService: CustomerContactService, - protected contactService: ContactService, + protected sepaMandateService: SepaMandateService, protected customerService: CustomerService, protected activatedRoute: ActivatedRoute ) {} ngOnInit() { this.isSaving = false; - this.activatedRoute.data.subscribe(({ customerContact }) => { - this.customerContact = customerContact; + this.activatedRoute.data.subscribe(({ sepaMandate }) => { + this.sepaMandate = sepaMandate; }); - this.contactService - .query() - .pipe( - filter((mayBeOk: HttpResponse) => mayBeOk.ok), - map((response: HttpResponse) => response.body) - ) - .subscribe((res: IContact[]) => (this.contacts = res), (res: HttpErrorResponse) => this.onError(res.message)); this.customerService .query() .pipe( @@ -58,15 +52,15 @@ export class CustomerContactUpdateComponent implements OnInit { save() { this.isSaving = true; - if (this.customerContact.id !== undefined) { - this.subscribeToSaveResponse(this.customerContactService.update(this.customerContact)); + if (this.sepaMandate.id !== undefined) { + this.subscribeToSaveResponse(this.sepaMandateService.update(this.sepaMandate)); } else { - this.subscribeToSaveResponse(this.customerContactService.create(this.customerContact)); + this.subscribeToSaveResponse(this.sepaMandateService.create(this.sepaMandate)); } } - protected subscribeToSaveResponse(result: Observable>) { - result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); + protected subscribeToSaveResponse(result: Observable>) { + result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); } protected onSaveSuccess() { @@ -82,10 +76,6 @@ export class CustomerContactUpdateComponent implements OnInit { this.jhiAlertService.error(errorMessage, null, null); } - trackContactById(index: number, item: IContact) { - return item.id; - } - 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..67450128 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html @@ -0,0 +1,76 @@ +
+

+ Sepa Mandates + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID Reference Iban Bic Created Valid From Valid To Last Used Cancelled Comment Customer
{{sepaMandate.id}}{{sepaMandate.reference}}{{sepaMandate.iban}}{{sepaMandate.bic}}{{sepaMandate.created | date:'mediumDate'}}{{sepaMandate.validFrom | date:'mediumDate'}}{{sepaMandate.validTo | date:'mediumDate'}}{{sepaMandate.lastUsed | date:'mediumDate'}}{{sepaMandate.cancelled | date:'mediumDate'}}{{sepaMandate.comment}} + + +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/contact/contact.component.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.ts similarity index 70% rename from src/main/webapp/app/entities/contact/contact.component.ts rename to src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.ts index 60c0f99d..d7ef209a 100644 --- a/src/main/webapp/app/entities/contact/contact.component.ts +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.ts @@ -4,18 +4,18 @@ import { Subscription } from 'rxjs'; import { filter, map } from 'rxjs/operators'; import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster'; -import { IContact } from 'app/shared/model/contact.model'; +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; import { AccountService } from 'app/core'; import { ITEMS_PER_PAGE } from 'app/shared'; -import { ContactService } from './contact.service'; +import { SepaMandateService } from './sepa-mandate.service'; @Component({ - selector: 'jhi-contact', - templateUrl: './contact.component.html' + selector: 'jhi-sepa-mandate', + templateUrl: './sepa-mandate.component.html' }) -export class ContactComponent implements OnInit, OnDestroy { - contacts: IContact[]; +export class SepaMandateComponent implements OnInit, OnDestroy { + sepaMandates: ISepaMandate[]; currentAccount: any; eventSubscriber: Subscription; itemsPerPage: number; @@ -26,13 +26,13 @@ export class ContactComponent implements OnInit, OnDestroy { totalItems: number; constructor( - protected contactService: ContactService, + protected sepaMandateService: SepaMandateService, protected jhiAlertService: JhiAlertService, protected eventManager: JhiEventManager, protected parseLinks: JhiParseLinks, protected accountService: AccountService ) { - this.contacts = []; + this.sepaMandates = []; this.itemsPerPage = ITEMS_PER_PAGE; this.page = 0; this.links = { @@ -43,21 +43,21 @@ export class ContactComponent implements OnInit, OnDestroy { } loadAll() { - this.contactService + this.sepaMandateService .query({ page: this.page, size: this.itemsPerPage, sort: this.sort() }) .subscribe( - (res: HttpResponse) => this.paginateContacts(res.body, res.headers), + (res: HttpResponse) => this.paginateSepaMandates(res.body, res.headers), (res: HttpErrorResponse) => this.onError(res.message) ); } reset() { this.page = 0; - this.contacts = []; + this.sepaMandates = []; this.loadAll(); } @@ -71,19 +71,19 @@ export class ContactComponent implements OnInit, OnDestroy { this.accountService.identity().then(account => { this.currentAccount = account; }); - this.registerChangeInContacts(); + this.registerChangeInSepaMandates(); } ngOnDestroy() { this.eventManager.destroy(this.eventSubscriber); } - trackId(index: number, item: IContact) { + trackId(index: number, item: ISepaMandate) { return item.id; } - registerChangeInContacts() { - this.eventSubscriber = this.eventManager.subscribe('contactListModification', response => this.reset()); + registerChangeInSepaMandates() { + this.eventSubscriber = this.eventManager.subscribe('sepaMandateListModification', response => this.reset()); } sort() { @@ -94,11 +94,11 @@ export class ContactComponent implements OnInit, OnDestroy { return result; } - protected paginateContacts(data: IContact[], headers: HttpHeaders) { + 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.contacts.push(data[i]); + this.sepaMandates.push(data[i]); } } diff --git a/src/main/webapp/app/entities/contact/contact.module.ts b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.module.ts similarity index 56% rename from src/main/webapp/app/entities/contact/contact.module.ts rename to src/main/webapp/app/entities/sepa-mandate/sepa-mandate.module.ts index 21e6975d..f94a5113 100644 --- a/src/main/webapp/app/entities/contact/contact.module.ts +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.module.ts @@ -5,31 +5,31 @@ import { JhiLanguageHelper } from 'app/core'; import { HsadminNgSharedModule } from 'app/shared'; import { - ContactComponent, - ContactDetailComponent, - ContactUpdateComponent, - ContactDeletePopupComponent, - ContactDeleteDialogComponent, - contactRoute, - contactPopupRoute + SepaMandateComponent, + SepaMandateDetailComponent, + SepaMandateUpdateComponent, + SepaMandateDeletePopupComponent, + SepaMandateDeleteDialogComponent, + sepaMandateRoute, + sepaMandatePopupRoute } from './'; -const ENTITY_STATES = [...contactRoute, ...contactPopupRoute]; +const ENTITY_STATES = [...sepaMandateRoute, ...sepaMandatePopupRoute]; @NgModule({ imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], declarations: [ - ContactComponent, - ContactDetailComponent, - ContactUpdateComponent, - ContactDeleteDialogComponent, - ContactDeletePopupComponent + SepaMandateComponent, + SepaMandateDetailComponent, + SepaMandateUpdateComponent, + SepaMandateDeleteDialogComponent, + SepaMandateDeletePopupComponent ], - entryComponents: [ContactComponent, ContactUpdateComponent, ContactDeleteDialogComponent, ContactDeletePopupComponent], + entryComponents: [SepaMandateComponent, SepaMandateUpdateComponent, SepaMandateDeleteDialogComponent, SepaMandateDeletePopupComponent], providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], schemas: [CUSTOM_ELEMENTS_SCHEMA] }) -export class HsadminNgContactModule { +export class HsadminNgSepaMandateModule { constructor(private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper) { this.languageHelper.language.subscribe((languageKey: string) => { if (languageKey !== undefined) { 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..cb5e5b77 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts @@ -0,0 +1,86 @@ +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, { + created: sepaMandate.created != null && sepaMandate.created.isValid() ? sepaMandate.created.format(DATE_FORMAT) : null, + validFrom: sepaMandate.validFrom != null && sepaMandate.validFrom.isValid() ? sepaMandate.validFrom.format(DATE_FORMAT) : null, + validTo: sepaMandate.validTo != null && sepaMandate.validTo.isValid() ? sepaMandate.validTo.format(DATE_FORMAT) : null, + lastUsed: sepaMandate.lastUsed != null && sepaMandate.lastUsed.isValid() ? sepaMandate.lastUsed.format(DATE_FORMAT) : null, + cancelled: sepaMandate.cancelled != null && sepaMandate.cancelled.isValid() ? sepaMandate.cancelled.format(DATE_FORMAT) : null + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.created = res.body.created != null ? moment(res.body.created) : null; + res.body.validFrom = res.body.validFrom != null ? moment(res.body.validFrom) : null; + res.body.validTo = res.body.validTo != null ? moment(res.body.validTo) : null; + res.body.lastUsed = res.body.lastUsed != null ? moment(res.body.lastUsed) : null; + res.body.cancelled = res.body.cancelled != null ? moment(res.body.cancelled) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((sepaMandate: ISepaMandate) => { + sepaMandate.created = sepaMandate.created != null ? moment(sepaMandate.created) : null; + sepaMandate.validFrom = sepaMandate.validFrom != null ? moment(sepaMandate.validFrom) : null; + sepaMandate.validTo = sepaMandate.validTo != null ? moment(sepaMandate.validTo) : null; + sepaMandate.lastUsed = sepaMandate.lastUsed != null ? moment(sepaMandate.lastUsed) : null; + sepaMandate.cancelled = sepaMandate.cancelled != null ? moment(sepaMandate.cancelled) : null; + }); + } + return res; + } +} diff --git a/src/main/webapp/app/entities/share/share-detail.component.html b/src/main/webapp/app/entities/share/share-detail.component.html index 24ba66c1..5ebcd18a 100644 --- a/src/main/webapp/app/entities/share/share-detail.component.html +++ b/src/main/webapp/app/entities/share/share-detail.component.html @@ -21,10 +21,10 @@
{{share.comment}}
-
Member
+
Membership
-
diff --git a/src/main/webapp/app/entities/share/share-update.component.html b/src/main/webapp/app/entities/share/share-update.component.html index 3f092ec3..ee2f579d 100644 --- a/src/main/webapp/app/entities/share/share-update.component.html +++ b/src/main/webapp/app/entities/share/share-update.component.html @@ -66,16 +66,15 @@
- - + +
-
+
+ [hidden]="!editForm.controls.membership?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
diff --git a/src/main/webapp/app/entities/share/share.component.html b/src/main/webapp/app/entities/share/share.component.html index 82cead44..9ee3a776 100644 --- a/src/main/webapp/app/entities/share/share.component.html +++ b/src/main/webapp/app/entities/share/share.component.html @@ -19,7 +19,7 @@ Action Quantity Comment - Member + Membership @@ -31,8 +31,8 @@ {{share.quantity}} {{share.comment}} -
- {{share.memberId}} + diff --git a/src/main/webapp/app/layouts/navbar/navbar.component.html b/src/main/webapp/app/layouts/navbar/navbar.component.html index 201ff3aa..9ec42f90 100644 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -33,18 +33,6 @@ Customer -
  • - - - Contact - -
  • -
  • - - - Customer Contact - -
  • @@ -63,6 +51,12 @@ Asset
  • +
  • + + + Sepa Mandate + +
  • diff --git a/src/main/webapp/app/shared/model/asset.model.ts b/src/main/webapp/app/shared/model/asset.model.ts index aa577d11..def847a0 100644 --- a/src/main/webapp/app/shared/model/asset.model.ts +++ b/src/main/webapp/app/shared/model/asset.model.ts @@ -15,7 +15,8 @@ export interface IAsset { action?: AssetAction; amount?: number; comment?: string; - memberId?: number; + membershipFrom?: string; + membershipId?: number; } export class Asset implements IAsset { @@ -25,6 +26,7 @@ export class Asset implements IAsset { public action?: AssetAction, public amount?: number, public comment?: string, - public memberId?: number + public membershipFrom?: string, + public membershipId?: number ) {} } diff --git a/src/main/webapp/app/shared/model/contact.model.ts b/src/main/webapp/app/shared/model/contact.model.ts deleted file mode 100644 index 8c02a4a2..00000000 --- a/src/main/webapp/app/shared/model/contact.model.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; - -export interface IContact { - id?: number; - firstName?: string; - lastName?: string; - email?: string; - roles?: ICustomerContact[]; -} - -export class Contact implements IContact { - constructor( - public id?: number, - public firstName?: string, - public lastName?: string, - public email?: string, - public roles?: ICustomerContact[] - ) {} -} diff --git a/src/main/webapp/app/shared/model/customer-contact.model.ts b/src/main/webapp/app/shared/model/customer-contact.model.ts deleted file mode 100644 index c1d3f274..00000000 --- a/src/main/webapp/app/shared/model/customer-contact.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -export const enum CustomerContactRole { - CONTRACTUAL = 'CONTRACTUAL', - TECHNICAL = 'TECHNICAL', - FINANCIAL = 'FINANCIAL' -} - -export interface ICustomerContact { - id?: number; - role?: CustomerContactRole; - contactEmail?: string; - contactId?: number; - customerPrefix?: string; - customerId?: number; -} - -export class CustomerContact implements ICustomerContact { - constructor( - public id?: number, - public role?: CustomerContactRole, - public contactEmail?: string, - public contactId?: number, - public customerPrefix?: string, - public customerId?: number - ) {} -} diff --git a/src/main/webapp/app/shared/model/customer.model.ts b/src/main/webapp/app/shared/model/customer.model.ts index d876bd10..c8c2cd8f 100644 --- a/src/main/webapp/app/shared/model/customer.model.ts +++ b/src/main/webapp/app/shared/model/customer.model.ts @@ -1,17 +1,17 @@ -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; import { IMembership } from 'app/shared/model/membership.model'; +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; export interface ICustomer { id?: number; number?: number; prefix?: string; name?: string; - contractualAddress?: string; contractualSalutation?: string; - billingAddress?: string; + contractualAddress?: string; billingSalutation?: string; - roles?: ICustomerContact[]; + billingAddress?: string; memberships?: IMembership[]; + sepamandates?: ISepaMandate[]; } export class Customer implements ICustomer { @@ -20,11 +20,11 @@ export class Customer implements ICustomer { public number?: number, public prefix?: string, public name?: string, - public contractualAddress?: string, public contractualSalutation?: string, - public billingAddress?: string, + public contractualAddress?: string, public billingSalutation?: string, - public roles?: ICustomerContact[], - public memberships?: IMembership[] + public billingAddress?: 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 index f1ad5337..87bbf1d6 100644 --- a/src/main/webapp/app/shared/model/membership.model.ts +++ b/src/main/webapp/app/shared/model/membership.model.ts @@ -4,8 +4,9 @@ import { IAsset } from 'app/shared/model/asset.model'; export interface IMembership { id?: number; - sinceDate?: Moment; - untilDate?: Moment; + from?: Moment; + to?: Moment; + comment?: string; shares?: IShare[]; assets?: IAsset[]; customerPrefix?: string; @@ -15,8 +16,9 @@ export interface IMembership { export class Membership implements IMembership { constructor( public id?: number, - public sinceDate?: Moment, - public untilDate?: Moment, + public from?: Moment, + public to?: Moment, + public comment?: string, public shares?: IShare[], public assets?: IAsset[], public customerPrefix?: string, 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..0589e0b0 --- /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; + created?: Moment; + validFrom?: Moment; + validTo?: Moment; + lastUsed?: Moment; + cancelled?: Moment; + comment?: string; + customerPrefix?: string; + customerId?: number; +} + +export class SepaMandate implements ISepaMandate { + constructor( + public id?: number, + public reference?: string, + public iban?: string, + public bic?: string, + public created?: Moment, + public validFrom?: Moment, + public validTo?: Moment, + public lastUsed?: Moment, + public cancelled?: Moment, + public comment?: string, + public customerPrefix?: string, + public customerId?: number + ) {} +} diff --git a/src/main/webapp/app/shared/model/share.model.ts b/src/main/webapp/app/shared/model/share.model.ts index c3eb8cce..e318889f 100644 --- a/src/main/webapp/app/shared/model/share.model.ts +++ b/src/main/webapp/app/shared/model/share.model.ts @@ -11,7 +11,8 @@ export interface IShare { action?: ShareAction; quantity?: number; comment?: string; - memberId?: number; + membershipFrom?: string; + membershipId?: number; } export class Share implements IShare { @@ -21,6 +22,7 @@ export class Share implements IShare { public action?: ShareAction, public quantity?: number, public comment?: string, - public memberId?: number + public membershipFrom?: string, + public membershipId?: number ) {} } diff --git a/src/main/webapp/i18n/de/asset.json b/src/main/webapp/i18n/de/asset.json index 8f36a53f..1cd6fa89 100644 --- a/src/main/webapp/i18n/de/asset.json +++ b/src/main/webapp/i18n/de/asset.json @@ -19,7 +19,7 @@ "action": "Action", "amount": "Amount", "comment": "Comment", - "member": "Member" + "membership": "Membership" } } } diff --git a/src/main/webapp/i18n/de/contact.json b/src/main/webapp/i18n/de/contact.json deleted file mode 100644 index 521243c6..00000000 --- a/src/main/webapp/i18n/de/contact.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "hsadminNgApp": { - "contact": { - "home": { - "title": "Contacts", - "createLabel": "Contact erstellen", - "createOrEditLabel": "Contact erstellen oder bearbeiten" - }, - "created": "Contact erstellt mit ID {{ param }}", - "updated": "Contact aktualisiert mit ID {{ param }}", - "deleted": "Contact gelöscht mit ID {{ param }}", - "delete": { - "question": "Soll Contact {{ id }} wirklich dauerhaft gelöscht werden?" - }, - "detail": { - "title": "Contact" - }, - "firstName": "First Name", - "lastName": "Last Name", - "email": "Email", - "role": "Role" - } - } -} diff --git a/src/main/webapp/i18n/de/customer.json b/src/main/webapp/i18n/de/customer.json index 407c3863..88e0fb1b 100644 --- a/src/main/webapp/i18n/de/customer.json +++ b/src/main/webapp/i18n/de/customer.json @@ -18,12 +18,12 @@ "number": "Number", "prefix": "Prefix", "name": "Name", - "contractualAddress": "Contractual Address", "contractualSalutation": "Contractual Salutation", - "billingAddress": "Billing Address", + "contractualAddress": "Contractual Address", "billingSalutation": "Billing Salutation", - "role": "Role", - "membership": "Membership" + "billingAddress": "Billing Address", + "membership": "Membership", + "sepamandate": "Sepamandate" } } } diff --git a/src/main/webapp/i18n/de/customerContact.json b/src/main/webapp/i18n/de/customerContact.json deleted file mode 100644 index 4f5b69d9..00000000 --- a/src/main/webapp/i18n/de/customerContact.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "hsadminNgApp": { - "customerContact": { - "home": { - "title": "Customer Contacts", - "createLabel": "Customer Contact erstellen", - "createOrEditLabel": "Customer Contact erstellen oder bearbeiten" - }, - "created": "Customer Contact erstellt mit ID {{ param }}", - "updated": "Customer Contact aktualisiert mit ID {{ param }}", - "deleted": "Customer Contact gelöscht mit ID {{ param }}", - "delete": { - "question": "Soll Customer Contact {{ id }} wirklich dauerhaft gelöscht werden?" - }, - "detail": { - "title": "Customer Contact" - }, - "role": "Role", - "contact": "Contact", - "customer": "Customer" - } - } -} diff --git a/src/main/webapp/i18n/de/customerContactRole.json b/src/main/webapp/i18n/de/customerContactRole.json deleted file mode 100644 index 7e654646..00000000 --- a/src/main/webapp/i18n/de/customerContactRole.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "hsadminNgApp": { - "CustomerContactRole": { - "null": "", - "CONTRACTUAL": "CONTRACTUAL", - "TECHNICAL": "TECHNICAL", - "FINANCIAL": "FINANCIAL" - } - } -} diff --git a/src/main/webapp/i18n/de/global.json b/src/main/webapp/i18n/de/global.json index f6ef880f..45c16b69 100644 --- a/src/main/webapp/i18n/de/global.json +++ b/src/main/webapp/i18n/de/global.json @@ -8,11 +8,10 @@ "entities": { "main": "Entitäten", "customer": "Customer", - "contact": "Contact", - "customerContact": "Customer Contact", "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 index 95fb3f58..925ad16c 100644 --- a/src/main/webapp/i18n/de/membership.json +++ b/src/main/webapp/i18n/de/membership.json @@ -15,8 +15,9 @@ "detail": { "title": "Membership" }, - "sinceDate": "Since Date", - "untilDate": "Until Date", + "from": "From", + "to": "To", + "comment": "Comment", "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..f071fcbb --- /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", + "created": "Created", + "validFrom": "Valid From", + "validTo": "Valid To", + "lastUsed": "Last Used", + "cancelled": "Cancelled", + "comment": "Comment", + "customer": "Customer" + } + } +} diff --git a/src/main/webapp/i18n/de/share.json b/src/main/webapp/i18n/de/share.json index 702f8f83..977c72b8 100644 --- a/src/main/webapp/i18n/de/share.json +++ b/src/main/webapp/i18n/de/share.json @@ -19,7 +19,7 @@ "action": "Action", "quantity": "Quantity", "comment": "Comment", - "member": "Member" + "membership": "Membership" } } } diff --git a/src/main/webapp/i18n/en/asset.json b/src/main/webapp/i18n/en/asset.json index 128f5716..207565eb 100644 --- a/src/main/webapp/i18n/en/asset.json +++ b/src/main/webapp/i18n/en/asset.json @@ -19,7 +19,7 @@ "action": "Action", "amount": "Amount", "comment": "Comment", - "member": "Member" + "membership": "Membership" } } } diff --git a/src/main/webapp/i18n/en/contact.json b/src/main/webapp/i18n/en/contact.json deleted file mode 100644 index 680664c7..00000000 --- a/src/main/webapp/i18n/en/contact.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "hsadminNgApp": { - "contact": { - "home": { - "title": "Contacts", - "createLabel": "Create a new Contact", - "createOrEditLabel": "Create or edit a Contact" - }, - "created": "A new Contact is created with identifier {{ param }}", - "updated": "A Contact is updated with identifier {{ param }}", - "deleted": "A Contact is deleted with identifier {{ param }}", - "delete": { - "question": "Are you sure you want to delete Contact {{ id }}?" - }, - "detail": { - "title": "Contact" - }, - "firstName": "First Name", - "lastName": "Last Name", - "email": "Email", - "role": "Role" - } - } -} diff --git a/src/main/webapp/i18n/en/customer.json b/src/main/webapp/i18n/en/customer.json index b58c1345..620db497 100644 --- a/src/main/webapp/i18n/en/customer.json +++ b/src/main/webapp/i18n/en/customer.json @@ -18,12 +18,12 @@ "number": "Number", "prefix": "Prefix", "name": "Name", - "contractualAddress": "Contractual Address", "contractualSalutation": "Contractual Salutation", - "billingAddress": "Billing Address", + "contractualAddress": "Contractual Address", "billingSalutation": "Billing Salutation", - "role": "Role", - "membership": "Membership" + "billingAddress": "Billing Address", + "membership": "Membership", + "sepamandate": "Sepamandate" } } } diff --git a/src/main/webapp/i18n/en/customerContact.json b/src/main/webapp/i18n/en/customerContact.json deleted file mode 100644 index 57173ebd..00000000 --- a/src/main/webapp/i18n/en/customerContact.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "hsadminNgApp": { - "customerContact": { - "home": { - "title": "Customer Contacts", - "createLabel": "Create a new Customer Contact", - "createOrEditLabel": "Create or edit a Customer Contact" - }, - "created": "A new Customer Contact is created with identifier {{ param }}", - "updated": "A Customer Contact is updated with identifier {{ param }}", - "deleted": "A Customer Contact is deleted with identifier {{ param }}", - "delete": { - "question": "Are you sure you want to delete Customer Contact {{ id }}?" - }, - "detail": { - "title": "Customer Contact" - }, - "role": "Role", - "contact": "Contact", - "customer": "Customer" - } - } -} diff --git a/src/main/webapp/i18n/en/customerContactRole.json b/src/main/webapp/i18n/en/customerContactRole.json deleted file mode 100644 index 7e654646..00000000 --- a/src/main/webapp/i18n/en/customerContactRole.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "hsadminNgApp": { - "CustomerContactRole": { - "null": "", - "CONTRACTUAL": "CONTRACTUAL", - "TECHNICAL": "TECHNICAL", - "FINANCIAL": "FINANCIAL" - } - } -} diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index 3b496f5b..0e0124c8 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -8,11 +8,10 @@ "entities": { "main": "Entities", "customer": "Customer", - "contact": "Contact", - "customerContact": "Customer Contact", "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 index 08b7f156..c9828a5d 100644 --- a/src/main/webapp/i18n/en/membership.json +++ b/src/main/webapp/i18n/en/membership.json @@ -15,8 +15,9 @@ "detail": { "title": "Membership" }, - "sinceDate": "Since Date", - "untilDate": "Until Date", + "from": "From", + "to": "To", + "comment": "Comment", "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..22ffee76 --- /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", + "created": "Created", + "validFrom": "Valid From", + "validTo": "Valid To", + "lastUsed": "Last Used", + "cancelled": "Cancelled", + "comment": "Comment", + "customer": "Customer" + } + } +} diff --git a/src/main/webapp/i18n/en/share.json b/src/main/webapp/i18n/en/share.json index 06637120..1a446f85 100644 --- a/src/main/webapp/i18n/en/share.json +++ b/src/main/webapp/i18n/en/share.json @@ -19,7 +19,7 @@ "action": "Action", "quantity": "Quantity", "comment": "Comment", - "member": "Member" + "membership": "Membership" } } } diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java index 80dc172a..7e5f86fa 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java @@ -1,15 +1,17 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; + import org.hostsharing.hsadminng.domain.Asset; import org.hostsharing.hsadminng.domain.Membership; -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; import org.hostsharing.hsadminng.repository.AssetRepository; -import org.hostsharing.hsadminng.service.AssetQueryService; import org.hostsharing.hsadminng.service.AssetService; import org.hostsharing.hsadminng.service.dto.AssetDTO; import org.hostsharing.hsadminng.service.mapper.AssetMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.AssetCriteria; +import org.hostsharing.hsadminng.service.AssetQueryService; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,11 +33,14 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; + +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; /** * Test class for the AssetResource REST controller. * @@ -116,7 +121,7 @@ public class AssetResourceIntTest { Membership membership = MembershipResourceIntTest.createEntity(em); em.persist(membership); em.flush(); - asset.setMember(membership); + asset.setMembership(membership); return asset; } @@ -443,20 +448,20 @@ public class AssetResourceIntTest { @Test @Transactional - public void getAllAssetsByMemberIsEqualToSomething() throws Exception { + public void getAllAssetsByMembershipIsEqualToSomething() throws Exception { // Initialize the database - Membership member = MembershipResourceIntTest.createEntity(em); - em.persist(member); + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); em.flush(); - asset.setMember(member); + asset.setMembership(membership); assetRepository.saveAndFlush(asset); - Long memberId = member.getId(); + Long membershipId = membership.getId(); - // Get all the assetList where member equals to memberId - defaultAssetShouldBeFound("memberId.equals=" + memberId); + // Get all the assetList where membership equals to membershipId + defaultAssetShouldBeFound("membershipId.equals=" + membershipId); - // Get all the assetList where member equals to memberId + 1 - defaultAssetShouldNotBeFound("memberId.equals=" + (memberId + 1)); + // Get all the assetList where membership equals to membershipId + 1 + defaultAssetShouldNotBeFound("membershipId.equals=" + (membershipId + 1)); } /** diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java deleted file mode 100644 index 724a06c3..00000000 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java +++ /dev/null @@ -1,536 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; - -import org.hostsharing.hsadminng.HsadminNgApp; - -import org.hostsharing.hsadminng.domain.Contact; -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.hostsharing.hsadminng.repository.ContactRepository; -import org.hostsharing.hsadminng.service.ContactService; -import org.hostsharing.hsadminng.service.dto.ContactDTO; -import org.hostsharing.hsadminng.service.mapper.ContactMapper; -import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.ContactCriteria; -import org.hostsharing.hsadminng.service.ContactQueryService; - -import org.junit.Before; -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.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 ContactResource REST controller. - * - * @see ContactResource - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = HsadminNgApp.class) -public class ContactResourceIntTest { - - private static final String DEFAULT_FIRST_NAME = "AAAAAAAAAA"; - private static final String UPDATED_FIRST_NAME = "BBBBBBBBBB"; - - private static final String DEFAULT_LAST_NAME = "AAAAAAAAAA"; - private static final String UPDATED_LAST_NAME = "BBBBBBBBBB"; - - private static final String DEFAULT_EMAIL = "AAAAAAAAAA"; - private static final String UPDATED_EMAIL = "BBBBBBBBBB"; - - @Autowired - private ContactRepository contactRepository; - - @Autowired - private ContactMapper contactMapper; - - @Autowired - private ContactService contactService; - - @Autowired - private ContactQueryService contactQueryService; - - @Autowired - private MappingJackson2HttpMessageConverter jacksonMessageConverter; - - @Autowired - private PageableHandlerMethodArgumentResolver pageableArgumentResolver; - - @Autowired - private ExceptionTranslator exceptionTranslator; - - @Autowired - private EntityManager em; - - @Autowired - private Validator validator; - - private MockMvc restContactMockMvc; - - private Contact contact; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - final ContactResource contactResource = new ContactResource(contactService, contactQueryService); - this.restContactMockMvc = MockMvcBuilders.standaloneSetup(contactResource) - .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 Contact createEntity(EntityManager em) { - Contact contact = new Contact() - .firstName(DEFAULT_FIRST_NAME) - .lastName(DEFAULT_LAST_NAME) - .email(DEFAULT_EMAIL); - return contact; - } - - @Before - public void initTest() { - contact = createEntity(em); - } - - @Test - @Transactional - public void createContact() throws Exception { - int databaseSizeBeforeCreate = contactRepository.findAll().size(); - - // Create the Contact - ContactDTO contactDTO = contactMapper.toDto(contact); - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isCreated()); - - // Validate the Contact in the database - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeCreate + 1); - Contact testContact = contactList.get(contactList.size() - 1); - assertThat(testContact.getFirstName()).isEqualTo(DEFAULT_FIRST_NAME); - assertThat(testContact.getLastName()).isEqualTo(DEFAULT_LAST_NAME); - assertThat(testContact.getEmail()).isEqualTo(DEFAULT_EMAIL); - } - - @Test - @Transactional - public void createContactWithExistingId() throws Exception { - int databaseSizeBeforeCreate = contactRepository.findAll().size(); - - // Create the Contact with an existing ID - contact.setId(1L); - ContactDTO contactDTO = contactMapper.toDto(contact); - - // An entity with an existing ID cannot be created, so this API call must fail - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - // Validate the Contact in the database - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeCreate); - } - - @Test - @Transactional - public void checkFirstNameIsRequired() throws Exception { - int databaseSizeBeforeTest = contactRepository.findAll().size(); - // set the field null - contact.setFirstName(null); - - // Create the Contact, which fails. - ContactDTO contactDTO = contactMapper.toDto(contact); - - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeTest); - } - - @Test - @Transactional - public void checkLastNameIsRequired() throws Exception { - int databaseSizeBeforeTest = contactRepository.findAll().size(); - // set the field null - contact.setLastName(null); - - // Create the Contact, which fails. - ContactDTO contactDTO = contactMapper.toDto(contact); - - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeTest); - } - - @Test - @Transactional - public void checkEmailIsRequired() throws Exception { - int databaseSizeBeforeTest = contactRepository.findAll().size(); - // set the field null - contact.setEmail(null); - - // Create the Contact, which fails. - ContactDTO contactDTO = contactMapper.toDto(contact); - - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeTest); - } - - @Test - @Transactional - public void getAllContacts() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList - restContactMockMvc.perform(get("/api/contacts?sort=id,desc")) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.[*].id").value(hasItem(contact.getId().intValue()))) - .andExpect(jsonPath("$.[*].firstName").value(hasItem(DEFAULT_FIRST_NAME.toString()))) - .andExpect(jsonPath("$.[*].lastName").value(hasItem(DEFAULT_LAST_NAME.toString()))) - .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL.toString()))); - } - - @Test - @Transactional - public void getContact() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get the contact - restContactMockMvc.perform(get("/api/contacts/{id}", contact.getId())) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.id").value(contact.getId().intValue())) - .andExpect(jsonPath("$.firstName").value(DEFAULT_FIRST_NAME.toString())) - .andExpect(jsonPath("$.lastName").value(DEFAULT_LAST_NAME.toString())) - .andExpect(jsonPath("$.email").value(DEFAULT_EMAIL.toString())); - } - - @Test - @Transactional - public void getAllContactsByFirstNameIsEqualToSomething() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where firstName equals to DEFAULT_FIRST_NAME - defaultContactShouldBeFound("firstName.equals=" + DEFAULT_FIRST_NAME); - - // Get all the contactList where firstName equals to UPDATED_FIRST_NAME - defaultContactShouldNotBeFound("firstName.equals=" + UPDATED_FIRST_NAME); - } - - @Test - @Transactional - public void getAllContactsByFirstNameIsInShouldWork() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where firstName in DEFAULT_FIRST_NAME or UPDATED_FIRST_NAME - defaultContactShouldBeFound("firstName.in=" + DEFAULT_FIRST_NAME + "," + UPDATED_FIRST_NAME); - - // Get all the contactList where firstName equals to UPDATED_FIRST_NAME - defaultContactShouldNotBeFound("firstName.in=" + UPDATED_FIRST_NAME); - } - - @Test - @Transactional - public void getAllContactsByFirstNameIsNullOrNotNull() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where firstName is not null - defaultContactShouldBeFound("firstName.specified=true"); - - // Get all the contactList where firstName is null - defaultContactShouldNotBeFound("firstName.specified=false"); - } - - @Test - @Transactional - public void getAllContactsByLastNameIsEqualToSomething() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where lastName equals to DEFAULT_LAST_NAME - defaultContactShouldBeFound("lastName.equals=" + DEFAULT_LAST_NAME); - - // Get all the contactList where lastName equals to UPDATED_LAST_NAME - defaultContactShouldNotBeFound("lastName.equals=" + UPDATED_LAST_NAME); - } - - @Test - @Transactional - public void getAllContactsByLastNameIsInShouldWork() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where lastName in DEFAULT_LAST_NAME or UPDATED_LAST_NAME - defaultContactShouldBeFound("lastName.in=" + DEFAULT_LAST_NAME + "," + UPDATED_LAST_NAME); - - // Get all the contactList where lastName equals to UPDATED_LAST_NAME - defaultContactShouldNotBeFound("lastName.in=" + UPDATED_LAST_NAME); - } - - @Test - @Transactional - public void getAllContactsByLastNameIsNullOrNotNull() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where lastName is not null - defaultContactShouldBeFound("lastName.specified=true"); - - // Get all the contactList where lastName is null - defaultContactShouldNotBeFound("lastName.specified=false"); - } - - @Test - @Transactional - public void getAllContactsByEmailIsEqualToSomething() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where email equals to DEFAULT_EMAIL - defaultContactShouldBeFound("email.equals=" + DEFAULT_EMAIL); - - // Get all the contactList where email equals to UPDATED_EMAIL - defaultContactShouldNotBeFound("email.equals=" + UPDATED_EMAIL); - } - - @Test - @Transactional - public void getAllContactsByEmailIsInShouldWork() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where email in DEFAULT_EMAIL or UPDATED_EMAIL - defaultContactShouldBeFound("email.in=" + DEFAULT_EMAIL + "," + UPDATED_EMAIL); - - // Get all the contactList where email equals to UPDATED_EMAIL - defaultContactShouldNotBeFound("email.in=" + UPDATED_EMAIL); - } - - @Test - @Transactional - public void getAllContactsByEmailIsNullOrNotNull() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where email is not null - defaultContactShouldBeFound("email.specified=true"); - - // Get all the contactList where email is null - defaultContactShouldNotBeFound("email.specified=false"); - } - - @Test - @Transactional - public void getAllContactsByRoleIsEqualToSomething() throws Exception { - // Initialize the database - CustomerContact role = CustomerContactResourceIntTest.createEntity(em); - em.persist(role); - em.flush(); - contact.addRole(role); - contactRepository.saveAndFlush(contact); - Long roleId = role.getId(); - - // Get all the contactList where role equals to roleId - defaultContactShouldBeFound("roleId.equals=" + roleId); - - // Get all the contactList where role equals to roleId + 1 - defaultContactShouldNotBeFound("roleId.equals=" + (roleId + 1)); - } - - /** - * Executes the search, and checks that the default entity is returned - */ - private void defaultContactShouldBeFound(String filter) throws Exception { - restContactMockMvc.perform(get("/api/contacts?sort=id,desc&" + filter)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.[*].id").value(hasItem(contact.getId().intValue()))) - .andExpect(jsonPath("$.[*].firstName").value(hasItem(DEFAULT_FIRST_NAME))) - .andExpect(jsonPath("$.[*].lastName").value(hasItem(DEFAULT_LAST_NAME))) - .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL))); - - // Check, that the count call also returns 1 - restContactMockMvc.perform(get("/api/contacts/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 defaultContactShouldNotBeFound(String filter) throws Exception { - restContactMockMvc.perform(get("/api/contacts?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 - restContactMockMvc.perform(get("/api/contacts/count?sort=id,desc&" + filter)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(content().string("0")); - } - - - @Test - @Transactional - public void getNonExistingContact() throws Exception { - // Get the contact - restContactMockMvc.perform(get("/api/contacts/{id}", Long.MAX_VALUE)) - .andExpect(status().isNotFound()); - } - - @Test - @Transactional - public void updateContact() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - int databaseSizeBeforeUpdate = contactRepository.findAll().size(); - - // Update the contact - Contact updatedContact = contactRepository.findById(contact.getId()).get(); - // Disconnect from session so that the updates on updatedContact are not directly saved in db - em.detach(updatedContact); - updatedContact - .firstName(UPDATED_FIRST_NAME) - .lastName(UPDATED_LAST_NAME) - .email(UPDATED_EMAIL); - ContactDTO contactDTO = contactMapper.toDto(updatedContact); - - restContactMockMvc.perform(put("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isOk()); - - // Validate the Contact in the database - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeUpdate); - Contact testContact = contactList.get(contactList.size() - 1); - assertThat(testContact.getFirstName()).isEqualTo(UPDATED_FIRST_NAME); - assertThat(testContact.getLastName()).isEqualTo(UPDATED_LAST_NAME); - assertThat(testContact.getEmail()).isEqualTo(UPDATED_EMAIL); - } - - @Test - @Transactional - public void updateNonExistingContact() throws Exception { - int databaseSizeBeforeUpdate = contactRepository.findAll().size(); - - // Create the Contact - ContactDTO contactDTO = contactMapper.toDto(contact); - - // If the entity doesn't have an ID, it will throw BadRequestAlertException - restContactMockMvc.perform(put("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - // Validate the Contact in the database - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeUpdate); - } - - @Test - @Transactional - public void deleteContact() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - int databaseSizeBeforeDelete = contactRepository.findAll().size(); - - // Delete the contact - restContactMockMvc.perform(delete("/api/contacts/{id}", contact.getId()) - .accept(TestUtil.APPLICATION_JSON_UTF8)) - .andExpect(status().isOk()); - - // Validate the database is empty - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeDelete - 1); - } - - @Test - @Transactional - public void equalsVerifier() throws Exception { - TestUtil.equalsVerifier(Contact.class); - Contact contact1 = new Contact(); - contact1.setId(1L); - Contact contact2 = new Contact(); - contact2.setId(contact1.getId()); - assertThat(contact1).isEqualTo(contact2); - contact2.setId(2L); - assertThat(contact1).isNotEqualTo(contact2); - contact1.setId(null); - assertThat(contact1).isNotEqualTo(contact2); - } - - @Test - @Transactional - public void dtoEqualsVerifier() throws Exception { - TestUtil.equalsVerifier(ContactDTO.class); - ContactDTO contactDTO1 = new ContactDTO(); - contactDTO1.setId(1L); - ContactDTO contactDTO2 = new ContactDTO(); - assertThat(contactDTO1).isNotEqualTo(contactDTO2); - contactDTO2.setId(contactDTO1.getId()); - assertThat(contactDTO1).isEqualTo(contactDTO2); - contactDTO2.setId(2L); - assertThat(contactDTO1).isNotEqualTo(contactDTO2); - contactDTO1.setId(null); - assertThat(contactDTO1).isNotEqualTo(contactDTO2); - } - - @Test - @Transactional - public void testEntityFromId() { - assertThat(contactMapper.fromId(42L).getId()).isEqualTo(42); - assertThat(contactMapper.fromId(null)).isNull(); - } -} diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java deleted file mode 100644 index 04097ed1..00000000 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java +++ /dev/null @@ -1,431 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; - -import org.hostsharing.hsadminng.HsadminNgApp; - -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.hostsharing.hsadminng.domain.Contact; -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.repository.CustomerContactRepository; -import org.hostsharing.hsadminng.service.CustomerContactService; -import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper; -import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria; -import org.hostsharing.hsadminng.service.CustomerContactQueryService; - -import org.junit.Before; -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.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.CustomerContactRole; -/** - * Test class for the CustomerContactResource REST controller. - * - * @see CustomerContactResource - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = HsadminNgApp.class) -public class CustomerContactResourceIntTest { - - private static final CustomerContactRole DEFAULT_ROLE = CustomerContactRole.CONTRACTUAL; - private static final CustomerContactRole UPDATED_ROLE = CustomerContactRole.TECHNICAL; - - @Autowired - private CustomerContactRepository customerContactRepository; - - @Autowired - private CustomerContactMapper customerContactMapper; - - @Autowired - private CustomerContactService customerContactService; - - @Autowired - private CustomerContactQueryService customerContactQueryService; - - @Autowired - private MappingJackson2HttpMessageConverter jacksonMessageConverter; - - @Autowired - private PageableHandlerMethodArgumentResolver pageableArgumentResolver; - - @Autowired - private ExceptionTranslator exceptionTranslator; - - @Autowired - private EntityManager em; - - @Autowired - private Validator validator; - - private MockMvc restCustomerContactMockMvc; - - private CustomerContact customerContact; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - final CustomerContactResource customerContactResource = new CustomerContactResource(customerContactService, customerContactQueryService); - this.restCustomerContactMockMvc = MockMvcBuilders.standaloneSetup(customerContactResource) - .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 CustomerContact createEntity(EntityManager em) { - CustomerContact customerContact = new CustomerContact() - .role(DEFAULT_ROLE); - // Add required entity - Contact contact = ContactResourceIntTest.createEntity(em); - em.persist(contact); - em.flush(); - customerContact.setContact(contact); - // Add required entity - Customer customer = CustomerResourceIntTest.createEntity(em); - em.persist(customer); - em.flush(); - customerContact.setCustomer(customer); - return customerContact; - } - - @Before - public void initTest() { - customerContact = createEntity(em); - } - - @Test - @Transactional - public void createCustomerContact() throws Exception { - int databaseSizeBeforeCreate = customerContactRepository.findAll().size(); - - // Create the CustomerContact - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact); - restCustomerContactMockMvc.perform(post("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isCreated()); - - // Validate the CustomerContact in the database - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeCreate + 1); - CustomerContact testCustomerContact = customerContactList.get(customerContactList.size() - 1); - assertThat(testCustomerContact.getRole()).isEqualTo(DEFAULT_ROLE); - } - - @Test - @Transactional - public void createCustomerContactWithExistingId() throws Exception { - int databaseSizeBeforeCreate = customerContactRepository.findAll().size(); - - // Create the CustomerContact with an existing ID - customerContact.setId(1L); - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact); - - // An entity with an existing ID cannot be created, so this API call must fail - restCustomerContactMockMvc.perform(post("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isBadRequest()); - - // Validate the CustomerContact in the database - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeCreate); - } - - @Test - @Transactional - public void checkRoleIsRequired() throws Exception { - int databaseSizeBeforeTest = customerContactRepository.findAll().size(); - // set the field null - customerContact.setRole(null); - - // Create the CustomerContact, which fails. - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact); - - restCustomerContactMockMvc.perform(post("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isBadRequest()); - - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeTest); - } - - @Test - @Transactional - public void getAllCustomerContacts() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get all the customerContactList - restCustomerContactMockMvc.perform(get("/api/customer-contacts?sort=id,desc")) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.[*].id").value(hasItem(customerContact.getId().intValue()))) - .andExpect(jsonPath("$.[*].role").value(hasItem(DEFAULT_ROLE.toString()))); - } - - @Test - @Transactional - public void getCustomerContact() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get the customerContact - restCustomerContactMockMvc.perform(get("/api/customer-contacts/{id}", customerContact.getId())) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.id").value(customerContact.getId().intValue())) - .andExpect(jsonPath("$.role").value(DEFAULT_ROLE.toString())); - } - - @Test - @Transactional - public void getAllCustomerContactsByRoleIsEqualToSomething() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get all the customerContactList where role equals to DEFAULT_ROLE - defaultCustomerContactShouldBeFound("role.equals=" + DEFAULT_ROLE); - - // Get all the customerContactList where role equals to UPDATED_ROLE - defaultCustomerContactShouldNotBeFound("role.equals=" + UPDATED_ROLE); - } - - @Test - @Transactional - public void getAllCustomerContactsByRoleIsInShouldWork() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get all the customerContactList where role in DEFAULT_ROLE or UPDATED_ROLE - defaultCustomerContactShouldBeFound("role.in=" + DEFAULT_ROLE + "," + UPDATED_ROLE); - - // Get all the customerContactList where role equals to UPDATED_ROLE - defaultCustomerContactShouldNotBeFound("role.in=" + UPDATED_ROLE); - } - - @Test - @Transactional - public void getAllCustomerContactsByRoleIsNullOrNotNull() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get all the customerContactList where role is not null - defaultCustomerContactShouldBeFound("role.specified=true"); - - // Get all the customerContactList where role is null - defaultCustomerContactShouldNotBeFound("role.specified=false"); - } - - @Test - @Transactional - public void getAllCustomerContactsByContactIsEqualToSomething() throws Exception { - // Initialize the database - Contact contact = ContactResourceIntTest.createEntity(em); - em.persist(contact); - em.flush(); - customerContact.setContact(contact); - customerContactRepository.saveAndFlush(customerContact); - Long contactId = contact.getId(); - - // Get all the customerContactList where contact equals to contactId - defaultCustomerContactShouldBeFound("contactId.equals=" + contactId); - - // Get all the customerContactList where contact equals to contactId + 1 - defaultCustomerContactShouldNotBeFound("contactId.equals=" + (contactId + 1)); - } - - - @Test - @Transactional - public void getAllCustomerContactsByCustomerIsEqualToSomething() throws Exception { - // Initialize the database - Customer customer = CustomerResourceIntTest.createEntity(em); - em.persist(customer); - em.flush(); - customerContact.setCustomer(customer); - customerContactRepository.saveAndFlush(customerContact); - Long customerId = customer.getId(); - - // Get all the customerContactList where customer equals to customerId - defaultCustomerContactShouldBeFound("customerId.equals=" + customerId); - - // Get all the customerContactList where customer equals to customerId + 1 - defaultCustomerContactShouldNotBeFound("customerId.equals=" + (customerId + 1)); - } - - /** - * Executes the search, and checks that the default entity is returned - */ - private void defaultCustomerContactShouldBeFound(String filter) throws Exception { - restCustomerContactMockMvc.perform(get("/api/customer-contacts?sort=id,desc&" + filter)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.[*].id").value(hasItem(customerContact.getId().intValue()))) - .andExpect(jsonPath("$.[*].role").value(hasItem(DEFAULT_ROLE.toString()))); - - // Check, that the count call also returns 1 - restCustomerContactMockMvc.perform(get("/api/customer-contacts/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 defaultCustomerContactShouldNotBeFound(String filter) throws Exception { - restCustomerContactMockMvc.perform(get("/api/customer-contacts?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 - restCustomerContactMockMvc.perform(get("/api/customer-contacts/count?sort=id,desc&" + filter)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(content().string("0")); - } - - - @Test - @Transactional - public void getNonExistingCustomerContact() throws Exception { - // Get the customerContact - restCustomerContactMockMvc.perform(get("/api/customer-contacts/{id}", Long.MAX_VALUE)) - .andExpect(status().isNotFound()); - } - - @Test - @Transactional - public void updateCustomerContact() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - int databaseSizeBeforeUpdate = customerContactRepository.findAll().size(); - - // Update the customerContact - CustomerContact updatedCustomerContact = customerContactRepository.findById(customerContact.getId()).get(); - // Disconnect from session so that the updates on updatedCustomerContact are not directly saved in db - em.detach(updatedCustomerContact); - updatedCustomerContact - .role(UPDATED_ROLE); - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(updatedCustomerContact); - - restCustomerContactMockMvc.perform(put("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isOk()); - - // Validate the CustomerContact in the database - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeUpdate); - CustomerContact testCustomerContact = customerContactList.get(customerContactList.size() - 1); - assertThat(testCustomerContact.getRole()).isEqualTo(UPDATED_ROLE); - } - - @Test - @Transactional - public void updateNonExistingCustomerContact() throws Exception { - int databaseSizeBeforeUpdate = customerContactRepository.findAll().size(); - - // Create the CustomerContact - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact); - - // If the entity doesn't have an ID, it will throw BadRequestAlertException - restCustomerContactMockMvc.perform(put("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isBadRequest()); - - // Validate the CustomerContact in the database - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeUpdate); - } - - @Test - @Transactional - public void deleteCustomerContact() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - int databaseSizeBeforeDelete = customerContactRepository.findAll().size(); - - // Delete the customerContact - restCustomerContactMockMvc.perform(delete("/api/customer-contacts/{id}", customerContact.getId()) - .accept(TestUtil.APPLICATION_JSON_UTF8)) - .andExpect(status().isOk()); - - // Validate the database is empty - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeDelete - 1); - } - - @Test - @Transactional - public void equalsVerifier() throws Exception { - TestUtil.equalsVerifier(CustomerContact.class); - CustomerContact customerContact1 = new CustomerContact(); - customerContact1.setId(1L); - CustomerContact customerContact2 = new CustomerContact(); - customerContact2.setId(customerContact1.getId()); - assertThat(customerContact1).isEqualTo(customerContact2); - customerContact2.setId(2L); - assertThat(customerContact1).isNotEqualTo(customerContact2); - customerContact1.setId(null); - assertThat(customerContact1).isNotEqualTo(customerContact2); - } - - @Test - @Transactional - public void dtoEqualsVerifier() throws Exception { - TestUtil.equalsVerifier(CustomerContactDTO.class); - CustomerContactDTO customerContactDTO1 = new CustomerContactDTO(); - customerContactDTO1.setId(1L); - CustomerContactDTO customerContactDTO2 = new CustomerContactDTO(); - assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2); - customerContactDTO2.setId(customerContactDTO1.getId()); - assertThat(customerContactDTO1).isEqualTo(customerContactDTO2); - customerContactDTO2.setId(2L); - assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2); - customerContactDTO1.setId(null); - assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2); - } - - @Test - @Transactional - public void testEntityFromId() { - assertThat(customerContactMapper.fromId(42L).getId()).isEqualTo(42); - assertThat(customerContactMapper.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 index d22cad45..a5b737c4 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java @@ -1,15 +1,18 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; + import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.CustomerContact; import org.hostsharing.hsadminng.domain.Membership; +import org.hostsharing.hsadminng.domain.SepaMandate; import org.hostsharing.hsadminng.repository.CustomerRepository; -import org.hostsharing.hsadminng.service.CustomerQueryService; import org.hostsharing.hsadminng.service.CustomerService; import org.hostsharing.hsadminng.service.dto.CustomerDTO; import org.hostsharing.hsadminng.service.mapper.CustomerMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.CustomerCriteria; +import org.hostsharing.hsadminng.service.CustomerQueryService; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,9 +31,10 @@ import org.springframework.validation.Validator; import javax.persistence.EntityManager; import java.util.List; + +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -46,24 +50,24 @@ public class CustomerResourceIntTest { private static final Integer DEFAULT_NUMBER = 10000; private static final Integer UPDATED_NUMBER = 10001; - private static final String DEFAULT_PREFIX = "lzv"; - private static final String UPDATED_PREFIX = "zf"; + private static final String DEFAULT_PREFIX = "nf"; + private static final String UPDATED_PREFIX = "m2"; private static final String DEFAULT_NAME = "AAAAAAAAAA"; private static final String UPDATED_NAME = "BBBBBBBBBB"; - private static final String DEFAULT_CONTRACTUAL_ADDRESS = "AAAAAAAAAA"; - private static final String UPDATED_CONTRACTUAL_ADDRESS = "BBBBBBBBBB"; - private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA"; private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB"; - private static final String DEFAULT_BILLING_ADDRESS = "AAAAAAAAAA"; - private static final String UPDATED_BILLING_ADDRESS = "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"; + @Autowired private CustomerRepository customerRepository; @@ -118,10 +122,10 @@ public class CustomerResourceIntTest { .number(DEFAULT_NUMBER) .prefix(DEFAULT_PREFIX) .name(DEFAULT_NAME) - .contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS) .contractualSalutation(DEFAULT_CONTRACTUAL_SALUTATION) - .billingAddress(DEFAULT_BILLING_ADDRESS) - .billingSalutation(DEFAULT_BILLING_SALUTATION); + .contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS) + .billingSalutation(DEFAULT_BILLING_SALUTATION) + .billingAddress(DEFAULT_BILLING_ADDRESS); return customer; } @@ -149,10 +153,10 @@ public class CustomerResourceIntTest { assertThat(testCustomer.getNumber()).isEqualTo(DEFAULT_NUMBER); assertThat(testCustomer.getPrefix()).isEqualTo(DEFAULT_PREFIX); assertThat(testCustomer.getName()).isEqualTo(DEFAULT_NAME); - assertThat(testCustomer.getContractualAddress()).isEqualTo(DEFAULT_CONTRACTUAL_ADDRESS); assertThat(testCustomer.getContractualSalutation()).isEqualTo(DEFAULT_CONTRACTUAL_SALUTATION); - assertThat(testCustomer.getBillingAddress()).isEqualTo(DEFAULT_BILLING_ADDRESS); + assertThat(testCustomer.getContractualAddress()).isEqualTo(DEFAULT_CONTRACTUAL_ADDRESS); assertThat(testCustomer.getBillingSalutation()).isEqualTo(DEFAULT_BILLING_SALUTATION); + assertThat(testCustomer.getBillingAddress()).isEqualTo(DEFAULT_BILLING_ADDRESS); } @Test @@ -265,10 +269,10 @@ public class CustomerResourceIntTest { .andExpect(jsonPath("$.[*].number").value(hasItem(DEFAULT_NUMBER))) .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX.toString()))) .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))) - .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS.toString()))) .andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION.toString()))) - .andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS.toString()))) - .andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_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()))); } @Test @@ -285,10 +289,10 @@ public class CustomerResourceIntTest { .andExpect(jsonPath("$.number").value(DEFAULT_NUMBER)) .andExpect(jsonPath("$.prefix").value(DEFAULT_PREFIX.toString())) .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())) - .andExpect(jsonPath("$.contractualAddress").value(DEFAULT_CONTRACTUAL_ADDRESS.toString())) .andExpect(jsonPath("$.contractualSalutation").value(DEFAULT_CONTRACTUAL_SALUTATION.toString())) - .andExpect(jsonPath("$.billingAddress").value(DEFAULT_BILLING_ADDRESS.toString())) - .andExpect(jsonPath("$.billingSalutation").value(DEFAULT_BILLING_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())); } @Test @@ -435,45 +439,6 @@ public class CustomerResourceIntTest { defaultCustomerShouldNotBeFound("name.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 getAllCustomersByContractualSalutationIsEqualToSomething() throws Exception { @@ -515,41 +480,41 @@ public class CustomerResourceIntTest { @Test @Transactional - public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception { + public void getAllCustomersByContractualAddressIsEqualToSomething() 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 contractualAddress equals to DEFAULT_CONTRACTUAL_ADDRESS + defaultCustomerShouldBeFound("contractualAddress.equals=" + DEFAULT_CONTRACTUAL_ADDRESS); - // Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS - defaultCustomerShouldNotBeFound("billingAddress.equals=" + UPDATED_BILLING_ADDRESS); + // Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldNotBeFound("contractualAddress.equals=" + UPDATED_CONTRACTUAL_ADDRESS); } @Test @Transactional - public void getAllCustomersByBillingAddressIsInShouldWork() throws Exception { + public void getAllCustomersByContractualAddressIsInShouldWork() 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 contractualAddress in DEFAULT_CONTRACTUAL_ADDRESS or UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldBeFound("contractualAddress.in=" + DEFAULT_CONTRACTUAL_ADDRESS + "," + UPDATED_CONTRACTUAL_ADDRESS); - // Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS - defaultCustomerShouldNotBeFound("billingAddress.in=" + UPDATED_BILLING_ADDRESS); + // Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldNotBeFound("contractualAddress.in=" + UPDATED_CONTRACTUAL_ADDRESS); } @Test @Transactional - public void getAllCustomersByBillingAddressIsNullOrNotNull() throws Exception { + public void getAllCustomersByContractualAddressIsNullOrNotNull() 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 contractualAddress is not null + defaultCustomerShouldBeFound("contractualAddress.specified=true"); - // Get all the customerList where billingAddress is null - defaultCustomerShouldNotBeFound("billingAddress.specified=false"); + // Get all the customerList where contractualAddress is null + defaultCustomerShouldNotBeFound("contractualAddress.specified=false"); } @Test @@ -593,22 +558,42 @@ public class CustomerResourceIntTest { @Test @Transactional - public void getAllCustomersByRoleIsEqualToSomething() throws Exception { + public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception { // Initialize the database - CustomerContact role = CustomerContactResourceIntTest.createEntity(em); - em.persist(role); - em.flush(); - customer.addRole(role); customerRepository.saveAndFlush(customer); - Long roleId = role.getId(); - // Get all the customerList where role equals to roleId - defaultCustomerShouldBeFound("roleId.equals=" + roleId); + // Get all the customerList where billingAddress equals to DEFAULT_BILLING_ADDRESS + defaultCustomerShouldBeFound("billingAddress.equals=" + DEFAULT_BILLING_ADDRESS); - // Get all the customerList where role equals to roleId + 1 - defaultCustomerShouldNotBeFound("roleId.equals=" + (roleId + 1)); + // 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 @@ -628,6 +613,25 @@ public class CustomerResourceIntTest { 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 */ @@ -639,10 +643,10 @@ public class CustomerResourceIntTest { .andExpect(jsonPath("$.[*].number").value(hasItem(DEFAULT_NUMBER))) .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX))) .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))) - .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS))) .andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION))) - .andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS))) - .andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_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))); // Check, that the count call also returns 1 restCustomerMockMvc.perform(get("/api/customers/count?sort=id,desc&" + filter)) @@ -693,10 +697,10 @@ public class CustomerResourceIntTest { .number(UPDATED_NUMBER) .prefix(UPDATED_PREFIX) .name(UPDATED_NAME) - .contractualAddress(UPDATED_CONTRACTUAL_ADDRESS) .contractualSalutation(UPDATED_CONTRACTUAL_SALUTATION) - .billingAddress(UPDATED_BILLING_ADDRESS) - .billingSalutation(UPDATED_BILLING_SALUTATION); + .contractualAddress(UPDATED_CONTRACTUAL_ADDRESS) + .billingSalutation(UPDATED_BILLING_SALUTATION) + .billingAddress(UPDATED_BILLING_ADDRESS); CustomerDTO customerDTO = customerMapper.toDto(updatedCustomer); restCustomerMockMvc.perform(put("/api/customers") @@ -711,10 +715,10 @@ public class CustomerResourceIntTest { assertThat(testCustomer.getNumber()).isEqualTo(UPDATED_NUMBER); assertThat(testCustomer.getPrefix()).isEqualTo(UPDATED_PREFIX); assertThat(testCustomer.getName()).isEqualTo(UPDATED_NAME); - assertThat(testCustomer.getContractualAddress()).isEqualTo(UPDATED_CONTRACTUAL_ADDRESS); assertThat(testCustomer.getContractualSalutation()).isEqualTo(UPDATED_CONTRACTUAL_SALUTATION); - assertThat(testCustomer.getBillingAddress()).isEqualTo(UPDATED_BILLING_ADDRESS); + assertThat(testCustomer.getContractualAddress()).isEqualTo(UPDATED_CONTRACTUAL_ADDRESS); assertThat(testCustomer.getBillingSalutation()).isEqualTo(UPDATED_BILLING_SALUTATION); + assertThat(testCustomer.getBillingAddress()).isEqualTo(UPDATED_BILLING_ADDRESS); } @Test diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java index 97b8eed0..2e7ac3e3 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java @@ -1,16 +1,19 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; -import org.hostsharing.hsadminng.domain.Asset; -import org.hostsharing.hsadminng.domain.Customer; + import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.domain.Share; +import org.hostsharing.hsadminng.domain.Asset; +import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.repository.MembershipRepository; -import org.hostsharing.hsadminng.service.MembershipQueryService; import org.hostsharing.hsadminng.service.MembershipService; import org.hostsharing.hsadminng.service.dto.MembershipDTO; import org.hostsharing.hsadminng.service.mapper.MembershipMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.MembershipCriteria; +import org.hostsharing.hsadminng.service.MembershipQueryService; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,9 +34,10 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; + +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -46,11 +50,14 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(classes = HsadminNgApp.class) public class MembershipResourceIntTest { - private static final LocalDate DEFAULT_SINCE_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_SINCE_DATE = LocalDate.now(ZoneId.systemDefault()); + private static final LocalDate DEFAULT_FROM = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_FROM = LocalDate.now(ZoneId.systemDefault()); - private static final LocalDate DEFAULT_UNTIL_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault()); + private static final LocalDate DEFAULT_TO = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_TO = LocalDate.now(ZoneId.systemDefault()); + + private static final String DEFAULT_COMMENT = "AAAAAAAAAA"; + private static final String UPDATED_COMMENT = "BBBBBBBBBB"; @Autowired private MembershipRepository membershipRepository; @@ -103,8 +110,9 @@ public class MembershipResourceIntTest { */ public static Membership createEntity(EntityManager em) { Membership membership = new Membership() - .sinceDate(DEFAULT_SINCE_DATE) - .untilDate(DEFAULT_UNTIL_DATE); + .from(DEFAULT_FROM) + .to(DEFAULT_TO) + .comment(DEFAULT_COMMENT); // Add required entity Customer customer = CustomerResourceIntTest.createEntity(em); em.persist(customer); @@ -134,8 +142,9 @@ public class MembershipResourceIntTest { List membershipList = membershipRepository.findAll(); assertThat(membershipList).hasSize(databaseSizeBeforeCreate + 1); Membership testMembership = membershipList.get(membershipList.size() - 1); - assertThat(testMembership.getSinceDate()).isEqualTo(DEFAULT_SINCE_DATE); - assertThat(testMembership.getUntilDate()).isEqualTo(DEFAULT_UNTIL_DATE); + assertThat(testMembership.getFrom()).isEqualTo(DEFAULT_FROM); + assertThat(testMembership.getTo()).isEqualTo(DEFAULT_TO); + assertThat(testMembership.getComment()).isEqualTo(DEFAULT_COMMENT); } @Test @@ -160,10 +169,10 @@ public class MembershipResourceIntTest { @Test @Transactional - public void checkSinceDateIsRequired() throws Exception { + public void checkFromIsRequired() throws Exception { int databaseSizeBeforeTest = membershipRepository.findAll().size(); // set the field null - membership.setSinceDate(null); + membership.setFrom(null); // Create the Membership, which fails. MembershipDTO membershipDTO = membershipMapper.toDto(membership); @@ -188,8 +197,9 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue()))) - .andExpect(jsonPath("$.[*].sinceDate").value(hasItem(DEFAULT_SINCE_DATE.toString()))) - .andExpect(jsonPath("$.[*].untilDate").value(hasItem(DEFAULT_UNTIL_DATE.toString()))); + .andExpect(jsonPath("$.[*].from").value(hasItem(DEFAULT_FROM.toString()))) + .andExpect(jsonPath("$.[*].to").value(hasItem(DEFAULT_TO.toString()))) + .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT.toString()))); } @Test @@ -203,142 +213,182 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(membership.getId().intValue())) - .andExpect(jsonPath("$.sinceDate").value(DEFAULT_SINCE_DATE.toString())) - .andExpect(jsonPath("$.untilDate").value(DEFAULT_UNTIL_DATE.toString())); + .andExpect(jsonPath("$.from").value(DEFAULT_FROM.toString())) + .andExpect(jsonPath("$.to").value(DEFAULT_TO.toString())) + .andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT.toString())); } @Test @Transactional - public void getAllMembershipsBySinceDateIsEqualToSomething() throws Exception { + public void getAllMembershipsByFromIsEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate equals to DEFAULT_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.equals=" + DEFAULT_SINCE_DATE); + // Get all the membershipList where from equals to DEFAULT_FROM + defaultMembershipShouldBeFound("from.equals=" + DEFAULT_FROM); - // Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.equals=" + UPDATED_SINCE_DATE); + // Get all the membershipList where from equals to UPDATED_FROM + defaultMembershipShouldNotBeFound("from.equals=" + UPDATED_FROM); } @Test @Transactional - public void getAllMembershipsBySinceDateIsInShouldWork() throws Exception { + public void getAllMembershipsByFromIsInShouldWork() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate in DEFAULT_SINCE_DATE or UPDATED_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.in=" + DEFAULT_SINCE_DATE + "," + UPDATED_SINCE_DATE); + // Get all the membershipList where from in DEFAULT_FROM or UPDATED_FROM + defaultMembershipShouldBeFound("from.in=" + DEFAULT_FROM + "," + UPDATED_FROM); - // Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.in=" + UPDATED_SINCE_DATE); + // Get all the membershipList where from equals to UPDATED_FROM + defaultMembershipShouldNotBeFound("from.in=" + UPDATED_FROM); } @Test @Transactional - public void getAllMembershipsBySinceDateIsNullOrNotNull() throws Exception { + public void getAllMembershipsByFromIsNullOrNotNull() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate is not null - defaultMembershipShouldBeFound("sinceDate.specified=true"); + // Get all the membershipList where from is not null + defaultMembershipShouldBeFound("from.specified=true"); - // Get all the membershipList where sinceDate is null - defaultMembershipShouldNotBeFound("sinceDate.specified=false"); + // Get all the membershipList where from is null + defaultMembershipShouldNotBeFound("from.specified=false"); } @Test @Transactional - public void getAllMembershipsBySinceDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllMembershipsByFromIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate greater than or equals to DEFAULT_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.greaterOrEqualThan=" + DEFAULT_SINCE_DATE); + // Get all the membershipList where from greater than or equals to DEFAULT_FROM + defaultMembershipShouldBeFound("from.greaterOrEqualThan=" + DEFAULT_FROM); - // Get all the membershipList where sinceDate greater than or equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.greaterOrEqualThan=" + UPDATED_SINCE_DATE); + // Get all the membershipList where from greater than or equals to UPDATED_FROM + defaultMembershipShouldNotBeFound("from.greaterOrEqualThan=" + UPDATED_FROM); } @Test @Transactional - public void getAllMembershipsBySinceDateIsLessThanSomething() throws Exception { + public void getAllMembershipsByFromIsLessThanSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate less than or equals to DEFAULT_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.lessThan=" + DEFAULT_SINCE_DATE); + // Get all the membershipList where from less than or equals to DEFAULT_FROM + defaultMembershipShouldNotBeFound("from.lessThan=" + DEFAULT_FROM); - // Get all the membershipList where sinceDate less than or equals to UPDATED_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.lessThan=" + UPDATED_SINCE_DATE); + // Get all the membershipList where from less than or equals to UPDATED_FROM + defaultMembershipShouldBeFound("from.lessThan=" + UPDATED_FROM); } @Test @Transactional - public void getAllMembershipsByUntilDateIsEqualToSomething() throws Exception { + public void getAllMembershipsByToIsEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.equals=" + DEFAULT_UNTIL_DATE); + // Get all the membershipList where to equals to DEFAULT_TO + defaultMembershipShouldBeFound("to.equals=" + DEFAULT_TO); - // Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.equals=" + UPDATED_UNTIL_DATE); + // Get all the membershipList where to equals to UPDATED_TO + defaultMembershipShouldNotBeFound("to.equals=" + UPDATED_TO); } @Test @Transactional - public void getAllMembershipsByUntilDateIsInShouldWork() throws Exception { + public void getAllMembershipsByToIsInShouldWork() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate in DEFAULT_UNTIL_DATE or UPDATED_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.in=" + DEFAULT_UNTIL_DATE + "," + UPDATED_UNTIL_DATE); + // Get all the membershipList where to in DEFAULT_TO or UPDATED_TO + defaultMembershipShouldBeFound("to.in=" + DEFAULT_TO + "," + UPDATED_TO); - // Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.in=" + UPDATED_UNTIL_DATE); + // Get all the membershipList where to equals to UPDATED_TO + defaultMembershipShouldNotBeFound("to.in=" + UPDATED_TO); } @Test @Transactional - public void getAllMembershipsByUntilDateIsNullOrNotNull() throws Exception { + public void getAllMembershipsByToIsNullOrNotNull() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate is not null - defaultMembershipShouldBeFound("untilDate.specified=true"); + // Get all the membershipList where to is not null + defaultMembershipShouldBeFound("to.specified=true"); - // Get all the membershipList where untilDate is null - defaultMembershipShouldNotBeFound("untilDate.specified=false"); + // Get all the membershipList where to is null + defaultMembershipShouldNotBeFound("to.specified=false"); } @Test @Transactional - public void getAllMembershipsByUntilDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllMembershipsByToIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate greater than or equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.greaterOrEqualThan=" + DEFAULT_UNTIL_DATE); + // Get all the membershipList where to greater than or equals to DEFAULT_TO + defaultMembershipShouldBeFound("to.greaterOrEqualThan=" + DEFAULT_TO); - // Get all the membershipList where untilDate greater than or equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.greaterOrEqualThan=" + UPDATED_UNTIL_DATE); + // Get all the membershipList where to greater than or equals to UPDATED_TO + defaultMembershipShouldNotBeFound("to.greaterOrEqualThan=" + UPDATED_TO); } @Test @Transactional - public void getAllMembershipsByUntilDateIsLessThanSomething() throws Exception { + public void getAllMembershipsByToIsLessThanSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate less than or equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.lessThan=" + DEFAULT_UNTIL_DATE); + // Get all the membershipList where to less than or equals to DEFAULT_TO + defaultMembershipShouldNotBeFound("to.lessThan=" + DEFAULT_TO); - // Get all the membershipList where untilDate less than or equals to UPDATED_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.lessThan=" + UPDATED_UNTIL_DATE); + // Get all the membershipList where to less than or equals to UPDATED_TO + defaultMembershipShouldBeFound("to.lessThan=" + UPDATED_TO); } + @Test + @Transactional + public void getAllMembershipsByCommentIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where comment equals to DEFAULT_COMMENT + defaultMembershipShouldBeFound("comment.equals=" + DEFAULT_COMMENT); + + // Get all the membershipList where comment equals to UPDATED_COMMENT + defaultMembershipShouldNotBeFound("comment.equals=" + UPDATED_COMMENT); + } + + @Test + @Transactional + public void getAllMembershipsByCommentIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where comment in DEFAULT_COMMENT or UPDATED_COMMENT + defaultMembershipShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT); + + // Get all the membershipList where comment equals to UPDATED_COMMENT + defaultMembershipShouldNotBeFound("comment.in=" + UPDATED_COMMENT); + } + + @Test + @Transactional + public void getAllMembershipsByCommentIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where comment is not null + defaultMembershipShouldBeFound("comment.specified=true"); + + // Get all the membershipList where comment is null + defaultMembershipShouldNotBeFound("comment.specified=false"); + } + @Test @Transactional public void getAllMembershipsByShareIsEqualToSomething() throws Exception { @@ -403,8 +453,9 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue()))) - .andExpect(jsonPath("$.[*].sinceDate").value(hasItem(DEFAULT_SINCE_DATE.toString()))) - .andExpect(jsonPath("$.[*].untilDate").value(hasItem(DEFAULT_UNTIL_DATE.toString()))); + .andExpect(jsonPath("$.[*].from").value(hasItem(DEFAULT_FROM.toString()))) + .andExpect(jsonPath("$.[*].to").value(hasItem(DEFAULT_TO.toString()))) + .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT))); // Check, that the count call also returns 1 restMembershipMockMvc.perform(get("/api/memberships/count?sort=id,desc&" + filter)) @@ -452,8 +503,9 @@ public class MembershipResourceIntTest { // Disconnect from session so that the updates on updatedMembership are not directly saved in db em.detach(updatedMembership); updatedMembership - .sinceDate(UPDATED_SINCE_DATE) - .untilDate(UPDATED_UNTIL_DATE); + .from(UPDATED_FROM) + .to(UPDATED_TO) + .comment(UPDATED_COMMENT); MembershipDTO membershipDTO = membershipMapper.toDto(updatedMembership); restMembershipMockMvc.perform(put("/api/memberships") @@ -465,8 +517,9 @@ public class MembershipResourceIntTest { List membershipList = membershipRepository.findAll(); assertThat(membershipList).hasSize(databaseSizeBeforeUpdate); Membership testMembership = membershipList.get(membershipList.size() - 1); - assertThat(testMembership.getSinceDate()).isEqualTo(UPDATED_SINCE_DATE); - assertThat(testMembership.getUntilDate()).isEqualTo(UPDATED_UNTIL_DATE); + assertThat(testMembership.getFrom()).isEqualTo(UPDATED_FROM); + assertThat(testMembership.getTo()).isEqualTo(UPDATED_TO); + assertThat(testMembership.getComment()).isEqualTo(UPDATED_COMMENT); } @Test diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java new file mode 100644 index 00000000..1238d6f6 --- /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_CREATED = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_CREATED = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_VALID_FROM = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_FROM = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_VALID_TO = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_TO = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_LAST_USED = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_LAST_USED = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_CANCELLED = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_CANCELLED = LocalDate.now(ZoneId.systemDefault()); + + private static final String DEFAULT_COMMENT = "AAAAAAAAAA"; + private static final String UPDATED_COMMENT = "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) + .created(DEFAULT_CREATED) + .validFrom(DEFAULT_VALID_FROM) + .validTo(DEFAULT_VALID_TO) + .lastUsed(DEFAULT_LAST_USED) + .cancelled(DEFAULT_CANCELLED) + .comment(DEFAULT_COMMENT); + // 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.getCreated()).isEqualTo(DEFAULT_CREATED); + assertThat(testSepaMandate.getValidFrom()).isEqualTo(DEFAULT_VALID_FROM); + assertThat(testSepaMandate.getValidTo()).isEqualTo(DEFAULT_VALID_TO); + assertThat(testSepaMandate.getLastUsed()).isEqualTo(DEFAULT_LAST_USED); + assertThat(testSepaMandate.getCancelled()).isEqualTo(DEFAULT_CANCELLED); + assertThat(testSepaMandate.getComment()).isEqualTo(DEFAULT_COMMENT); + } + + @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 checkCreatedIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setCreated(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 checkValidFromIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setValidFrom(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("$.[*].created").value(hasItem(DEFAULT_CREATED.toString()))) + .andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString()))) + .andExpect(jsonPath("$.[*].validTo").value(hasItem(DEFAULT_VALID_TO.toString()))) + .andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString()))) + .andExpect(jsonPath("$.[*].cancelled").value(hasItem(DEFAULT_CANCELLED.toString()))) + .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT.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("$.created").value(DEFAULT_CREATED.toString())) + .andExpect(jsonPath("$.validFrom").value(DEFAULT_VALID_FROM.toString())) + .andExpect(jsonPath("$.validTo").value(DEFAULT_VALID_TO.toString())) + .andExpect(jsonPath("$.lastUsed").value(DEFAULT_LAST_USED.toString())) + .andExpect(jsonPath("$.cancelled").value(DEFAULT_CANCELLED.toString())) + .andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT.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 getAllSepaMandatesByCreatedIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where created equals to DEFAULT_CREATED + defaultSepaMandateShouldBeFound("created.equals=" + DEFAULT_CREATED); + + // Get all the sepaMandateList where created equals to UPDATED_CREATED + defaultSepaMandateShouldNotBeFound("created.equals=" + UPDATED_CREATED); + } + + @Test + @Transactional + public void getAllSepaMandatesByCreatedIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where created in DEFAULT_CREATED or UPDATED_CREATED + defaultSepaMandateShouldBeFound("created.in=" + DEFAULT_CREATED + "," + UPDATED_CREATED); + + // Get all the sepaMandateList where created equals to UPDATED_CREATED + defaultSepaMandateShouldNotBeFound("created.in=" + UPDATED_CREATED); + } + + @Test + @Transactional + public void getAllSepaMandatesByCreatedIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where created is not null + defaultSepaMandateShouldBeFound("created.specified=true"); + + // Get all the sepaMandateList where created is null + defaultSepaMandateShouldNotBeFound("created.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByCreatedIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where created greater than or equals to DEFAULT_CREATED + defaultSepaMandateShouldBeFound("created.greaterOrEqualThan=" + DEFAULT_CREATED); + + // Get all the sepaMandateList where created greater than or equals to UPDATED_CREATED + defaultSepaMandateShouldNotBeFound("created.greaterOrEqualThan=" + UPDATED_CREATED); + } + + @Test + @Transactional + public void getAllSepaMandatesByCreatedIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where created less than or equals to DEFAULT_CREATED + defaultSepaMandateShouldNotBeFound("created.lessThan=" + DEFAULT_CREATED); + + // Get all the sepaMandateList where created less than or equals to UPDATED_CREATED + defaultSepaMandateShouldBeFound("created.lessThan=" + UPDATED_CREATED); + } + + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.equals=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.equals=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom in DEFAULT_VALID_FROM or UPDATED_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.in=" + DEFAULT_VALID_FROM + "," + UPDATED_VALID_FROM); + + // Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.in=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom is not null + defaultSepaMandateShouldBeFound("validFrom.specified=true"); + + // Get all the sepaMandateList where validFrom is null + defaultSepaMandateShouldNotBeFound("validFrom.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom greater than or equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.greaterOrEqualThan=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom greater than or equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.greaterOrEqualThan=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom less than or equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.lessThan=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom less than or equals to UPDATED_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.lessThan=" + UPDATED_VALID_FROM); + } + + + @Test + @Transactional + public void getAllSepaMandatesByValidToIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validTo equals to DEFAULT_VALID_TO + defaultSepaMandateShouldBeFound("validTo.equals=" + DEFAULT_VALID_TO); + + // Get all the sepaMandateList where validTo equals to UPDATED_VALID_TO + defaultSepaMandateShouldNotBeFound("validTo.equals=" + UPDATED_VALID_TO); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidToIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validTo in DEFAULT_VALID_TO or UPDATED_VALID_TO + defaultSepaMandateShouldBeFound("validTo.in=" + DEFAULT_VALID_TO + "," + UPDATED_VALID_TO); + + // Get all the sepaMandateList where validTo equals to UPDATED_VALID_TO + defaultSepaMandateShouldNotBeFound("validTo.in=" + UPDATED_VALID_TO); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidToIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validTo is not null + defaultSepaMandateShouldBeFound("validTo.specified=true"); + + // Get all the sepaMandateList where validTo is null + defaultSepaMandateShouldNotBeFound("validTo.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidToIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validTo greater than or equals to DEFAULT_VALID_TO + defaultSepaMandateShouldBeFound("validTo.greaterOrEqualThan=" + DEFAULT_VALID_TO); + + // Get all the sepaMandateList where validTo greater than or equals to UPDATED_VALID_TO + defaultSepaMandateShouldNotBeFound("validTo.greaterOrEqualThan=" + UPDATED_VALID_TO); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidToIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validTo less than or equals to DEFAULT_VALID_TO + defaultSepaMandateShouldNotBeFound("validTo.lessThan=" + DEFAULT_VALID_TO); + + // Get all the sepaMandateList where validTo less than or equals to UPDATED_VALID_TO + defaultSepaMandateShouldBeFound("validTo.lessThan=" + UPDATED_VALID_TO); + } + + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed equals to DEFAULT_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.equals=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.equals=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed in DEFAULT_LAST_USED or UPDATED_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.in=" + DEFAULT_LAST_USED + "," + UPDATED_LAST_USED); + + // Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.in=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed is not null + defaultSepaMandateShouldBeFound("lastUsed.specified=true"); + + // Get all the sepaMandateList where lastUsed is null + defaultSepaMandateShouldNotBeFound("lastUsed.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed greater than or equals to DEFAULT_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.greaterOrEqualThan=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed greater than or equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.greaterOrEqualThan=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed less than or equals to DEFAULT_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.lessThan=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed less than or equals to UPDATED_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.lessThan=" + UPDATED_LAST_USED); + } + + + @Test + @Transactional + public void getAllSepaMandatesByCancelledIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancelled equals to DEFAULT_CANCELLED + defaultSepaMandateShouldBeFound("cancelled.equals=" + DEFAULT_CANCELLED); + + // Get all the sepaMandateList where cancelled equals to UPDATED_CANCELLED + defaultSepaMandateShouldNotBeFound("cancelled.equals=" + UPDATED_CANCELLED); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancelledIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancelled in DEFAULT_CANCELLED or UPDATED_CANCELLED + defaultSepaMandateShouldBeFound("cancelled.in=" + DEFAULT_CANCELLED + "," + UPDATED_CANCELLED); + + // Get all the sepaMandateList where cancelled equals to UPDATED_CANCELLED + defaultSepaMandateShouldNotBeFound("cancelled.in=" + UPDATED_CANCELLED); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancelledIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancelled is not null + defaultSepaMandateShouldBeFound("cancelled.specified=true"); + + // Get all the sepaMandateList where cancelled is null + defaultSepaMandateShouldNotBeFound("cancelled.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancelledIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancelled greater than or equals to DEFAULT_CANCELLED + defaultSepaMandateShouldBeFound("cancelled.greaterOrEqualThan=" + DEFAULT_CANCELLED); + + // Get all the sepaMandateList where cancelled greater than or equals to UPDATED_CANCELLED + defaultSepaMandateShouldNotBeFound("cancelled.greaterOrEqualThan=" + UPDATED_CANCELLED); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancelledIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancelled less than or equals to DEFAULT_CANCELLED + defaultSepaMandateShouldNotBeFound("cancelled.lessThan=" + DEFAULT_CANCELLED); + + // Get all the sepaMandateList where cancelled less than or equals to UPDATED_CANCELLED + defaultSepaMandateShouldBeFound("cancelled.lessThan=" + UPDATED_CANCELLED); + } + + + @Test + @Transactional + public void getAllSepaMandatesByCommentIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where comment equals to DEFAULT_COMMENT + defaultSepaMandateShouldBeFound("comment.equals=" + DEFAULT_COMMENT); + + // Get all the sepaMandateList where comment equals to UPDATED_COMMENT + defaultSepaMandateShouldNotBeFound("comment.equals=" + UPDATED_COMMENT); + } + + @Test + @Transactional + public void getAllSepaMandatesByCommentIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where comment in DEFAULT_COMMENT or UPDATED_COMMENT + defaultSepaMandateShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT); + + // Get all the sepaMandateList where comment equals to UPDATED_COMMENT + defaultSepaMandateShouldNotBeFound("comment.in=" + UPDATED_COMMENT); + } + + @Test + @Transactional + public void getAllSepaMandatesByCommentIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where comment is not null + defaultSepaMandateShouldBeFound("comment.specified=true"); + + // Get all the sepaMandateList where comment is null + defaultSepaMandateShouldNotBeFound("comment.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("$.[*].created").value(hasItem(DEFAULT_CREATED.toString()))) + .andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString()))) + .andExpect(jsonPath("$.[*].validTo").value(hasItem(DEFAULT_VALID_TO.toString()))) + .andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString()))) + .andExpect(jsonPath("$.[*].cancelled").value(hasItem(DEFAULT_CANCELLED.toString()))) + .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT))); + + // 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) + .created(UPDATED_CREATED) + .validFrom(UPDATED_VALID_FROM) + .validTo(UPDATED_VALID_TO) + .lastUsed(UPDATED_LAST_USED) + .cancelled(UPDATED_CANCELLED) + .comment(UPDATED_COMMENT); + 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.getCreated()).isEqualTo(UPDATED_CREATED); + assertThat(testSepaMandate.getValidFrom()).isEqualTo(UPDATED_VALID_FROM); + assertThat(testSepaMandate.getValidTo()).isEqualTo(UPDATED_VALID_TO); + assertThat(testSepaMandate.getLastUsed()).isEqualTo(UPDATED_LAST_USED); + assertThat(testSepaMandate.getCancelled()).isEqualTo(UPDATED_CANCELLED); + assertThat(testSepaMandate.getComment()).isEqualTo(UPDATED_COMMENT); + } + + @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 index 44aa1dca..202f8229 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java @@ -1,15 +1,17 @@ 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.enumeration.ShareAction; +import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.repository.ShareRepository; -import org.hostsharing.hsadminng.service.ShareQueryService; import org.hostsharing.hsadminng.service.ShareService; import org.hostsharing.hsadminng.service.dto.ShareDTO; import org.hostsharing.hsadminng.service.mapper.ShareMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.ShareCriteria; +import org.hostsharing.hsadminng.service.ShareQueryService; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,11 +32,14 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; + +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; /** * Test class for the ShareResource REST controller. * @@ -115,7 +120,7 @@ public class ShareResourceIntTest { Membership membership = MembershipResourceIntTest.createEntity(em); em.persist(membership); em.flush(); - share.setMember(membership); + share.setMembership(membership); return share; } @@ -469,20 +474,20 @@ public class ShareResourceIntTest { @Test @Transactional - public void getAllSharesByMemberIsEqualToSomething() throws Exception { + public void getAllSharesByMembershipIsEqualToSomething() throws Exception { // Initialize the database - Membership member = MembershipResourceIntTest.createEntity(em); - em.persist(member); + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); em.flush(); - share.setMember(member); + share.setMembership(membership); shareRepository.saveAndFlush(share); - Long memberId = member.getId(); + Long membershipId = membership.getId(); - // Get all the shareList where member equals to memberId - defaultShareShouldBeFound("memberId.equals=" + memberId); + // Get all the shareList where membership equals to membershipId + defaultShareShouldBeFound("membershipId.equals=" + membershipId); - // Get all the shareList where member equals to memberId + 1 - defaultShareShouldNotBeFound("memberId.equals=" + (memberId + 1)); + // Get all the shareList where membership equals to membershipId + 1 + defaultShareShouldNotBeFound("membershipId.equals=" + (membershipId + 1)); } /** 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 index 0278f8ab..20bcdf53 100644 --- 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 @@ -1,7 +1,7 @@ /* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; import { AssetUpdateComponent } from 'app/entities/asset/asset-update.component'; diff --git a/src/test/javascript/spec/app/entities/contact/contact.service.spec.ts b/src/test/javascript/spec/app/entities/contact/contact.service.spec.ts deleted file mode 100644 index 5e912840..00000000 --- a/src/test/javascript/spec/app/entities/contact/contact.service.spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* 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 { ContactService } from 'app/entities/contact/contact.service'; -import { IContact, Contact } from 'app/shared/model/contact.model'; - -describe('Service Tests', () => { - describe('Contact Service', () => { - let injector: TestBed; - let service: ContactService; - let httpMock: HttpTestingController; - let elemDefault: IContact; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] - }); - injector = getTestBed(); - service = injector.get(ContactService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new Contact(0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA'); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, 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 Contact', async () => { - const returnedFromService = Object.assign( - { - id: 0 - }, - elemDefault - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new Contact(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 Contact', async () => { - const returnedFromService = Object.assign( - { - firstName: 'BBBBBB', - lastName: 'BBBBBB', - email: 'BBBBBB' - }, - elemDefault - ); - - const expected = Object.assign({}, 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 Contact', async () => { - const returnedFromService = Object.assign( - { - firstName: 'BBBBBB', - lastName: 'BBBBBB', - email: 'BBBBBB' - }, - elemDefault - ); - const expected = Object.assign({}, 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 Contact', 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-contact/customer-contact-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact-delete-dialog.component.spec.ts deleted file mode 100644 index 57ab1ea5..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 { CustomerContactDeleteDialogComponent } from 'app/entities/customer-contact/customer-contact-delete-dialog.component'; -import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service'; - -describe('Component Tests', () => { - describe('CustomerContact Management Delete Component', () => { - let comp: CustomerContactDeleteDialogComponent; - let fixture: ComponentFixture; - let service: CustomerContactService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [CustomerContactDeleteDialogComponent] - }) - .overrideTemplate(CustomerContactDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(CustomerContactDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CustomerContactService); - 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-contact/customer-contact-detail.component.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact-detail.component.spec.ts deleted file mode 100644 index 54e11abc..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 { CustomerContactDetailComponent } from 'app/entities/customer-contact/customer-contact-detail.component'; -import { CustomerContact } from 'app/shared/model/customer-contact.model'; - -describe('Component Tests', () => { - describe('CustomerContact Management Detail Component', () => { - let comp: CustomerContactDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ customerContact: new CustomerContact(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [CustomerContactDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }] - }) - .overrideTemplate(CustomerContactDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(CustomerContactDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.customerContact).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/customer-contact/customer-contact-update.component.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact-update.component.spec.ts deleted file mode 100644 index 9c73dbb8..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* 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 { CustomerContactUpdateComponent } from 'app/entities/customer-contact/customer-contact-update.component'; -import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service'; -import { CustomerContact } from 'app/shared/model/customer-contact.model'; - -describe('Component Tests', () => { - describe('CustomerContact Management Update Component', () => { - let comp: CustomerContactUpdateComponent; - let fixture: ComponentFixture; - let service: CustomerContactService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [CustomerContactUpdateComponent] - }) - .overrideTemplate(CustomerContactUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(CustomerContactUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CustomerContactService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new CustomerContact(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.customerContact = 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 CustomerContact(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.customerContact = 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-contact/customer-contact.component.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact.component.spec.ts deleted file mode 100644 index 1d0649ef..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact.component.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 { CustomerContactComponent } from 'app/entities/customer-contact/customer-contact.component'; -import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service'; -import { CustomerContact } from 'app/shared/model/customer-contact.model'; - -describe('Component Tests', () => { - describe('CustomerContact Management Component', () => { - let comp: CustomerContactComponent; - let fixture: ComponentFixture; - let service: CustomerContactService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [CustomerContactComponent], - providers: [ - { - provide: ActivatedRoute, - useValue: { - data: { - subscribe: (fn: (value: Data) => void) => - fn({ - pagingParams: { - predicate: 'id', - reverse: false, - page: 0 - } - }) - } - } - } - ] - }) - .overrideTemplate(CustomerContactComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(CustomerContactComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CustomerContactService); - }); - - 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 CustomerContact(123)], - headers - }) - ) - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.customerContacts[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 CustomerContact(123)], - headers - }) - ) - ); - - // WHEN - comp.loadPage(1); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.customerContacts[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 CustomerContact(123)], - headers - }) - ) - ); - - // WHEN - comp.loadPage(1); - comp.reset(); - - // THEN - expect(comp.page).toEqual(0); - expect(service.query).toHaveBeenCalledTimes(2); - expect(comp.customerContacts[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-contact/customer-contact.service.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact.service.spec.ts deleted file mode 100644 index f31d85b9..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact.service.spec.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* 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 { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service'; -import { ICustomerContact, CustomerContact, CustomerContactRole } from 'app/shared/model/customer-contact.model'; - -describe('Service Tests', () => { - describe('CustomerContact Service', () => { - let injector: TestBed; - let service: CustomerContactService; - let httpMock: HttpTestingController; - let elemDefault: ICustomerContact; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] - }); - injector = getTestBed(); - service = injector.get(CustomerContactService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new CustomerContact(0, CustomerContactRole.CONTRACTUAL); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, 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 CustomerContact', async () => { - const returnedFromService = Object.assign( - { - id: 0 - }, - elemDefault - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new CustomerContact(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 CustomerContact', async () => { - const returnedFromService = Object.assign( - { - role: 'BBBBBB' - }, - elemDefault - ); - - const expected = Object.assign({}, 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 CustomerContact', async () => { - const returnedFromService = Object.assign( - { - role: 'BBBBBB' - }, - elemDefault - ); - const expected = Object.assign({}, 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 CustomerContact', 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-update.component.spec.ts b/src/test/javascript/spec/app/entities/customer/customer-update.component.spec.ts index 2249e64e..e50a46df 100644 --- 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 @@ -1,7 +1,7 @@ /* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; import { CustomerUpdateComponent } from 'app/entities/customer/customer-update.component'; diff --git a/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts b/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts index 8cbf4977..46117d13 100644 --- a/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts +++ b/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts @@ -1,9 +1,11 @@ /* tslint:disable max-line-length */ -import { getTestBed, TestBed } from '@angular/core/testing'; +import { TestBed, getTestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { map, take } from 'rxjs/operators'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; import { CustomerService } from 'app/entities/customer/customer.service'; -import { Customer, ICustomer } from 'app/shared/model/customer.model'; +import { ICustomer, Customer } from 'app/shared/model/customer.model'; describe('Service Tests', () => { describe('Customer Service', () => { @@ -56,10 +58,10 @@ describe('Service Tests', () => { number: 1, prefix: 'BBBBBB', name: 'BBBBBB', - contractualAddress: 'BBBBBB', contractualSalutation: 'BBBBBB', - billingAddress: 'BBBBBB', - billingSalutation: 'BBBBBB' + contractualAddress: 'BBBBBB', + billingSalutation: 'BBBBBB', + billingAddress: 'BBBBBB' }, elemDefault ); @@ -79,10 +81,10 @@ describe('Service Tests', () => { number: 1, prefix: 'BBBBBB', name: 'BBBBBB', - contractualAddress: 'BBBBBB', contractualSalutation: 'BBBBBB', - billingAddress: 'BBBBBB', - billingSalutation: 'BBBBBB' + contractualAddress: 'BBBBBB', + billingSalutation: 'BBBBBB', + billingAddress: 'BBBBBB' }, elemDefault ); 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 index 3fa8f65c..abd5a5a2 100644 --- 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 @@ -1,7 +1,7 @@ /* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; import { MembershipUpdateComponent } from 'app/entities/membership/membership-update.component'; diff --git a/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts b/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts index d608d510..139697e5 100644 --- a/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts +++ b/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts @@ -25,15 +25,15 @@ describe('Service Tests', () => { httpMock = injector.get(HttpTestingController); currentDate = moment(); - elemDefault = new Membership(0, currentDate, currentDate); + elemDefault = new Membership(0, currentDate, currentDate, 'AAAAAAA'); }); describe('Service methods', async () => { it('should find an element', async () => { const returnedFromService = Object.assign( { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) + from: currentDate.format(DATE_FORMAT), + to: currentDate.format(DATE_FORMAT) }, elemDefault ); @@ -50,15 +50,15 @@ describe('Service Tests', () => { const returnedFromService = Object.assign( { id: 0, - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) + from: currentDate.format(DATE_FORMAT), + to: currentDate.format(DATE_FORMAT) }, elemDefault ); const expected = Object.assign( { - sinceDate: currentDate, - untilDate: currentDate + from: currentDate, + to: currentDate }, returnedFromService ); @@ -73,16 +73,17 @@ describe('Service Tests', () => { it('should update a Membership', async () => { const returnedFromService = Object.assign( { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) + from: currentDate.format(DATE_FORMAT), + to: currentDate.format(DATE_FORMAT), + comment: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - sinceDate: currentDate, - untilDate: currentDate + from: currentDate, + to: currentDate }, returnedFromService ); @@ -97,15 +98,16 @@ describe('Service Tests', () => { it('should return a list of Membership', async () => { const returnedFromService = Object.assign( { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) + from: currentDate.format(DATE_FORMAT), + to: currentDate.format(DATE_FORMAT), + comment: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - sinceDate: currentDate, - untilDate: currentDate + from: currentDate, + to: currentDate }, returnedFromService ); diff --git a/src/test/javascript/spec/app/entities/contact/contact-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts similarity index 67% rename from src/test/javascript/spec/app/entities/contact/contact-delete-dialog.component.spec.ts rename to src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts index 1c572ff0..6dec0e0e 100644 --- a/src/test/javascript/spec/app/entities/contact/contact-delete-dialog.component.spec.ts +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts @@ -5,27 +5,27 @@ import { Observable, of } from 'rxjs'; import { JhiEventManager } from 'ng-jhipster'; import { HsadminNgTestModule } from '../../../test.module'; -import { ContactDeleteDialogComponent } from 'app/entities/contact/contact-delete-dialog.component'; -import { ContactService } from 'app/entities/contact/contact.service'; +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('Contact Management Delete Component', () => { - let comp: ContactDeleteDialogComponent; - let fixture: ComponentFixture; - let service: ContactService; + 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: [ContactDeleteDialogComponent] + declarations: [SepaMandateDeleteDialogComponent] }) - .overrideTemplate(ContactDeleteDialogComponent, '') + .overrideTemplate(SepaMandateDeleteDialogComponent, '') .compileComponents(); - fixture = TestBed.createComponent(ContactDeleteDialogComponent); + fixture = TestBed.createComponent(SepaMandateDeleteDialogComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ContactService); + service = fixture.debugElement.injector.get(SepaMandateService); mockEventManager = fixture.debugElement.injector.get(JhiEventManager); mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); }); diff --git a/src/test/javascript/spec/app/entities/contact/contact-detail.component.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-detail.component.spec.ts similarity index 52% rename from src/test/javascript/spec/app/entities/contact/contact-detail.component.spec.ts rename to src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-detail.component.spec.ts index f269a672..ba8ffcb2 100644 --- a/src/test/javascript/spec/app/entities/contact/contact-detail.component.spec.ts +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-detail.component.spec.ts @@ -4,24 +4,24 @@ import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; -import { ContactDetailComponent } from 'app/entities/contact/contact-detail.component'; -import { Contact } from 'app/shared/model/contact.model'; +import { SepaMandateDetailComponent } from 'app/entities/sepa-mandate/sepa-mandate-detail.component'; +import { SepaMandate } from 'app/shared/model/sepa-mandate.model'; describe('Component Tests', () => { - describe('Contact Management Detail Component', () => { - let comp: ContactDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ contact: new Contact(123) }) } as any) as ActivatedRoute; + 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: [ContactDetailComponent], + declarations: [SepaMandateDetailComponent], providers: [{ provide: ActivatedRoute, useValue: route }] }) - .overrideTemplate(ContactDetailComponent, '') + .overrideTemplate(SepaMandateDetailComponent, '') .compileComponents(); - fixture = TestBed.createComponent(ContactDetailComponent); + fixture = TestBed.createComponent(SepaMandateDetailComponent); comp = fixture.componentInstance; }); @@ -33,7 +33,7 @@ describe('Component Tests', () => { comp.ngOnInit(); // THEN - expect(comp.contact).toEqual(jasmine.objectContaining({ id: 123 })); + expect(comp.sepaMandate).toEqual(jasmine.objectContaining({ id: 123 })); }); }); }); diff --git a/src/test/javascript/spec/app/entities/contact/contact-update.component.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-update.component.spec.ts similarity index 62% rename from src/test/javascript/spec/app/entities/contact/contact-update.component.spec.ts rename to src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-update.component.spec.ts index 3cd83c3d..c2246524 100644 --- a/src/test/javascript/spec/app/entities/contact/contact-update.component.spec.ts +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-update.component.spec.ts @@ -4,35 +4,35 @@ import { HttpResponse } from '@angular/common/http'; import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; -import { ContactUpdateComponent } from 'app/entities/contact/contact-update.component'; -import { ContactService } from 'app/entities/contact/contact.service'; -import { Contact } from 'app/shared/model/contact.model'; +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('Contact Management Update Component', () => { - let comp: ContactUpdateComponent; - let fixture: ComponentFixture; - let service: ContactService; + describe('SepaMandate Management Update Component', () => { + let comp: SepaMandateUpdateComponent; + let fixture: ComponentFixture; + let service: SepaMandateService; beforeEach(() => { TestBed.configureTestingModule({ imports: [HsadminNgTestModule], - declarations: [ContactUpdateComponent] + declarations: [SepaMandateUpdateComponent] }) - .overrideTemplate(ContactUpdateComponent, '') + .overrideTemplate(SepaMandateUpdateComponent, '') .compileComponents(); - fixture = TestBed.createComponent(ContactUpdateComponent); + fixture = TestBed.createComponent(SepaMandateUpdateComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ContactService); + service = fixture.debugElement.injector.get(SepaMandateService); }); describe('save', () => { it('Should call update service on save for existing entity', fakeAsync(() => { // GIVEN - const entity = new Contact(123); + const entity = new SepaMandate(123); spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.contact = entity; + comp.sepaMandate = entity; // WHEN comp.save(); tick(); // simulate async @@ -44,9 +44,9 @@ describe('Component Tests', () => { it('Should call create service on save for new entity', fakeAsync(() => { // GIVEN - const entity = new Contact(); + const entity = new SepaMandate(); spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.contact = entity; + comp.sepaMandate = entity; // WHEN comp.save(); tick(); // simulate async diff --git a/src/test/javascript/spec/app/entities/contact/contact.component.spec.ts b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.component.spec.ts similarity index 74% rename from src/test/javascript/spec/app/entities/contact/contact.component.spec.ts rename to src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.component.spec.ts index 86c74058..66ce50bd 100644 --- a/src/test/javascript/spec/app/entities/contact/contact.component.spec.ts +++ b/src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.component.spec.ts @@ -5,20 +5,20 @@ import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { ActivatedRoute, Data } from '@angular/router'; import { HsadminNgTestModule } from '../../../test.module'; -import { ContactComponent } from 'app/entities/contact/contact.component'; -import { ContactService } from 'app/entities/contact/contact.service'; -import { Contact } from 'app/shared/model/contact.model'; +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('Contact Management Component', () => { - let comp: ContactComponent; - let fixture: ComponentFixture; - let service: ContactService; + describe('SepaMandate Management Component', () => { + let comp: SepaMandateComponent; + let fixture: ComponentFixture; + let service: SepaMandateService; beforeEach(() => { TestBed.configureTestingModule({ imports: [HsadminNgTestModule], - declarations: [ContactComponent], + declarations: [SepaMandateComponent], providers: [ { provide: ActivatedRoute, @@ -37,12 +37,12 @@ describe('Component Tests', () => { } ] }) - .overrideTemplate(ContactComponent, '') + .overrideTemplate(SepaMandateComponent, '') .compileComponents(); - fixture = TestBed.createComponent(ContactComponent); + fixture = TestBed.createComponent(SepaMandateComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ContactService); + service = fixture.debugElement.injector.get(SepaMandateService); }); it('Should call load all on init', () => { @@ -51,7 +51,7 @@ describe('Component Tests', () => { spyOn(service, 'query').and.returnValue( of( new HttpResponse({ - body: [new Contact(123)], + body: [new SepaMandate(123)], headers }) ) @@ -62,7 +62,7 @@ describe('Component Tests', () => { // THEN expect(service.query).toHaveBeenCalled(); - expect(comp.contacts[0]).toEqual(jasmine.objectContaining({ id: 123 })); + expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 })); }); it('should load a page', () => { @@ -71,7 +71,7 @@ describe('Component Tests', () => { spyOn(service, 'query').and.returnValue( of( new HttpResponse({ - body: [new Contact(123)], + body: [new SepaMandate(123)], headers }) ) @@ -82,7 +82,7 @@ describe('Component Tests', () => { // THEN expect(service.query).toHaveBeenCalled(); - expect(comp.contacts[0]).toEqual(jasmine.objectContaining({ id: 123 })); + expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 })); }); it('should re-initialize the page', () => { @@ -91,7 +91,7 @@ describe('Component Tests', () => { spyOn(service, 'query').and.returnValue( of( new HttpResponse({ - body: [new Contact(123)], + body: [new SepaMandate(123)], headers }) ) @@ -104,7 +104,7 @@ describe('Component Tests', () => { // THEN expect(comp.page).toEqual(0); expect(service.query).toHaveBeenCalledTimes(2); - expect(comp.contacts[0]).toEqual(jasmine.objectContaining({ id: 123 })); + expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 })); }); it('should calculate the sort attribute for an id', () => { // WHEN 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..98d20b23 --- /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( + { + created: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validTo: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancelled: 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, + created: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validTo: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancelled: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + created: currentDate, + validFrom: currentDate, + validTo: currentDate, + lastUsed: currentDate, + cancelled: 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', + created: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validTo: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancelled: currentDate.format(DATE_FORMAT), + comment: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + created: currentDate, + validFrom: currentDate, + validTo: currentDate, + lastUsed: currentDate, + cancelled: 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', + created: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validTo: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancelled: currentDate.format(DATE_FORMAT), + comment: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign( + { + created: currentDate, + validFrom: currentDate, + validTo: currentDate, + lastUsed: currentDate, + cancelled: 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-update.component.spec.ts b/src/test/javascript/spec/app/entities/share/share-update.component.spec.ts index f19de7be..279be464 100644 --- 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 @@ -1,7 +1,7 @@ /* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; import { ShareUpdateComponent } from 'app/entities/share/share-update.component'; From 2459dd3b64e1bb325c65f18fe1a09eb8eb80df73 Mon Sep 17 00:00:00 2001 From: Michael Hierweck Date: Wed, 17 Apr 2019 16:45:43 +0200 Subject: [PATCH 2/5] Model customers. --- .jhipster/Asset.json | 15 +- .jhipster/Customer.json | 30 +- .jhipster/Membership.json | 23 +- .jhipster/SepaMandate.json | 84 ++ .jhipster/Share.json | 15 +- .../hostsharing/hsadminng/domain/Asset.java | 75 +- .../hsadminng/domain/Customer.java | 130 ++- .../hsadminng/domain/Membership.java | 90 +- .../hsadminng/domain/SepaMandate.java | 241 +++++ .../hostsharing/hsadminng/domain/Share.java | 75 +- .../repository/SepaMandateRepository.java | 15 + .../hsadminng/service/AssetQueryService.java | 17 +- .../service/CustomerQueryService.java | 46 +- .../service/MembershipQueryService.java | 14 +- .../service/SepaMandateQueryService.java | 126 +++ .../hsadminng/service/SepaMandateService.java | 84 ++ .../hsadminng/service/ShareQueryService.java | 17 +- .../hsadminng/service/dto/AssetCriteria.java | 61 +- .../hsadminng/service/dto/AssetDTO.java | 59 +- .../service/dto/CustomerCriteria.java | 123 ++- .../hsadminng/service/dto/CustomerDTO.java | 51 +- .../service/dto/MembershipCriteria.java | 58 +- .../hsadminng/service/dto/MembershipDTO.java | 48 +- .../service/dto/SepaMandateCriteria.java | 194 ++++ .../hsadminng/service/dto/SepaMandateDTO.java | 178 ++++ .../hsadminng/service/dto/ShareCriteria.java | 61 +- .../hsadminng/service/dto/ShareDTO.java | 59 +- .../hsadminng/service/mapper/AssetMapper.java | 5 +- .../service/mapper/CustomerMapper.java | 8 +- .../service/mapper/SepaMandateMapper.java | 29 + .../hsadminng/service/mapper/ShareMapper.java | 5 +- .../web/rest/SepaMandateResource.java | 138 +++ src/main/jdl/customer.jdl | 65 +- .../20190403083735_added_entity_Customer.xml | 32 +- ...20190403083738_added_entity_Membership.xml | 18 +- .../20190403083739_added_entity_Share.xml | 16 +- ...3083739_added_entity_constraints_Share.xml | 4 +- .../20190403083740_added_entity_Asset.xml | 16 +- ...3083740_added_entity_constraints_Asset.xml | 4 +- ...0190418100951_added_entity_SepaMandate.xml | 69 ++ ...1_added_entity_constraints_SepaMandate.xml | 18 + .../resources/config/liquibase/master.xml | 2 + .../asset/asset-detail.component.html | 18 +- .../asset/asset-update.component.html | 49 +- .../entities/asset/asset-update.component.ts | 3 +- .../app/entities/asset/asset.component.html | 16 +- .../app/entities/asset/asset.service.ts | 9 +- .../customer/customer-detail.component.html | 16 +- .../customer/customer-update.component.html | 130 ++- .../entities/customer/customer.component.html | 31 +- src/main/webapp/app/entities/entity.module.ts | 20 + .../membership-detail.component.html | 16 +- .../membership-update.component.html | 49 +- .../membership/membership-update.component.ts | 5 +- .../membership/membership.component.html | 12 +- .../entities/membership/membership.service.ts | 17 +- .../webapp/app/entities/sepa-mandate/index.ts | 6 + .../sepa-mandate-delete-dialog.component.html | 19 + .../sepa-mandate-delete-dialog.component.ts | 72 ++ .../sepa-mandate-detail.component.html | 65 ++ .../sepa-mandate-detail.component.ts | 24 + .../sepa-mandate-update.component.html | 147 +++ .../sepa-mandate-update.component.ts | 82 ++ .../sepa-mandate/sepa-mandate.component.html | 76 ++ .../sepa-mandate/sepa-mandate.component.ts | 108 ++ .../sepa-mandate/sepa-mandate.module.ts | 40 + .../sepa-mandate/sepa-mandate.route.ts | 93 ++ .../sepa-mandate/sepa-mandate.service.ts | 93 ++ .../share/share-detail.component.html | 18 +- .../share/share-update.component.html | 49 +- .../entities/share/share-update.component.ts | 3 +- .../app/entities/share/share.component.html | 16 +- .../app/entities/share/share.service.ts | 9 +- .../app/layouts/navbar/navbar.component.html | 6 + .../webapp/app/shared/model/asset.model.ts | 16 +- .../webapp/app/shared/model/customer.model.ts | 22 +- .../app/shared/model/membership.model.ts | 12 +- .../app/shared/model/sepa-mandate.model.ts | 33 + .../webapp/app/shared/model/share.model.ts | 16 +- src/main/webapp/i18n/de/asset.json | 7 +- src/main/webapp/i18n/de/customer.json | 11 +- src/main/webapp/i18n/de/global.json | 1 + src/main/webapp/i18n/de/membership.json | 6 +- src/main/webapp/i18n/de/sepaMandate.json | 30 + src/main/webapp/i18n/de/share.json | 7 +- src/main/webapp/i18n/en/asset.json | 7 +- src/main/webapp/i18n/en/customer.json | 11 +- src/main/webapp/i18n/en/global.json | 1 + src/main/webapp/i18n/en/membership.json | 6 +- src/main/webapp/i18n/en/sepaMandate.json | 30 + src/main/webapp/i18n/en/share.json | 7 +- .../web/rest/AssetResourceIntTest.java | 246 +++-- .../web/rest/CustomerResourceIntTest.java | 295 +++--- .../web/rest/MembershipResourceIntTest.java | 296 ++++-- .../web/rest/SepaMandateResourceIntTest.java | 972 ++++++++++++++++++ .../web/rest/ShareResourceIntTest.java | 248 +++-- .../asset/asset-update.component.spec.ts | 4 +- .../app/entities/asset/asset.service.spec.ts | 27 +- .../customer-update.component.spec.ts | 4 +- .../customer/customer.service.spec.ts | 24 +- .../membership-update.component.spec.ts | 4 +- .../membership/membership.service.spec.ts | 39 +- ...pa-mandate-delete-dialog.component.spec.ts | 52 + .../sepa-mandate-detail.component.spec.ts | 40 + .../sepa-mandate-update.component.spec.ts | 60 ++ .../sepa-mandate.component.spec.ts | 128 +++ .../sepa-mandate/sepa-mandate.service.spec.ts | 176 ++++ .../share/share-update.component.spec.ts | 4 +- .../app/entities/share/share.service.spec.ts | 27 +- 109 files changed, 5513 insertions(+), 1091 deletions(-) create mode 100644 .jhipster/SepaMandate.json create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/SepaMandate.java create mode 100644 src/main/java/org/hostsharing/hsadminng/repository/SepaMandateRepository.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/SepaMandateService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateCriteria.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/SepaMandateMapper.java create mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/SepaMandateResource.java create mode 100644 src/main/resources/config/liquibase/changelog/20190418100951_added_entity_SepaMandate.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418100951_added_entity_constraints_SepaMandate.xml create mode 100644 src/main/webapp/app/entities/sepa-mandate/index.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.module.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.route.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts create mode 100644 src/main/webapp/app/shared/model/sepa-mandate.model.ts create mode 100644 src/main/webapp/i18n/de/sepaMandate.json create mode 100644 src/main/webapp/i18n/en/sepaMandate.json create mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.service.spec.ts diff --git a/.jhipster/Asset.json b/.jhipster/Asset.json index c1e70387..9c3d4501 100644 --- a/.jhipster/Asset.json +++ b/.jhipster/Asset.json @@ -2,7 +2,14 @@ "name": "Asset", "fields": [ { - "fieldName": "date", + "fieldName": "documentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "valueDate", "fieldType": "LocalDate", "fieldValidateRules": [ "required" @@ -24,7 +31,7 @@ ] }, { - "fieldName": "comment", + "fieldName": "remark", "fieldType": "String", "fieldValidateRules": [ "maxlength" @@ -38,8 +45,8 @@ "otherEntityName": "membership", "otherEntityRelationshipName": "asset", "relationshipValidateRules": "required", - "relationshipName": "member", - "otherEntityField": "id" + "relationshipName": "membership", + "otherEntityField": "documentDate" } ], "changelogDate": "20190403083740", diff --git a/.jhipster/Customer.json b/.jhipster/Customer.json index 36d7340c..76b1a567 100644 --- a/.jhipster/Customer.json +++ b/.jhipster/Customer.json @@ -2,7 +2,7 @@ "name": "Customer", "fields": [ { - "fieldName": "number", + "fieldName": "reference", "fieldType": "Integer", "fieldValidateRules": [ "required", @@ -18,9 +18,11 @@ "fieldType": "String", "fieldValidateRules": [ "required", + "maxlength", "unique", "pattern" ], + "fieldValidateRulesMaxlength": 3, "fieldValidateRulesPattern": "[a-z][a-z0-9]+" }, { @@ -32,6 +34,14 @@ ], "fieldValidateRulesMaxlength": 80 }, + { + "fieldName": "contractualSalutation", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 80 + }, { "fieldName": "contractualAddress", "fieldType": "String", @@ -42,7 +52,7 @@ "fieldValidateRulesMaxlength": 400 }, { - "fieldName": "contractualSalutation", + "fieldName": "billingSalutation", "fieldType": "String", "fieldValidateRules": [ "maxlength" @@ -58,26 +68,26 @@ "fieldValidateRulesMaxlength": 400 }, { - "fieldName": "billingSalutation", + "fieldName": "remark", "fieldType": "String", "fieldValidateRules": [ "maxlength" ], - "fieldValidateRulesMaxlength": 80 + "fieldValidateRulesMaxlength": 160 } ], "relationships": [ - { - "relationshipType": "one-to-many", - "otherEntityName": "customerContact", - "otherEntityRelationshipName": "customer", - "relationshipName": "role" - }, { "relationshipType": "one-to-many", "otherEntityName": "membership", "otherEntityRelationshipName": "customer", "relationshipName": "membership" + }, + { + "relationshipType": "one-to-many", + "otherEntityName": "sepaMandate", + "otherEntityRelationshipName": "customer", + "relationshipName": "sepamandate" } ], "changelogDate": "20190403083735", diff --git a/.jhipster/Membership.json b/.jhipster/Membership.json index c44a5c77..38b6361e 100644 --- a/.jhipster/Membership.json +++ b/.jhipster/Membership.json @@ -2,28 +2,43 @@ "name": "Membership", "fields": [ { - "fieldName": "sinceDate", + "fieldName": "documentDate", "fieldType": "LocalDate", "fieldValidateRules": [ "required" ] }, { - "fieldName": "untilDate", + "fieldName": "memberFrom", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "memberUntil", "fieldType": "LocalDate" + }, + { + "fieldName": "remark", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": 160 } ], "relationships": [ { "relationshipType": "one-to-many", "otherEntityName": "share", - "otherEntityRelationshipName": "member", + "otherEntityRelationshipName": "membership", "relationshipName": "share" }, { "relationshipType": "one-to-many", "otherEntityName": "asset", - "otherEntityRelationshipName": "member", + "otherEntityRelationshipName": "membership", "relationshipName": "asset" }, { diff --git a/.jhipster/SepaMandate.json b/.jhipster/SepaMandate.json new file mode 100644 index 00000000..403ec21d --- /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": "documentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "validFrom", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "validUntil", + "fieldType": "LocalDate" + }, + { + "fieldName": "lastUsed", + "fieldType": "LocalDate" + }, + { + "fieldName": "cancellationDate", + "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": "20190418100951", + "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 index 630f5a24..918983a7 100644 --- a/.jhipster/Share.json +++ b/.jhipster/Share.json @@ -2,7 +2,14 @@ "name": "Share", "fields": [ { - "fieldName": "date", + "fieldName": "documentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "valueDate", "fieldType": "LocalDate", "fieldValidateRules": [ "required" @@ -24,7 +31,7 @@ ] }, { - "fieldName": "comment", + "fieldName": "remark", "fieldType": "String", "fieldValidateRules": [ "maxlength" @@ -38,8 +45,8 @@ "otherEntityName": "membership", "otherEntityRelationshipName": "share", "relationshipValidateRules": "required", - "relationshipName": "member", - "otherEntityField": "id" + "relationshipName": "membership", + "otherEntityField": "documentDate" } ], "changelogDate": "20190403083739", diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java index fa69bb84..22227eb3 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Asset.java @@ -2,16 +2,17 @@ package org.hostsharing.hsadminng.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; import javax.persistence.*; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +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. */ @@ -27,8 +28,12 @@ public class Asset implements Serializable { private Long id; @NotNull - @Column(name = "jhi_date", nullable = false) - private LocalDate date; + @Column(name = "document_date", nullable = false) + private LocalDate documentDate; + + @NotNull + @Column(name = "value_date", nullable = false) + private LocalDate valueDate; @NotNull @Enumerated(EnumType.STRING) @@ -40,13 +45,13 @@ public class Asset implements Serializable { private BigDecimal amount; @Size(max = 160) - @Column(name = "jhi_comment", length = 160) - private String comment; + @Column(name = "remark", length = 160) + private String remark; @ManyToOne(optional = false) @NotNull @JsonIgnoreProperties("assets") - private Membership member; + private Membership membership; // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public Long getId() { @@ -57,17 +62,30 @@ public class Asset implements Serializable { this.id = id; } - public LocalDate getDate() { - return date; + public LocalDate getDocumentDate() { + return documentDate; } - public Asset date(LocalDate date) { - this.date = date; + public Asset documentDate(LocalDate documentDate) { + this.documentDate = documentDate; return this; } - public void setDate(LocalDate date) { - this.date = date; + 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() { @@ -96,30 +114,30 @@ public class Asset implements Serializable { this.amount = amount; } - public String getComment() { - return comment; + public String getRemark() { + return remark; } - public Asset comment(String comment) { - this.comment = comment; + public Asset remark(String remark) { + this.remark = remark; return this; } - public void setComment(String comment) { - this.comment = comment; + public void setRemark(String remark) { + this.remark = remark; } - public Membership getMember() { - return member; + public Membership getMembership() { + return membership; } - public Asset member(Membership membership) { - this.member = membership; + public Asset membership(Membership membership) { + this.membership = membership; return this; } - public void setMember(Membership membership) { - this.member = membership; + public void setMembership(Membership membership) { + this.membership = membership; } // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove @@ -147,10 +165,11 @@ public class Asset implements Serializable { public String toString() { return "Asset{" + "id=" + getId() + - ", date='" + getDate() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", valueDate='" + getValueDate() + "'" + ", action='" + getAction() + "'" + ", amount=" + getAmount() + - ", comment='" + getComment() + "'" + + ", remark='" + getRemark() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java index de1d9e78..c7cb1495 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java @@ -1,12 +1,15 @@ package org.hostsharing.hsadminng.domain; +import com.fasterxml.jackson.annotation.JsonIgnore; + import javax.persistence.*; import javax.validation.constraints.*; + import java.io.Serializable; import java.util.HashSet; -import java.util.Objects; import java.util.Set; +import java.util.Objects; /** * A Customer. @@ -25,12 +28,13 @@ public class Customer implements Serializable { @NotNull @Min(value = 10000) @Max(value = 99999) - @Column(name = "jhi_number", nullable = false, unique = true) - private Integer number; + @Column(name = "reference", nullable = false, unique = true) + private Integer reference; @NotNull + @Size(max = 3) @Pattern(regexp = "[a-z][a-z0-9]+") - @Column(name = "prefix", nullable = false, unique = true) + @Column(name = "prefix", length = 3, nullable = false, unique = true) private String prefix; @NotNull @@ -38,27 +42,31 @@ public class Customer implements Serializable { @Column(name = "name", length = 80, nullable = false) private String name; + @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 = "contractual_salutation", length = 80) - private String contractualSalutation; + @Column(name = "billing_salutation", length = 80) + private String billingSalutation; @Size(max = 400) @Column(name = "billing_address", length = 400) private String billingAddress; - @Size(max = 80) - @Column(name = "billing_salutation", length = 80) - private String billingSalutation; + @Size(max = 160) + @Column(name = "remark", length = 160) + private String remark; - @OneToMany(mappedBy = "customer") - private Set roles = new HashSet<>(); @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; @@ -68,17 +76,17 @@ public class Customer implements Serializable { this.id = id; } - public Integer getNumber() { - return number; + public Integer getReference() { + return reference; } - public Customer number(Integer number) { - this.number = number; + public Customer reference(Integer reference) { + this.reference = reference; return this; } - public void setNumber(Integer number) { - this.number = number; + public void setReference(Integer reference) { + this.reference = reference; } public String getPrefix() { @@ -107,19 +115,6 @@ public class Customer implements Serializable { this.name = name; } - 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 getContractualSalutation() { return contractualSalutation; } @@ -133,17 +128,17 @@ public class Customer implements Serializable { this.contractualSalutation = contractualSalutation; } - public String getBillingAddress() { - return billingAddress; + public String getContractualAddress() { + return contractualAddress; } - public Customer billingAddress(String billingAddress) { - this.billingAddress = billingAddress; + public Customer contractualAddress(String contractualAddress) { + this.contractualAddress = contractualAddress; return this; } - public void setBillingAddress(String billingAddress) { - this.billingAddress = billingAddress; + public void setContractualAddress(String contractualAddress) { + this.contractualAddress = contractualAddress; } public String getBillingSalutation() { @@ -159,29 +154,30 @@ public class Customer implements Serializable { this.billingSalutation = billingSalutation; } - public Set getRoles() { - return roles; + public String getBillingAddress() { + return billingAddress; } - public Customer roles(Set customerContacts) { - this.roles = customerContacts; + public Customer billingAddress(String billingAddress) { + this.billingAddress = billingAddress; return this; } - public Customer addRole(CustomerContact customerContact) { - this.roles.add(customerContact); - customerContact.setCustomer(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 Customer removeRole(CustomerContact customerContact) { - this.roles.remove(customerContact); - customerContact.setCustomer(null); - return this; - } - - public void setRoles(Set customerContacts) { - this.roles = customerContacts; + public void setRemark(String remark) { + this.remark = remark; } public Set getMemberships() { @@ -208,6 +204,31 @@ public class Customer implements Serializable { 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 @@ -234,13 +255,14 @@ public class Customer implements Serializable { public String toString() { return "Customer{" + "id=" + getId() + - ", number=" + getNumber() + + ", reference=" + getReference() + ", prefix='" + getPrefix() + "'" + ", name='" + getName() + "'" + - ", contractualAddress='" + getContractualAddress() + "'" + ", contractualSalutation='" + getContractualSalutation() + "'" + - ", billingAddress='" + getBillingAddress() + "'" + + ", 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 index 93f20433..e84834d8 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java @@ -1,15 +1,17 @@ package org.hostsharing.hsadminng.domain; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.persistence.*; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.*; + import java.io.Serializable; import java.time.LocalDate; import java.util.HashSet; -import java.util.Objects; import java.util.Set; +import java.util.Objects; /** * A Membership. @@ -26,15 +28,23 @@ public class Membership implements Serializable { private Long id; @NotNull - @Column(name = "since_date", nullable = false) - private LocalDate sinceDate; + @Column(name = "document_date", nullable = false) + private LocalDate documentDate; - @Column(name = "until_date") - private LocalDate untilDate; + @NotNull + @Column(name = "member_from", nullable = false) + private LocalDate memberFrom; - @OneToMany(mappedBy = "member") + @Column(name = "member_until") + private LocalDate memberUntil; + + @Size(max = 160) + @Column(name = "remark", length = 160) + private String remark; + + @OneToMany(mappedBy = "membership") private Set shares = new HashSet<>(); - @OneToMany(mappedBy = "member") + @OneToMany(mappedBy = "membership") private Set assets = new HashSet<>(); @ManyToOne(optional = false) @NotNull @@ -50,30 +60,56 @@ public class Membership implements Serializable { this.id = id; } - public LocalDate getSinceDate() { - return sinceDate; + public LocalDate getDocumentDate() { + return documentDate; } - public Membership sinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; + public Membership documentDate(LocalDate documentDate) { + this.documentDate = documentDate; return this; } - public void setSinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; } - public LocalDate getUntilDate() { - return untilDate; + public LocalDate getMemberFrom() { + return memberFrom; } - public Membership untilDate(LocalDate untilDate) { - this.untilDate = untilDate; + public Membership memberFrom(LocalDate memberFrom) { + this.memberFrom = memberFrom; return this; } - public void setUntilDate(LocalDate untilDate) { - this.untilDate = untilDate; + public void setMemberFrom(LocalDate memberFrom) { + this.memberFrom = memberFrom; + } + + public LocalDate getMemberUntil() { + return memberUntil; + } + + public Membership memberUntil(LocalDate memberUntil) { + this.memberUntil = memberUntil; + return this; + } + + public void setMemberUntil(LocalDate memberUntil) { + this.memberUntil = memberUntil; + } + + 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() { @@ -87,13 +123,13 @@ public class Membership implements Serializable { public Membership addShare(Share share) { this.shares.add(share); - share.setMember(this); + share.setMembership(this); return this; } public Membership removeShare(Share share) { this.shares.remove(share); - share.setMember(null); + share.setMembership(null); return this; } @@ -112,13 +148,13 @@ public class Membership implements Serializable { public Membership addAsset(Asset asset) { this.assets.add(asset); - asset.setMember(this); + asset.setMembership(this); return this; } public Membership removeAsset(Asset asset) { this.assets.remove(asset); - asset.setMember(null); + asset.setMembership(null); return this; } @@ -164,8 +200,10 @@ public class Membership implements Serializable { public String toString() { return "Membership{" + "id=" + getId() + - ", sinceDate='" + getSinceDate() + "'" + - ", untilDate='" + getUntilDate() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", memberFrom='" + getMemberFrom() + "'" + + ", memberUntil='" + getMemberUntil() + "'" + + ", 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..3c7741df --- /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 = "document_date", nullable = false) + private LocalDate documentDate; + + @NotNull + @Column(name = "valid_from", nullable = false) + private LocalDate validFrom; + + @Column(name = "valid_until") + private LocalDate validUntil; + + @Column(name = "last_used") + private LocalDate lastUsed; + + @Column(name = "cancellation_date") + private LocalDate cancellationDate; + + @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 getDocumentDate() { + return documentDate; + } + + public SepaMandate documentDate(LocalDate documentDate) { + this.documentDate = documentDate; + return this; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValidFrom() { + return validFrom; + } + + public SepaMandate validFrom(LocalDate validFrom) { + this.validFrom = validFrom; + return this; + } + + public void setValidFrom(LocalDate validFrom) { + this.validFrom = validFrom; + } + + public LocalDate getValidUntil() { + return validUntil; + } + + public SepaMandate validUntil(LocalDate validUntil) { + this.validUntil = validUntil; + return this; + } + + public void setValidUntil(LocalDate validUntil) { + this.validUntil = validUntil; + } + + public LocalDate getLastUsed() { + return lastUsed; + } + + public SepaMandate lastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + return this; + } + + public void setLastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDate getCancellationDate() { + return cancellationDate; + } + + public SepaMandate cancellationDate(LocalDate cancellationDate) { + this.cancellationDate = cancellationDate; + return this; + } + + public void setCancellationDate(LocalDate cancellationDate) { + this.cancellationDate = cancellationDate; + } + + 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() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", validFrom='" + getValidFrom() + "'" + + ", validUntil='" + getValidUntil() + "'" + + ", lastUsed='" + getLastUsed() + "'" + + ", cancellationDate='" + getCancellationDate() + "'" + + ", remark='" + getRemark() + "'" + + "}"; + } +} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Share.java b/src/main/java/org/hostsharing/hsadminng/domain/Share.java index 0d91abc1..2bc26931 100644 --- a/src/main/java/org/hostsharing/hsadminng/domain/Share.java +++ b/src/main/java/org/hostsharing/hsadminng/domain/Share.java @@ -2,15 +2,16 @@ package org.hostsharing.hsadminng.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.hostsharing.hsadminng.domain.enumeration.ShareAction; import javax.persistence.*; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +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. */ @@ -26,8 +27,12 @@ public class Share implements Serializable { private Long id; @NotNull - @Column(name = "jhi_date", nullable = false) - private LocalDate date; + @Column(name = "document_date", nullable = false) + private LocalDate documentDate; + + @NotNull + @Column(name = "value_date", nullable = false) + private LocalDate valueDate; @NotNull @Enumerated(EnumType.STRING) @@ -39,13 +44,13 @@ public class Share implements Serializable { private Integer quantity; @Size(max = 160) - @Column(name = "jhi_comment", length = 160) - private String comment; + @Column(name = "remark", length = 160) + private String remark; @ManyToOne(optional = false) @NotNull @JsonIgnoreProperties("shares") - private Membership member; + private Membership membership; // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public Long getId() { @@ -56,17 +61,30 @@ public class Share implements Serializable { this.id = id; } - public LocalDate getDate() { - return date; + public LocalDate getDocumentDate() { + return documentDate; } - public Share date(LocalDate date) { - this.date = date; + public Share documentDate(LocalDate documentDate) { + this.documentDate = documentDate; return this; } - public void setDate(LocalDate date) { - this.date = date; + 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() { @@ -95,30 +113,30 @@ public class Share implements Serializable { this.quantity = quantity; } - public String getComment() { - return comment; + public String getRemark() { + return remark; } - public Share comment(String comment) { - this.comment = comment; + public Share remark(String remark) { + this.remark = remark; return this; } - public void setComment(String comment) { - this.comment = comment; + public void setRemark(String remark) { + this.remark = remark; } - public Membership getMember() { - return member; + public Membership getMembership() { + return membership; } - public Share member(Membership membership) { - this.member = membership; + public Share membership(Membership membership) { + this.membership = membership; return this; } - public void setMember(Membership membership) { - this.member = membership; + public void setMembership(Membership membership) { + this.membership = membership; } // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove @@ -146,10 +164,11 @@ public class Share implements Serializable { public String toString() { return "Share{" + "id=" + getId() + - ", date='" + getDate() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", valueDate='" + getValueDate() + "'" + ", action='" + getAction() + "'" + ", quantity=" + getQuantity() + - ", comment='" + getComment() + "'" + + ", remark='" + getRemark() + "'" + "}"; } } 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/service/AssetQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java index 81853758..82137a84 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java @@ -89,8 +89,11 @@ public class AssetQueryService extends QueryService { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Asset_.id)); } - if (criteria.getDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getDate(), Asset_.date)); + 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)); @@ -98,12 +101,12 @@ public class AssetQueryService extends QueryService { if (criteria.getAmount() != null) { specification = specification.and(buildRangeSpecification(criteria.getAmount(), Asset_.amount)); } - if (criteria.getComment() != null) { - specification = specification.and(buildStringSpecification(criteria.getComment(), Asset_.comment)); + if (criteria.getRemark() != null) { + specification = specification.and(buildStringSpecification(criteria.getRemark(), Asset_.remark)); } - if (criteria.getMemberId() != null) { - specification = specification.and(buildSpecification(criteria.getMemberId(), - root -> root.join(Asset_.member, JoinType.LEFT).get(Membership_.id))); + 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/CustomerQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java index 214369a7..937322d1 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java @@ -1,14 +1,9 @@ package org.hostsharing.hsadminng.service; -import io.github.jhipster.service.QueryService; -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.CustomerContact_; -import org.hostsharing.hsadminng.domain.Customer_; -import org.hostsharing.hsadminng.domain.Membership_; -import org.hostsharing.hsadminng.repository.CustomerRepository; -import org.hostsharing.hsadminng.service.dto.CustomerCriteria; -import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerMapper; +import java.util.List; + +import javax.persistence.criteria.JoinType; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; @@ -17,8 +12,14 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.persistence.criteria.JoinType; -import java.util.List; +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. @@ -88,8 +89,8 @@ public class CustomerQueryService extends QueryService { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Customer_.id)); } - if (criteria.getNumber() != null) { - specification = specification.and(buildRangeSpecification(criteria.getNumber(), Customer_.number)); + if (criteria.getReference() != null) { + specification = specification.and(buildRangeSpecification(criteria.getReference(), Customer_.reference)); } if (criteria.getPrefix() != null) { specification = specification.and(buildStringSpecification(criteria.getPrefix(), Customer_.prefix)); @@ -97,26 +98,29 @@ public class CustomerQueryService extends QueryService { if (criteria.getName() != null) { specification = specification.and(buildStringSpecification(criteria.getName(), Customer_.name)); } - if (criteria.getContractualAddress() != null) { - specification = specification.and(buildStringSpecification(criteria.getContractualAddress(), Customer_.contractualAddress)); - } if (criteria.getContractualSalutation() != null) { specification = specification.and(buildStringSpecification(criteria.getContractualSalutation(), Customer_.contractualSalutation)); } - if (criteria.getBillingAddress() != null) { - specification = specification.and(buildStringSpecification(criteria.getBillingAddress(), Customer_.billingAddress)); + 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.getRoleId() != null) { - specification = specification.and(buildSpecification(criteria.getRoleId(), - root -> root.join(Customer_.roles, JoinType.LEFT).get(CustomerContact_.id))); + 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/MembershipQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java index 66f86f14..8ab0bb2f 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java @@ -89,11 +89,17 @@ public class MembershipQueryService extends QueryService { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Membership_.id)); } - if (criteria.getSinceDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getSinceDate(), Membership_.sinceDate)); + if (criteria.getDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), Membership_.documentDate)); } - if (criteria.getUntilDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getUntilDate(), Membership_.untilDate)); + if (criteria.getMemberFrom() != null) { + specification = specification.and(buildRangeSpecification(criteria.getMemberFrom(), Membership_.memberFrom)); + } + if (criteria.getMemberUntil() != null) { + specification = specification.and(buildRangeSpecification(criteria.getMemberUntil(), Membership_.memberUntil)); + } + if (criteria.getRemark() != null) { + specification = specification.and(buildStringSpecification(criteria.getRemark(), Membership_.remark)); } if (criteria.getShareId() != null) { specification = specification.and(buildSpecification(criteria.getShareId(), 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..1e31c8b4 --- /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.getDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), SepaMandate_.documentDate)); + } + if (criteria.getValidFrom() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidFrom(), SepaMandate_.validFrom)); + } + if (criteria.getValidUntil() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidUntil(), SepaMandate_.validUntil)); + } + if (criteria.getLastUsed() != null) { + specification = specification.and(buildRangeSpecification(criteria.getLastUsed(), SepaMandate_.lastUsed)); + } + if (criteria.getCancellationDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getCancellationDate(), SepaMandate_.cancellationDate)); + } + 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 index 17e51676..7dcfb36c 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java +++ b/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java @@ -89,8 +89,11 @@ public class ShareQueryService extends QueryService { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), Share_.id)); } - if (criteria.getDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getDate(), Share_.date)); + 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)); @@ -98,12 +101,12 @@ public class ShareQueryService extends QueryService { if (criteria.getQuantity() != null) { specification = specification.and(buildRangeSpecification(criteria.getQuantity(), Share_.quantity)); } - if (criteria.getComment() != null) { - specification = specification.and(buildStringSpecification(criteria.getComment(), Share_.comment)); + if (criteria.getRemark() != null) { + specification = specification.and(buildStringSpecification(criteria.getRemark(), Share_.remark)); } - if (criteria.getMemberId() != null) { - specification = specification.and(buildSpecification(criteria.getMemberId(), - root -> root.join(Share_.member, JoinType.LEFT).get(Membership_.id))); + 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/dto/AssetCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java index c9898fb9..fe0091fc 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java @@ -32,15 +32,17 @@ public class AssetCriteria implements Serializable { private LongFilter id; - private LocalDateFilter date; + private LocalDateFilter documentDate; + + private LocalDateFilter valueDate; private AssetActionFilter action; private BigDecimalFilter amount; - private StringFilter comment; + private StringFilter remark; - private LongFilter memberId; + private LongFilter membershipId; public LongFilter getId() { return id; @@ -50,12 +52,20 @@ public class AssetCriteria implements Serializable { this.id = id; } - public LocalDateFilter getDate() { - return date; + public LocalDateFilter getDocumentDate() { + return documentDate; } - public void setDate(LocalDateFilter date) { - this.date = date; + public void setDocumentDate(LocalDateFilter documentDate) { + this.documentDate = documentDate; + } + + public LocalDateFilter getValueDate() { + return valueDate; + } + + public void setValueDate(LocalDateFilter valueDate) { + this.valueDate = valueDate; } public AssetActionFilter getAction() { @@ -74,20 +84,20 @@ public class AssetCriteria implements Serializable { this.amount = amount; } - public StringFilter getComment() { - return comment; + public StringFilter getRemark() { + return remark; } - public void setComment(StringFilter comment) { - this.comment = comment; + public void setRemark(StringFilter remark) { + this.remark = remark; } - public LongFilter getMemberId() { - return memberId; + public LongFilter getMembershipId() { + return membershipId; } - public void setMemberId(LongFilter memberId) { - this.memberId = memberId; + public void setMembershipId(LongFilter membershipId) { + this.membershipId = membershipId; } @@ -102,22 +112,24 @@ public class AssetCriteria implements Serializable { final AssetCriteria that = (AssetCriteria) o; return Objects.equals(id, that.id) && - Objects.equals(date, that.date) && + Objects.equals(documentDate, that.documentDate) && + Objects.equals(valueDate, that.valueDate) && Objects.equals(action, that.action) && Objects.equals(amount, that.amount) && - Objects.equals(comment, that.comment) && - Objects.equals(memberId, that.memberId); + Objects.equals(remark, that.remark) && + Objects.equals(membershipId, that.membershipId); } @Override public int hashCode() { return Objects.hash( id, - date, + documentDate, + valueDate, action, amount, - comment, - memberId + remark, + membershipId ); } @@ -125,11 +137,12 @@ public class AssetCriteria implements Serializable { public String toString() { return "AssetCriteria{" + (id != null ? "id=" + id + ", " : "") + - (date != null ? "date=" + date + ", " : "") + + (documentDate != null ? "documentDate=" + documentDate + ", " : "") + + (valueDate != null ? "valueDate=" + valueDate + ", " : "") + (action != null ? "action=" + action + ", " : "") + (amount != null ? "amount=" + amount + ", " : "") + - (comment != null ? "comment=" + comment + ", " : "") + - (memberId != null ? "memberId=" + memberId + ", " : "") + + (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 index 9897321a..2ed0d828 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java @@ -14,7 +14,10 @@ public class AssetDTO implements Serializable { private Long id; @NotNull - private LocalDate date; + private LocalDate documentDate; + + @NotNull + private LocalDate valueDate; @NotNull private AssetAction action; @@ -23,10 +26,12 @@ public class AssetDTO implements Serializable { private BigDecimal amount; @Size(max = 160) - private String comment; + private String remark; - private Long memberId; + private Long membershipId; + + private String membershipDocumentDate; public Long getId() { return id; @@ -36,12 +41,20 @@ public class AssetDTO implements Serializable { this.id = id; } - public LocalDate getDate() { - return date; + public LocalDate getDocumentDate() { + return documentDate; } - public void setDate(LocalDate date) { - this.date = date; + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValueDate() { + return valueDate; + } + + public void setValueDate(LocalDate valueDate) { + this.valueDate = valueDate; } public AssetAction getAction() { @@ -60,20 +73,28 @@ public class AssetDTO implements Serializable { this.amount = amount; } - public String getComment() { - return comment; + public String getRemark() { + return remark; } - public void setComment(String comment) { - this.comment = comment; + public void setRemark(String remark) { + this.remark = remark; } - public Long getMemberId() { - return memberId; + public Long getMembershipId() { + return membershipId; } - public void setMemberId(Long membershipId) { - this.memberId = membershipId; + public void setMembershipId(Long membershipId) { + this.membershipId = membershipId; + } + + public String getMembershipDocumentDate() { + return membershipDocumentDate; + } + + public void setMembershipDocumentDate(String membershipDocumentDate) { + this.membershipDocumentDate = membershipDocumentDate; } @Override @@ -101,11 +122,13 @@ public class AssetDTO implements Serializable { public String toString() { return "AssetDTO{" + "id=" + getId() + - ", date='" + getDate() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", valueDate='" + getValueDate() + "'" + ", action='" + getAction() + "'" + ", amount=" + getAmount() + - ", comment='" + getComment() + "'" + - ", member=" + getMemberId() + + ", remark='" + getRemark() + "'" + + ", membership=" + getMembershipId() + + ", membership='" + getMembershipDocumentDate() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java index c46dd0d3..60d82e58 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java @@ -1,12 +1,14 @@ package org.hostsharing.hsadminng.service.dto; -import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.IntegerFilter; -import io.github.jhipster.service.filter.LongFilter; -import io.github.jhipster.service.filter.StringFilter; - import java.io.Serializable; import java.util.Objects; +import io.github.jhipster.service.filter.BooleanFilter; +import io.github.jhipster.service.filter.DoubleFilter; +import io.github.jhipster.service.filter.Filter; +import io.github.jhipster.service.filter.FloatFilter; +import io.github.jhipster.service.filter.IntegerFilter; +import io.github.jhipster.service.filter.LongFilter; +import io.github.jhipster.service.filter.StringFilter; /** * Criteria class for the Customer entity. This class is used in CustomerResource to @@ -22,24 +24,26 @@ public class CustomerCriteria implements Serializable { private LongFilter id; - private IntegerFilter number; + private IntegerFilter reference; private StringFilter prefix; private StringFilter name; - private StringFilter contractualAddress; - private StringFilter contractualSalutation; - private StringFilter billingAddress; + private StringFilter contractualAddress; private StringFilter billingSalutation; - private LongFilter roleId; + private StringFilter billingAddress; + + private StringFilter remark; private LongFilter membershipId; + private LongFilter sepamandateId; + public LongFilter getId() { return id; } @@ -48,12 +52,12 @@ public class CustomerCriteria implements Serializable { this.id = id; } - public IntegerFilter getNumber() { - return number; + public IntegerFilter getReference() { + return reference; } - public void setNumber(IntegerFilter number) { - this.number = number; + public void setReference(IntegerFilter reference) { + this.reference = reference; } public StringFilter getPrefix() { @@ -72,14 +76,6 @@ public class CustomerCriteria implements Serializable { this.name = name; } - public StringFilter getContractualAddress() { - return contractualAddress; - } - - public void setContractualAddress(StringFilter contractualAddress) { - this.contractualAddress = contractualAddress; - } - public StringFilter getContractualSalutation() { return contractualSalutation; } @@ -88,12 +84,12 @@ public class CustomerCriteria implements Serializable { this.contractualSalutation = contractualSalutation; } - public StringFilter getBillingAddress() { - return billingAddress; + public StringFilter getContractualAddress() { + return contractualAddress; } - public void setBillingAddress(StringFilter billingAddress) { - this.billingAddress = billingAddress; + public void setContractualAddress(StringFilter contractualAddress) { + this.contractualAddress = contractualAddress; } public StringFilter getBillingSalutation() { @@ -104,12 +100,20 @@ public class CustomerCriteria implements Serializable { this.billingSalutation = billingSalutation; } - public LongFilter getRoleId() { - return roleId; + public StringFilter getBillingAddress() { + return billingAddress; } - public void setRoleId(LongFilter roleId) { - this.roleId = roleId; + public void setBillingAddress(StringFilter billingAddress) { + this.billingAddress = billingAddress; + } + + public StringFilter getRemark() { + return remark; + } + + public void setRemark(StringFilter remark) { + this.remark = remark; } public LongFilter getMembershipId() { @@ -120,6 +124,14 @@ public class CustomerCriteria implements Serializable { this.membershipId = membershipId; } + public LongFilter getSepamandateId() { + return sepamandateId; + } + + public void setSepamandateId(LongFilter sepamandateId) { + this.sepamandateId = sepamandateId; + } + @Override public boolean equals(Object o) { @@ -132,30 +144,32 @@ public class CustomerCriteria implements Serializable { final CustomerCriteria that = (CustomerCriteria) o; return Objects.equals(id, that.id) && - Objects.equals(number, that.number) && + Objects.equals(reference, that.reference) && Objects.equals(prefix, that.prefix) && - Objects.equals(name, that.name) && - Objects.equals(contractualAddress, that.contractualAddress) && - Objects.equals(contractualSalutation, that.contractualSalutation) && - Objects.equals(billingAddress, that.billingAddress) && - Objects.equals(billingSalutation, that.billingSalutation) && - Objects.equals(roleId, that.roleId) && - Objects.equals(membershipId, that.membershipId); + Objects.equals(name, that.name) && + 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, - number, + reference, prefix, - name, - contractualAddress, - contractualSalutation, - billingAddress, - billingSalutation, - roleId, - membershipId + name, + contractualSalutation, + contractualAddress, + billingSalutation, + billingAddress, + remark, + membershipId, + sepamandateId ); } @@ -163,15 +177,16 @@ public class CustomerCriteria implements Serializable { public String toString() { return "CustomerCriteria{" + (id != null ? "id=" + id + ", " : "") + - (number != null ? "number=" + number + ", " : "") + + (reference != null ? "reference=" + reference + ", " : "") + (prefix != null ? "prefix=" + prefix + ", " : "") + - (name != null ? "name=" + name + ", " : "") + - (contractualAddress != null ? "contractualAddress=" + contractualAddress + ", " : "") + - (contractualSalutation != null ? "contractualSalutation=" + contractualSalutation + ", " : "") + - (billingAddress != null ? "billingAddress=" + billingAddress + ", " : "") + - (billingSalutation != null ? "billingSalutation=" + billingSalutation + ", " : "") + - (roleId != null ? "roleId=" + roleId + ", " : "") + - (membershipId != null ? "membershipId=" + membershipId + ", " : "") + + (name != null ? "name=" + name + ", " : "") + + (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 index ff8bf3d8..6dd5c845 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java @@ -13,9 +13,10 @@ public class CustomerDTO implements Serializable { @NotNull @Min(value = 10000) @Max(value = 99999) - private Integer number; + private Integer reference; @NotNull + @Size(max = 3) @Pattern(regexp = "[a-z][a-z0-9]+") private String prefix; @@ -23,18 +24,21 @@ public class CustomerDTO implements Serializable { @Size(max = 80) private String name; + @Size(max = 80) + private String contractualSalutation; + @NotNull @Size(max = 400) private String contractualAddress; @Size(max = 80) - private String contractualSalutation; + private String billingSalutation; @Size(max = 400) private String billingAddress; - @Size(max = 80) - private String billingSalutation; + @Size(max = 160) + private String remark; public Long getId() { @@ -45,12 +49,12 @@ public class CustomerDTO implements Serializable { this.id = id; } - public Integer getNumber() { - return number; + public Integer getReference() { + return reference; } - public void setNumber(Integer number) { - this.number = number; + public void setReference(Integer reference) { + this.reference = reference; } public String getPrefix() { @@ -69,6 +73,14 @@ public class CustomerDTO implements Serializable { this.name = name; } + public String getContractualSalutation() { + return contractualSalutation; + } + + public void setContractualSalutation(String contractualSalutation) { + this.contractualSalutation = contractualSalutation; + } + public String getContractualAddress() { return contractualAddress; } @@ -77,12 +89,12 @@ public class CustomerDTO implements Serializable { this.contractualAddress = contractualAddress; } - public String getContractualSalutation() { - return contractualSalutation; + public String getBillingSalutation() { + return billingSalutation; } - public void setContractualSalutation(String contractualSalutation) { - this.contractualSalutation = contractualSalutation; + public void setBillingSalutation(String billingSalutation) { + this.billingSalutation = billingSalutation; } public String getBillingAddress() { @@ -93,12 +105,12 @@ public class CustomerDTO implements Serializable { this.billingAddress = billingAddress; } - public String getBillingSalutation() { - return billingSalutation; + public String getRemark() { + return remark; } - public void setBillingSalutation(String billingSalutation) { - this.billingSalutation = billingSalutation; + public void setRemark(String remark) { + this.remark = remark; } @Override @@ -126,13 +138,14 @@ public class CustomerDTO implements Serializable { public String toString() { return "CustomerDTO{" + "id=" + getId() + - ", number=" + getNumber() + + ", reference=" + getReference() + ", prefix='" + getPrefix() + "'" + ", name='" + getName() + "'" + - ", contractualAddress='" + getContractualAddress() + "'" + ", contractualSalutation='" + getContractualSalutation() + "'" + - ", billingAddress='" + getBillingAddress() + "'" + + ", 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 index 6e8e7b45..be8308bc 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java @@ -25,9 +25,13 @@ public class MembershipCriteria implements Serializable { private LongFilter id; - private LocalDateFilter sinceDate; + private LocalDateFilter documentDate; - private LocalDateFilter untilDate; + private LocalDateFilter memberFrom; + + private LocalDateFilter memberUntil; + + private StringFilter remark; private LongFilter shareId; @@ -43,20 +47,36 @@ public class MembershipCriteria implements Serializable { this.id = id; } - public LocalDateFilter getSinceDate() { - return sinceDate; + public LocalDateFilter getDocumentDate() { + return documentDate; } - public void setSinceDate(LocalDateFilter sinceDate) { - this.sinceDate = sinceDate; + public void setDocumentDate(LocalDateFilter documentDate) { + this.documentDate = documentDate; } - public LocalDateFilter getUntilDate() { - return untilDate; + public LocalDateFilter getMemberFrom() { + return memberFrom; } - public void setUntilDate(LocalDateFilter untilDate) { - this.untilDate = untilDate; + public void setMemberFrom(LocalDateFilter memberFrom) { + this.memberFrom = memberFrom; + } + + public LocalDateFilter getMemberUntil() { + return memberUntil; + } + + public void setMemberUntil(LocalDateFilter memberUntil) { + this.memberUntil = memberUntil; + } + + public StringFilter getRemark() { + return remark; + } + + public void setRemark(StringFilter remark) { + this.remark = remark; } public LongFilter getShareId() { @@ -95,8 +115,10 @@ public class MembershipCriteria implements Serializable { final MembershipCriteria that = (MembershipCriteria) o; return Objects.equals(id, that.id) && - Objects.equals(sinceDate, that.sinceDate) && - Objects.equals(untilDate, that.untilDate) && + Objects.equals(documentDate, that.documentDate) && + Objects.equals(memberFrom, that.memberFrom) && + Objects.equals(memberUntil, that.memberUntil) && + Objects.equals(remark, that.remark) && Objects.equals(shareId, that.shareId) && Objects.equals(assetId, that.assetId) && Objects.equals(customerId, that.customerId); @@ -106,8 +128,10 @@ public class MembershipCriteria implements Serializable { public int hashCode() { return Objects.hash( id, - sinceDate, - untilDate, + documentDate, + memberFrom, + memberUntil, + remark, shareId, assetId, customerId @@ -118,8 +142,10 @@ public class MembershipCriteria implements Serializable { public String toString() { return "MembershipCriteria{" + (id != null ? "id=" + id + ", " : "") + - (sinceDate != null ? "sinceDate=" + sinceDate + ", " : "") + - (untilDate != null ? "untilDate=" + untilDate + ", " : "") + + (documentDate != null ? "documentDate=" + documentDate + ", " : "") + + (memberFrom != null ? "memberFrom=" + memberFrom + ", " : "") + + (memberUntil != null ? "memberUntil=" + memberUntil + ", " : "") + + (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 index 12232fed..c21a0ed1 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java @@ -12,9 +12,15 @@ public class MembershipDTO implements Serializable { private Long id; @NotNull - private LocalDate sinceDate; + private LocalDate documentDate; - private LocalDate untilDate; + @NotNull + private LocalDate memberFrom; + + private LocalDate memberUntil; + + @Size(max = 160) + private String remark; private Long customerId; @@ -29,20 +35,36 @@ public class MembershipDTO implements Serializable { this.id = id; } - public LocalDate getSinceDate() { - return sinceDate; + public LocalDate getDocumentDate() { + return documentDate; } - public void setSinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; } - public LocalDate getUntilDate() { - return untilDate; + public LocalDate getMemberFrom() { + return memberFrom; } - public void setUntilDate(LocalDate untilDate) { - this.untilDate = untilDate; + public void setMemberFrom(LocalDate memberFrom) { + this.memberFrom = memberFrom; + } + + public LocalDate getMemberUntil() { + return memberUntil; + } + + public void setMemberUntil(LocalDate memberUntil) { + this.memberUntil = memberUntil; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; } public Long getCustomerId() { @@ -86,8 +108,10 @@ public class MembershipDTO implements Serializable { public String toString() { return "MembershipDTO{" + "id=" + getId() + - ", sinceDate='" + getSinceDate() + "'" + - ", untilDate='" + getUntilDate() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", memberFrom='" + getMemberFrom() + "'" + + ", memberUntil='" + getMemberUntil() + "'" + + ", 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..ce429df5 --- /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 documentDate; + + private LocalDateFilter validFrom; + + private LocalDateFilter validUntil; + + private LocalDateFilter lastUsed; + + private LocalDateFilter cancellationDate; + + 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 getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDateFilter documentDate) { + this.documentDate = documentDate; + } + + public LocalDateFilter getValidFrom() { + return validFrom; + } + + public void setValidFrom(LocalDateFilter validFrom) { + this.validFrom = validFrom; + } + + public LocalDateFilter getValidUntil() { + return validUntil; + } + + public void setValidUntil(LocalDateFilter validUntil) { + this.validUntil = validUntil; + } + + public LocalDateFilter getLastUsed() { + return lastUsed; + } + + public void setLastUsed(LocalDateFilter lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDateFilter getCancellationDate() { + return cancellationDate; + } + + public void setCancellationDate(LocalDateFilter cancellationDate) { + this.cancellationDate = cancellationDate; + } + + 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(documentDate, that.documentDate) && + Objects.equals(validFrom, that.validFrom) && + Objects.equals(validUntil, that.validUntil) && + Objects.equals(lastUsed, that.lastUsed) && + Objects.equals(cancellationDate, that.cancellationDate) && + Objects.equals(remark, that.remark) && + Objects.equals(customerId, that.customerId); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + reference, + iban, + bic, + documentDate, + validFrom, + validUntil, + lastUsed, + cancellationDate, + remark, + customerId + ); + } + + @Override + public String toString() { + return "SepaMandateCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (reference != null ? "reference=" + reference + ", " : "") + + (iban != null ? "iban=" + iban + ", " : "") + + (bic != null ? "bic=" + bic + ", " : "") + + (documentDate != null ? "documentDate=" + documentDate + ", " : "") + + (validFrom != null ? "validFrom=" + validFrom + ", " : "") + + (validUntil != null ? "validUntil=" + validUntil + ", " : "") + + (lastUsed != null ? "lastUsed=" + lastUsed + ", " : "") + + (cancellationDate != null ? "cancellationDate=" + cancellationDate + ", " : "") + + (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..c763f352 --- /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 documentDate; + + @NotNull + private LocalDate validFrom; + + private LocalDate validUntil; + + private LocalDate lastUsed; + + private LocalDate cancellationDate; + + @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 getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValidFrom() { + return validFrom; + } + + public void setValidFrom(LocalDate validFrom) { + this.validFrom = validFrom; + } + + public LocalDate getValidUntil() { + return validUntil; + } + + public void setValidUntil(LocalDate validUntil) { + this.validUntil = validUntil; + } + + public LocalDate getLastUsed() { + return lastUsed; + } + + public void setLastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDate getCancellationDate() { + return cancellationDate; + } + + public void setCancellationDate(LocalDate cancellationDate) { + this.cancellationDate = cancellationDate; + } + + 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() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", validFrom='" + getValidFrom() + "'" + + ", validUntil='" + getValidUntil() + "'" + + ", lastUsed='" + getLastUsed() + "'" + + ", cancellationDate='" + getCancellationDate() + "'" + + ", 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 index 1db1aff5..313be4d3 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java @@ -31,15 +31,17 @@ public class ShareCriteria implements Serializable { private LongFilter id; - private LocalDateFilter date; + private LocalDateFilter documentDate; + + private LocalDateFilter valueDate; private ShareActionFilter action; private IntegerFilter quantity; - private StringFilter comment; + private StringFilter remark; - private LongFilter memberId; + private LongFilter membershipId; public LongFilter getId() { return id; @@ -49,12 +51,20 @@ public class ShareCriteria implements Serializable { this.id = id; } - public LocalDateFilter getDate() { - return date; + public LocalDateFilter getDocumentDate() { + return documentDate; } - public void setDate(LocalDateFilter date) { - this.date = date; + public void setDocumentDate(LocalDateFilter documentDate) { + this.documentDate = documentDate; + } + + public LocalDateFilter getValueDate() { + return valueDate; + } + + public void setValueDate(LocalDateFilter valueDate) { + this.valueDate = valueDate; } public ShareActionFilter getAction() { @@ -73,20 +83,20 @@ public class ShareCriteria implements Serializable { this.quantity = quantity; } - public StringFilter getComment() { - return comment; + public StringFilter getRemark() { + return remark; } - public void setComment(StringFilter comment) { - this.comment = comment; + public void setRemark(StringFilter remark) { + this.remark = remark; } - public LongFilter getMemberId() { - return memberId; + public LongFilter getMembershipId() { + return membershipId; } - public void setMemberId(LongFilter memberId) { - this.memberId = memberId; + public void setMembershipId(LongFilter membershipId) { + this.membershipId = membershipId; } @@ -101,22 +111,24 @@ public class ShareCriteria implements Serializable { final ShareCriteria that = (ShareCriteria) o; return Objects.equals(id, that.id) && - Objects.equals(date, that.date) && + Objects.equals(documentDate, that.documentDate) && + Objects.equals(valueDate, that.valueDate) && Objects.equals(action, that.action) && Objects.equals(quantity, that.quantity) && - Objects.equals(comment, that.comment) && - Objects.equals(memberId, that.memberId); + Objects.equals(remark, that.remark) && + Objects.equals(membershipId, that.membershipId); } @Override public int hashCode() { return Objects.hash( id, - date, + documentDate, + valueDate, action, quantity, - comment, - memberId + remark, + membershipId ); } @@ -124,11 +136,12 @@ public class ShareCriteria implements Serializable { public String toString() { return "ShareCriteria{" + (id != null ? "id=" + id + ", " : "") + - (date != null ? "date=" + date + ", " : "") + + (documentDate != null ? "documentDate=" + documentDate + ", " : "") + + (valueDate != null ? "valueDate=" + valueDate + ", " : "") + (action != null ? "action=" + action + ", " : "") + (quantity != null ? "quantity=" + quantity + ", " : "") + - (comment != null ? "comment=" + comment + ", " : "") + - (memberId != null ? "memberId=" + memberId + ", " : "") + + (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 index 1ae37049..e9f873fa 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java @@ -13,7 +13,10 @@ public class ShareDTO implements Serializable { private Long id; @NotNull - private LocalDate date; + private LocalDate documentDate; + + @NotNull + private LocalDate valueDate; @NotNull private ShareAction action; @@ -22,10 +25,12 @@ public class ShareDTO implements Serializable { private Integer quantity; @Size(max = 160) - private String comment; + private String remark; - private Long memberId; + private Long membershipId; + + private String membershipDocumentDate; public Long getId() { return id; @@ -35,12 +40,20 @@ public class ShareDTO implements Serializable { this.id = id; } - public LocalDate getDate() { - return date; + public LocalDate getDocumentDate() { + return documentDate; } - public void setDate(LocalDate date) { - this.date = date; + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValueDate() { + return valueDate; + } + + public void setValueDate(LocalDate valueDate) { + this.valueDate = valueDate; } public ShareAction getAction() { @@ -59,20 +72,28 @@ public class ShareDTO implements Serializable { this.quantity = quantity; } - public String getComment() { - return comment; + public String getRemark() { + return remark; } - public void setComment(String comment) { - this.comment = comment; + public void setRemark(String remark) { + this.remark = remark; } - public Long getMemberId() { - return memberId; + public Long getMembershipId() { + return membershipId; } - public void setMemberId(Long membershipId) { - this.memberId = membershipId; + public void setMembershipId(Long membershipId) { + this.membershipId = membershipId; + } + + public String getMembershipDocumentDate() { + return membershipDocumentDate; + } + + public void setMembershipDocumentDate(String membershipDocumentDate) { + this.membershipDocumentDate = membershipDocumentDate; } @Override @@ -100,11 +121,13 @@ public class ShareDTO implements Serializable { public String toString() { return "ShareDTO{" + "id=" + getId() + - ", date='" + getDate() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", valueDate='" + getValueDate() + "'" + ", action='" + getAction() + "'" + ", quantity=" + getQuantity() + - ", comment='" + getComment() + "'" + - ", member=" + getMemberId() + + ", remark='" + getRemark() + "'" + + ", membership=" + getMembershipId() + + ", membership='" + getMembershipDocumentDate() + "'" + "}"; } } diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java index 5d39692e..d43fc5c0 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java @@ -11,10 +11,11 @@ import org.mapstruct.*; @Mapper(componentModel = "spring", uses = {MembershipMapper.class}) public interface AssetMapper extends EntityMapper { - @Mapping(source = "member.id", target = "memberId") + @Mapping(source = "membership.id", target = "membershipId") + @Mapping(source = "membership.documentDate", target = "membershipDocumentDate") AssetDTO toDto(Asset asset); - @Mapping(source = "memberId", target = "member") + @Mapping(source = "membershipId", target = "membership") Asset toEntity(AssetDTO assetDTO); default Asset fromId(Long id) { diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java index 4bb2f1e9..6c9c204a 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java @@ -1,9 +1,9 @@ package org.hostsharing.hsadminng.service.mapper; -import org.hostsharing.hsadminng.domain.Customer; +import org.hostsharing.hsadminng.domain.*; import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; + +import org.mapstruct.*; /** * Mapper for the entity Customer and its DTO CustomerDTO. @@ -12,8 +12,8 @@ import org.mapstruct.Mapping; public interface CustomerMapper extends EntityMapper { - @Mapping(target = "roles", ignore = true) @Mapping(target = "memberships", ignore = true) + @Mapping(target = "sepamandates", ignore = true) Customer toEntity(CustomerDTO customerDTO); default Customer fromId(Long id) { 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 index c5ed7f33..6867130d 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java +++ b/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java @@ -11,10 +11,11 @@ import org.mapstruct.*; @Mapper(componentModel = "spring", uses = {MembershipMapper.class}) public interface ShareMapper extends EntityMapper { - @Mapping(source = "member.id", target = "memberId") + @Mapping(source = "membership.id", target = "membershipId") + @Mapping(source = "membership.documentDate", target = "membershipDocumentDate") ShareDTO toDto(Share share); - @Mapping(source = "memberId", target = "member") + @Mapping(source = "membershipId", target = "membership") Share toEntity(ShareDTO shareDTO); default Share fromId(Long id) { 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/jdl/customer.jdl b/src/main/jdl/customer.jdl index 14b17d8f..9af8c485 100644 --- a/src/main/jdl/customer.jdl +++ b/src/main/jdl/customer.jdl @@ -1,37 +1,24 @@ filter all dto all with mapstruct service all with serviceClass -paginate all with infinite-scroll +paginate all with infinite-scroll entity Customer { - number Integer required unique min(10000) max(99999), - prefix String required unique pattern(/[a-z][a-z0-9]+/), + 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), - contractualAddress String required maxlength(400), contractualSalutation String maxlength(80), + contractualAddress String required maxlength(400), + billingSalutation String maxlength(80), billingAddress String maxlength(400), - billingSalutation String maxlength(80) -} - -entity Contact { - firstName String required maxlength(80), - lastName String required maxlength(80), - email String required maxlength(80) -} - -enum CustomerContactRole { - CONTRACTUAL, - TECHNICAL, - FINANCIAL -} - -entity CustomerContact { - role CustomerContactRole required + remark String maxlength(160) } entity Membership { - sinceDate LocalDate required, - untilDate LocalDate + documentDate LocalDate required, + memberFrom LocalDate required, + memberUntil LocalDate, + remark String maxlength(160) } enum ShareAction { @@ -40,10 +27,11 @@ enum ShareAction { } entity Share { - date LocalDate required, + documentDate LocalDate required, + valueDate LocalDate required, action ShareAction required, quantity Integer required, - comment String maxlength(160) + remark String maxlength(160) } enum AssetAction { @@ -56,17 +44,28 @@ enum AssetAction { } entity Asset { - date LocalDate required, + documentDate LocalDate required, + valueDate LocalDate required, action AssetAction required, amount BigDecimal required, - comment String maxlength(160) + remark String maxlength(160) +} + +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, + remark String maxlength(160) } relationship OneToMany { - Contact{role} to CustomerContact{contact(email) required}, - Customer{role} to CustomerContact{customer(prefix) required}, - Customer to Membership{customer(prefix) required}, - Membership to Share{member required}, - Membership to Asset{member required} + 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} } - diff --git a/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml b/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml index b888eebe..598384eb 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml @@ -1,8 +1,10 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> @@ -19,32 +21,36 @@ - - + + - + - - - - - + - + - - + + - + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml b/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml index 95973eb5..3daf95d2 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml @@ -1,8 +1,10 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> @@ -19,16 +21,24 @@ - + - + + + + + + + + + - + diff --git a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml b/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml index 24fd082a..2d7dee4e 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml @@ -1,8 +1,10 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> @@ -19,7 +21,11 @@ - + + + + + @@ -31,12 +37,12 @@ - + - - + + diff --git a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml b/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml index a5b4cebd..05c38a08 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml @@ -8,9 +8,9 @@ --> - diff --git a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml b/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml index 682f4e2c..94abb9e1 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml @@ -1,8 +1,10 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> @@ -19,7 +21,11 @@ - + + + + + @@ -31,12 +37,12 @@ - + - - + + diff --git a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml b/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml index 329a22b8..16ce148f 100644 --- a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml +++ b/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml @@ -8,9 +8,9 @@ --> - diff --git a/src/main/resources/config/liquibase/changelog/20190418100951_added_entity_SepaMandate.xml b/src/main/resources/config/liquibase/changelog/20190418100951_added_entity_SepaMandate.xml new file mode 100644 index 00000000..17a2e0bf --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418100951_added_entity_SepaMandate.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418100951_added_entity_constraints_SepaMandate.xml b/src/main/resources/config/liquibase/changelog/20190418100951_added_entity_constraints_SepaMandate.xml new file mode 100644 index 00000000..019bba36 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418100951_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 97a01937..48e094e9 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -11,10 +11,12 @@ + + diff --git a/src/main/webapp/app/entities/asset/asset-detail.component.html b/src/main/webapp/app/entities/asset/asset-detail.component.html index 29a4b452..c259a165 100644 --- a/src/main/webapp/app/entities/asset/asset-detail.component.html +++ b/src/main/webapp/app/entities/asset/asset-detail.component.html @@ -5,9 +5,13 @@
    -
    Date
    +
    Document Date
    - {{asset.date}} + {{asset.documentDate}} +
    +
    Value Date
    +
    + {{asset.valueDate}}
    Action
    @@ -17,14 +21,14 @@
    {{asset.amount}}
    -
    Comment
    +
    Remark
    - {{asset.comment}} + {{asset.remark}}
    -
    Member
    +
    Membership
    -
    diff --git a/src/main/webapp/app/entities/asset/asset-update.component.html b/src/main/webapp/app/entities/asset/asset-update.component.html index 0e1fa8d1..cc48af42 100644 --- a/src/main/webapp/app/entities/asset/asset-update.component.html +++ b/src/main/webapp/app/entities/asset/asset-update.component.html @@ -10,17 +10,33 @@ [(ngModel)]="asset.id" readonly />
    - +
    - - +
    -
    +
    + [hidden]="!editForm.controls.documentDate?.errors?.required" jhiTranslate="entity.validation.required"> + This field is required. + +
    +
    +
    + +
    + + + + +
    +
    + This field is required.
    @@ -58,28 +74,27 @@
    - - -
    + + +
    + [hidden]="!editForm.controls.remark?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 160 }"> This field cannot be longer than 160 characters.
    - - + +
    -
    +
    + [hidden]="!editForm.controls.membership?.errors?.required" jhiTranslate="entity.validation.required"> 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 index 98147937..a58ab009 100644 --- a/src/main/webapp/app/entities/asset/asset-update.component.ts +++ b/src/main/webapp/app/entities/asset/asset-update.component.ts @@ -19,7 +19,8 @@ export class AssetUpdateComponent implements OnInit { isSaving: boolean; memberships: IMembership[]; - dateDp: any; + documentDateDp: any; + valueDateDp: any; constructor( protected jhiAlertService: JhiAlertService, diff --git a/src/main/webapp/app/entities/asset/asset.component.html b/src/main/webapp/app/entities/asset/asset.component.html index 0ac03e8f..8fac5e46 100644 --- a/src/main/webapp/app/entities/asset/asset.component.html +++ b/src/main/webapp/app/entities/asset/asset.component.html @@ -15,24 +15,26 @@ ID - Date + Document Date + Value Date Action Amount - Comment - Member + Remark + Membership {{asset.id}} - {{asset.date | date:'mediumDate'}} + {{asset.documentDate | date:'mediumDate'}} + {{asset.valueDate | date:'mediumDate'}} {{asset.action}} {{asset.amount}} - {{asset.comment}} + {{asset.remark}} -
    - {{asset.memberId}} + diff --git a/src/main/webapp/app/entities/asset/asset.service.ts b/src/main/webapp/app/entities/asset/asset.service.ts index 9ef5cbde..379d2cec 100644 --- a/src/main/webapp/app/entities/asset/asset.service.ts +++ b/src/main/webapp/app/entities/asset/asset.service.ts @@ -51,14 +51,16 @@ export class AssetService { protected convertDateFromClient(asset: IAsset): IAsset { const copy: IAsset = Object.assign({}, asset, { - date: asset.date != null && asset.date.isValid() ? asset.date.format(DATE_FORMAT) : null + 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.date = res.body.date != null ? moment(res.body.date) : null; + 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; } @@ -66,7 +68,8 @@ export class AssetService { protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { if (res.body) { res.body.forEach((asset: IAsset) => { - asset.date = asset.date != null ? moment(asset.date) : null; + 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/customer/customer-detail.component.html b/src/main/webapp/app/entities/customer/customer-detail.component.html index fbf98ec0..a3d1343c 100644 --- a/src/main/webapp/app/entities/customer/customer-detail.component.html +++ b/src/main/webapp/app/entities/customer/customer-detail.component.html @@ -5,9 +5,9 @@
    -
    Number
    +
    Reference
    - {{customer.number}} + {{customer.reference}}
    Prefix
    @@ -17,21 +17,25 @@
    {{customer.name}}
    +
    Contractual Salutation
    +
    + {{customer.contractualSalutation}} +
    Contractual Address
    {{customer.contractualAddress}}
    -
    Contractual Salutation
    +
    Billing Salutation
    - {{customer.contractualSalutation}} + {{customer.billingSalutation}}
    Billing Address
    {{customer.billingAddress}}
    -
    Billing Salutation
    +
    Remark
    - {{customer.billingSalutation}} + {{customer.remark}}
    diff --git a/src/main/webapp/app/entities/customer/customer-update.component.html b/src/main/webapp/app/entities/customer/customer-update.component.html index 43f9d079..de0d7818 100644 --- a/src/main/webapp/app/entities/customer/customer-update.component.html +++ b/src/main/webapp/app/entities/customer/customer-update.component.html @@ -10,24 +10,24 @@ [(ngModel)]="customer.id" readonly />
    - - -
    + + +
    + [hidden]="!editForm.controls.reference?.errors?.required" jhiTranslate="entity.validation.required"> This field is required. + [hidden]="!editForm.controls.reference?.errors?.min" jhiTranslate="entity.validation.min" [translateValues]="{ min: 10000 }"> This field should be at least 10000. + [hidden]="!editForm.controls.reference?.errors?.max" jhiTranslate="entity.validation.max" [translateValues]="{ max: 99999 }"> This field cannot be more than 99999. + [hidden]="!editForm.controls.reference?.errors?.number" jhiTranslate="entity.validation.number"> This field should be a number.
    @@ -35,12 +35,16 @@
    + [(ngModel)]="customer.prefix" required maxlength="3" pattern="[a-z][a-z0-9]+"/>
    This field is required. + + This field cannot be longer than 3 characters. + This field should follow pattern for "Prefix". @@ -48,82 +52,76 @@
    - + + [(ngModel)]="customer.name" required maxlength="80"/>
    - This field is required. + [hidden]="!editForm.controls.name?.errors?.required" jhiTranslate="entity.validation.required"> + This field is required. - This field cannot be longer than 80 characters. + [hidden]="!editForm.controls.name?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 80 }"> + This field cannot be longer than 80 characters.
    - + + +
    + + This field cannot be longer than 80 characters. + +
    +
    +
    + -
    + [(ngModel)]="customer.contractualAddress" required maxlength="400"/> +
    - This field is required. + [hidden]="!editForm.controls.contractualAddress?.errors?.required" jhiTranslate="entity.validation.required"> + This field is required. - This field cannot be longer than 400 characters. + [hidden]="!editForm.controls.contractualAddress?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 400 }"> + This field cannot be longer than 400 characters.
    - - -
    - - This field cannot be longer than 80 characters. - -
    -
    -
    - - -
    - - This field cannot be longer than 400 characters. - -
    -
    -
    - + -
    + [(ngModel)]="customer.billingSalutation" maxlength="80"/> +
    - This field cannot be longer than 80 characters. + [hidden]="!editForm.controls.billingSalutation?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 80 }"> + 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.component.html b/src/main/webapp/app/entities/customer/customer.component.html index def61b53..38405029 100644 --- a/src/main/webapp/app/entities/customer/customer.component.html +++ b/src/main/webapp/app/entities/customer/customer.component.html @@ -15,37 +15,28 @@ ID - Number + Reference Prefix - Name - - - Contractual Address - - - Contractual Salutation - - - Billing Address - - - Billing Salutation - - + Name + Contractual Salutation + Contractual Address + Billing Salutation + Billing Address + Remark {{customer.id}} - {{customer.number}} + {{customer.reference}} {{customer.prefix}} {{customer.name}} - {{customer.contractualAddress}} {{customer.contractualSalutation}} - {{customer.billingAddress}} + {{customer.contractualAddress}} {{customer.billingSalutation}} + {{customer.billingAddress}} + {{customer.remark}}
    - +
    - - +
    -
    +
    + [hidden]="!editForm.controls.documentDate?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
    - +
    - + + + +
    +
    + + This field is required. + +
    +
    +
    + +
    + - +
    +
    + + +
    + + This field cannot be longer than 160 characters. + +
    +
    -
    + [hidden]="!editForm.controls.customer?.errors?.required" jhiTranslate="entity.validation.required"> This field is required.
    diff --git a/src/main/webapp/app/entities/membership/membership-update.component.ts b/src/main/webapp/app/entities/membership/membership-update.component.ts index 92d41047..1f68bfc2 100644 --- a/src/main/webapp/app/entities/membership/membership-update.component.ts +++ b/src/main/webapp/app/entities/membership/membership-update.component.ts @@ -19,8 +19,9 @@ export class MembershipUpdateComponent implements OnInit { isSaving: boolean; customers: ICustomer[]; - sinceDateDp: any; - untilDateDp: any; + documentDateDp: any; + memberFromDp: any; + memberUntilDp: any; constructor( protected jhiAlertService: JhiAlertService, diff --git a/src/main/webapp/app/entities/membership/membership.component.html b/src/main/webapp/app/entities/membership/membership.component.html index 075546a4..6852205f 100644 --- a/src/main/webapp/app/entities/membership/membership.component.html +++ b/src/main/webapp/app/entities/membership/membership.component.html @@ -15,8 +15,10 @@ ID - Since Date - Until Date + Document Date + Member From + Member Until + Remark Customer @@ -24,8 +26,10 @@ {{membership.id}} - {{membership.sinceDate | date:'mediumDate'}} - {{membership.untilDate | date:'mediumDate'}} + {{membership.documentDate | date:'mediumDate'}} + {{membership.memberFrom | date:'mediumDate'}} + {{membership.memberUntil | date:'mediumDate'}} + {{membership.remark}}
    {{membership.customerPrefix}} diff --git a/src/main/webapp/app/entities/membership/membership.service.ts b/src/main/webapp/app/entities/membership/membership.service.ts index 95388263..c0fb3e77 100644 --- a/src/main/webapp/app/entities/membership/membership.service.ts +++ b/src/main/webapp/app/entities/membership/membership.service.ts @@ -51,16 +51,20 @@ export class MembershipService { protected convertDateFromClient(membership: IMembership): IMembership { const copy: IMembership = Object.assign({}, membership, { - sinceDate: membership.sinceDate != null && membership.sinceDate.isValid() ? membership.sinceDate.format(DATE_FORMAT) : null, - untilDate: membership.untilDate != null && membership.untilDate.isValid() ? membership.untilDate.format(DATE_FORMAT) : null + documentDate: + membership.documentDate != null && membership.documentDate.isValid() ? membership.documentDate.format(DATE_FORMAT) : null, + memberFrom: membership.memberFrom != null && membership.memberFrom.isValid() ? membership.memberFrom.format(DATE_FORMAT) : null, + memberUntil: + membership.memberUntil != null && membership.memberUntil.isValid() ? membership.memberUntil.format(DATE_FORMAT) : null }); return copy; } protected convertDateFromServer(res: EntityResponseType): EntityResponseType { if (res.body) { - res.body.sinceDate = res.body.sinceDate != null ? moment(res.body.sinceDate) : null; - res.body.untilDate = res.body.untilDate != null ? moment(res.body.untilDate) : null; + res.body.documentDate = res.body.documentDate != null ? moment(res.body.documentDate) : null; + res.body.memberFrom = res.body.memberFrom != null ? moment(res.body.memberFrom) : null; + res.body.memberUntil = res.body.memberUntil != null ? moment(res.body.memberUntil) : null; } return res; } @@ -68,8 +72,9 @@ export class MembershipService { protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { if (res.body) { res.body.forEach((membership: IMembership) => { - membership.sinceDate = membership.sinceDate != null ? moment(membership.sinceDate) : null; - membership.untilDate = membership.untilDate != null ? moment(membership.untilDate) : null; + membership.documentDate = membership.documentDate != null ? moment(membership.documentDate) : null; + membership.memberFrom = membership.memberFrom != null ? moment(membership.memberFrom) : null; + membership.memberUntil = membership.memberUntil != null ? moment(membership.memberUntil) : null; }); } 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..5b87977f --- /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}} +
    +
    Document Date
    +
    + {{sepaMandate.documentDate}} +
    +
    Valid From
    +
    + {{sepaMandate.validFrom}} +
    +
    Valid Until
    +
    + {{sepaMandate.validUntil}} +
    +
    Last Used
    +
    + {{sepaMandate.lastUsed}} +
    +
    Cancellation Date
    +
    + {{sepaMandate.cancellationDate}} +
    +
    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..c4803427 --- /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..ba809340 --- /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[]; + documentDateDp: any; + validFromDp: any; + validUntilDp: any; + lastUsedDp: any; + cancellationDateDp: 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..21976ea7 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html @@ -0,0 +1,76 @@ +
    +

    + Sepa Mandates + +

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ID Reference Iban Bic Document Date Valid From Valid Until Last Used Cancellation Date Remark Customer
    {{sepaMandate.id}}{{sepaMandate.reference}}{{sepaMandate.iban}}{{sepaMandate.bic}}{{sepaMandate.documentDate | date:'mediumDate'}}{{sepaMandate.validFrom | date:'mediumDate'}}{{sepaMandate.validUntil | date:'mediumDate'}}{{sepaMandate.lastUsed | date:'mediumDate'}}{{sepaMandate.cancellationDate | date:'mediumDate'}}{{sepaMandate.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..17a9584a --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts @@ -0,0 +1,93 @@ +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, { + documentDate: + sepaMandate.documentDate != null && sepaMandate.documentDate.isValid() + ? sepaMandate.documentDate.format(DATE_FORMAT) + : null, + validFrom: sepaMandate.validFrom != null && sepaMandate.validFrom.isValid() ? sepaMandate.validFrom.format(DATE_FORMAT) : null, + validUntil: + sepaMandate.validUntil != null && sepaMandate.validUntil.isValid() ? sepaMandate.validUntil.format(DATE_FORMAT) : null, + lastUsed: sepaMandate.lastUsed != null && sepaMandate.lastUsed.isValid() ? sepaMandate.lastUsed.format(DATE_FORMAT) : null, + cancellationDate: + sepaMandate.cancellationDate != null && sepaMandate.cancellationDate.isValid() + ? sepaMandate.cancellationDate.format(DATE_FORMAT) + : null + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.documentDate = res.body.documentDate != null ? moment(res.body.documentDate) : null; + res.body.validFrom = res.body.validFrom != null ? moment(res.body.validFrom) : null; + res.body.validUntil = res.body.validUntil != null ? moment(res.body.validUntil) : null; + res.body.lastUsed = res.body.lastUsed != null ? moment(res.body.lastUsed) : null; + res.body.cancellationDate = res.body.cancellationDate != null ? moment(res.body.cancellationDate) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((sepaMandate: ISepaMandate) => { + sepaMandate.documentDate = sepaMandate.documentDate != null ? moment(sepaMandate.documentDate) : null; + sepaMandate.validFrom = sepaMandate.validFrom != null ? moment(sepaMandate.validFrom) : null; + sepaMandate.validUntil = sepaMandate.validUntil != null ? moment(sepaMandate.validUntil) : null; + sepaMandate.lastUsed = sepaMandate.lastUsed != null ? moment(sepaMandate.lastUsed) : null; + sepaMandate.cancellationDate = sepaMandate.cancellationDate != null ? moment(sepaMandate.cancellationDate) : null; + }); + } + return res; + } +} diff --git a/src/main/webapp/app/entities/share/share-detail.component.html b/src/main/webapp/app/entities/share/share-detail.component.html index 24ba66c1..505a8591 100644 --- a/src/main/webapp/app/entities/share/share-detail.component.html +++ b/src/main/webapp/app/entities/share/share-detail.component.html @@ -5,9 +5,13 @@
    -
    Date
    +
    Document Date
    - {{share.date}} + {{share.documentDate}} +
    +
    Value Date
    +
    + {{share.valueDate}}
    Action
    @@ -17,14 +21,14 @@
    {{share.quantity}}
    -
    Comment
    +
    Remark
    - {{share.comment}} + {{share.remark}}
    -
    Member
    +
    Membership
    -
    diff --git a/src/main/webapp/app/entities/share/share-update.component.html b/src/main/webapp/app/entities/share/share-update.component.html index 3f092ec3..34d6853c 100644 --- a/src/main/webapp/app/entities/share/share-update.component.html +++ b/src/main/webapp/app/entities/share/share-update.component.html @@ -10,17 +10,33 @@ [(ngModel)]="share.id" readonly />
    - +
    - - +
    -
    +
    + [hidden]="!editForm.controls.documentDate?.errors?.required" jhiTranslate="entity.validation.required"> + This field is required. + +
    +
    +
    + +
    + + + + +
    +
    + This field is required.
    @@ -54,28 +70,27 @@
    - - -
    + + +
    + [hidden]="!editForm.controls.remark?.errors?.maxlength" jhiTranslate="entity.validation.maxlength" [translateValues]="{ max: 160 }"> This field cannot be longer than 160 characters.
    - - + +
    -
    +
    + [hidden]="!editForm.controls.membership?.errors?.required" jhiTranslate="entity.validation.required"> 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 index 677a033c..e7301309 100644 --- a/src/main/webapp/app/entities/share/share-update.component.ts +++ b/src/main/webapp/app/entities/share/share-update.component.ts @@ -19,7 +19,8 @@ export class ShareUpdateComponent implements OnInit { isSaving: boolean; memberships: IMembership[]; - dateDp: any; + documentDateDp: any; + valueDateDp: any; constructor( protected jhiAlertService: JhiAlertService, diff --git a/src/main/webapp/app/entities/share/share.component.html b/src/main/webapp/app/entities/share/share.component.html index 82cead44..81c23e25 100644 --- a/src/main/webapp/app/entities/share/share.component.html +++ b/src/main/webapp/app/entities/share/share.component.html @@ -15,24 +15,26 @@ ID - Date + Document Date + Value Date Action Quantity - Comment - Member + Remark + Membership {{share.id}} - {{share.date | date:'mediumDate'}} + {{share.documentDate | date:'mediumDate'}} + {{share.valueDate | date:'mediumDate'}} {{share.action}} {{share.quantity}} - {{share.comment}} + {{share.remark}} -
    - {{share.memberId}} + diff --git a/src/main/webapp/app/entities/share/share.service.ts b/src/main/webapp/app/entities/share/share.service.ts index 4b9389b3..d9bf57ec 100644 --- a/src/main/webapp/app/entities/share/share.service.ts +++ b/src/main/webapp/app/entities/share/share.service.ts @@ -51,14 +51,16 @@ export class ShareService { protected convertDateFromClient(share: IShare): IShare { const copy: IShare = Object.assign({}, share, { - date: share.date != null && share.date.isValid() ? share.date.format(DATE_FORMAT) : null + 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.date = res.body.date != null ? moment(res.body.date) : null; + 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; } @@ -66,7 +68,8 @@ export class ShareService { protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { if (res.body) { res.body.forEach((share: IShare) => { - share.date = share.date != null ? moment(share.date) : null; + 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 201ff3aa..b9e2451a 100644 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -63,6 +63,12 @@ Asset +
  • + + + Sepa Mandate + +
  • diff --git a/src/main/webapp/app/shared/model/asset.model.ts b/src/main/webapp/app/shared/model/asset.model.ts index aa577d11..7964c1f7 100644 --- a/src/main/webapp/app/shared/model/asset.model.ts +++ b/src/main/webapp/app/shared/model/asset.model.ts @@ -11,20 +11,24 @@ export const enum AssetAction { export interface IAsset { id?: number; - date?: Moment; + documentDate?: Moment; + valueDate?: Moment; action?: AssetAction; amount?: number; - comment?: string; - memberId?: number; + remark?: string; + membershipDocumentDate?: string; + membershipId?: number; } export class Asset implements IAsset { constructor( public id?: number, - public date?: Moment, + public documentDate?: Moment, + public valueDate?: Moment, public action?: AssetAction, public amount?: number, - public comment?: string, - public memberId?: number + public remark?: string, + public membershipDocumentDate?: string, + public membershipId?: number ) {} } diff --git a/src/main/webapp/app/shared/model/customer.model.ts b/src/main/webapp/app/shared/model/customer.model.ts index d876bd10..1970b289 100644 --- a/src/main/webapp/app/shared/model/customer.model.ts +++ b/src/main/webapp/app/shared/model/customer.model.ts @@ -1,30 +1,32 @@ -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; import { IMembership } from 'app/shared/model/membership.model'; +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; export interface ICustomer { id?: number; - number?: number; + reference?: number; prefix?: string; name?: string; - contractualAddress?: string; contractualSalutation?: string; - billingAddress?: string; + contractualAddress?: string; billingSalutation?: string; - roles?: ICustomerContact[]; + billingAddress?: string; + remark?: string; memberships?: IMembership[]; + sepamandates?: ISepaMandate[]; } export class Customer implements ICustomer { constructor( public id?: number, - public number?: number, + public reference?: number, public prefix?: string, public name?: string, - public contractualAddress?: string, public contractualSalutation?: string, - public billingAddress?: string, + public contractualAddress?: string, public billingSalutation?: string, - public roles?: ICustomerContact[], - public memberships?: IMembership[] + 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 index f1ad5337..57418782 100644 --- a/src/main/webapp/app/shared/model/membership.model.ts +++ b/src/main/webapp/app/shared/model/membership.model.ts @@ -4,8 +4,10 @@ import { IAsset } from 'app/shared/model/asset.model'; export interface IMembership { id?: number; - sinceDate?: Moment; - untilDate?: Moment; + documentDate?: Moment; + memberFrom?: Moment; + memberUntil?: Moment; + remark?: string; shares?: IShare[]; assets?: IAsset[]; customerPrefix?: string; @@ -15,8 +17,10 @@ export interface IMembership { export class Membership implements IMembership { constructor( public id?: number, - public sinceDate?: Moment, - public untilDate?: Moment, + public documentDate?: Moment, + public memberFrom?: Moment, + public memberUntil?: Moment, + public remark?: string, public shares?: IShare[], public assets?: IAsset[], public customerPrefix?: string, 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..feccc941 --- /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; + documentDate?: Moment; + validFrom?: Moment; + validUntil?: Moment; + lastUsed?: Moment; + cancellationDate?: 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 documentDate?: Moment, + public validFrom?: Moment, + public validUntil?: Moment, + public lastUsed?: Moment, + public cancellationDate?: Moment, + public remark?: string, + public customerPrefix?: string, + public customerId?: number + ) {} +} diff --git a/src/main/webapp/app/shared/model/share.model.ts b/src/main/webapp/app/shared/model/share.model.ts index c3eb8cce..5338867a 100644 --- a/src/main/webapp/app/shared/model/share.model.ts +++ b/src/main/webapp/app/shared/model/share.model.ts @@ -7,20 +7,24 @@ export const enum ShareAction { export interface IShare { id?: number; - date?: Moment; + documentDate?: Moment; + valueDate?: Moment; action?: ShareAction; quantity?: number; - comment?: string; - memberId?: number; + remark?: string; + membershipDocumentDate?: string; + membershipId?: number; } export class Share implements IShare { constructor( public id?: number, - public date?: Moment, + public documentDate?: Moment, + public valueDate?: Moment, public action?: ShareAction, public quantity?: number, - public comment?: string, - public memberId?: number + public remark?: string, + public membershipDocumentDate?: string, + public membershipId?: number ) {} } diff --git a/src/main/webapp/i18n/de/asset.json b/src/main/webapp/i18n/de/asset.json index 8f36a53f..ff6df7e7 100644 --- a/src/main/webapp/i18n/de/asset.json +++ b/src/main/webapp/i18n/de/asset.json @@ -15,11 +15,12 @@ "detail": { "title": "Asset" }, - "date": "Date", + "documentDate": "Document Date", + "valueDate": "Value Date", "action": "Action", "amount": "Amount", - "comment": "Comment", - "member": "Member" + "remark": "Remark", + "membership": "Membership" } } } diff --git a/src/main/webapp/i18n/de/customer.json b/src/main/webapp/i18n/de/customer.json index 407c3863..a699be5a 100644 --- a/src/main/webapp/i18n/de/customer.json +++ b/src/main/webapp/i18n/de/customer.json @@ -15,15 +15,16 @@ "detail": { "title": "Customer" }, - "number": "Number", + "reference": "Reference", "prefix": "Prefix", "name": "Name", - "contractualAddress": "Contractual Address", "contractualSalutation": "Contractual Salutation", - "billingAddress": "Billing Address", + "contractualAddress": "Contractual Address", "billingSalutation": "Billing Salutation", - "role": "Role", - "membership": "Membership" + "billingAddress": "Billing Address", + "remark": "Remark", + "membership": "Membership", + "sepamandate": "Sepamandate" } } } diff --git a/src/main/webapp/i18n/de/global.json b/src/main/webapp/i18n/de/global.json index f6ef880f..86dfbb52 100644 --- a/src/main/webapp/i18n/de/global.json +++ b/src/main/webapp/i18n/de/global.json @@ -13,6 +13,7 @@ "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 index 95fb3f58..936c4fc9 100644 --- a/src/main/webapp/i18n/de/membership.json +++ b/src/main/webapp/i18n/de/membership.json @@ -15,8 +15,10 @@ "detail": { "title": "Membership" }, - "sinceDate": "Since Date", - "untilDate": "Until Date", + "documentDate": "Document Date", + "memberFrom": "Member From", + "memberUntil": "Member Until", + "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..c0d1347b --- /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", + "documentDate": "Document Date", + "validFrom": "Valid From", + "validUntil": "Valid Until", + "lastUsed": "Last Used", + "cancellationDate": "Cancellation Date", + "remark": "Remark", + "customer": "Customer" + } + } +} diff --git a/src/main/webapp/i18n/de/share.json b/src/main/webapp/i18n/de/share.json index 702f8f83..fdb5dec4 100644 --- a/src/main/webapp/i18n/de/share.json +++ b/src/main/webapp/i18n/de/share.json @@ -15,11 +15,12 @@ "detail": { "title": "Share" }, - "date": "Date", + "documentDate": "Document Date", + "valueDate": "Value Date", "action": "Action", "quantity": "Quantity", - "comment": "Comment", - "member": "Member" + "remark": "Remark", + "membership": "Membership" } } } diff --git a/src/main/webapp/i18n/en/asset.json b/src/main/webapp/i18n/en/asset.json index 128f5716..ac290fb7 100644 --- a/src/main/webapp/i18n/en/asset.json +++ b/src/main/webapp/i18n/en/asset.json @@ -15,11 +15,12 @@ "detail": { "title": "Asset" }, - "date": "Date", + "documentDate": "Document Date", + "valueDate": "Value Date", "action": "Action", "amount": "Amount", - "comment": "Comment", - "member": "Member" + "remark": "Remark", + "membership": "Membership" } } } diff --git a/src/main/webapp/i18n/en/customer.json b/src/main/webapp/i18n/en/customer.json index b58c1345..6f30090f 100644 --- a/src/main/webapp/i18n/en/customer.json +++ b/src/main/webapp/i18n/en/customer.json @@ -15,15 +15,16 @@ "detail": { "title": "Customer" }, - "number": "Number", + "reference": "Reference", "prefix": "Prefix", "name": "Name", - "contractualAddress": "Contractual Address", "contractualSalutation": "Contractual Salutation", - "billingAddress": "Billing Address", + "contractualAddress": "Contractual Address", "billingSalutation": "Billing Salutation", - "role": "Role", - "membership": "Membership" + "billingAddress": "Billing Address", + "remark": "Remark", + "membership": "Membership", + "sepamandate": "Sepamandate" } } } diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index 3b496f5b..c978e2d9 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -13,6 +13,7 @@ "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 index 08b7f156..9bf9136c 100644 --- a/src/main/webapp/i18n/en/membership.json +++ b/src/main/webapp/i18n/en/membership.json @@ -15,8 +15,10 @@ "detail": { "title": "Membership" }, - "sinceDate": "Since Date", - "untilDate": "Until Date", + "documentDate": "Document Date", + "memberFrom": "Member From", + "memberUntil": "Member Until", + "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..a403e016 --- /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", + "documentDate": "Document Date", + "validFrom": "Valid From", + "validUntil": "Valid Until", + "lastUsed": "Last Used", + "cancellationDate": "Cancellation Date", + "remark": "Remark", + "customer": "Customer" + } + } +} diff --git a/src/main/webapp/i18n/en/share.json b/src/main/webapp/i18n/en/share.json index 06637120..5c178744 100644 --- a/src/main/webapp/i18n/en/share.json +++ b/src/main/webapp/i18n/en/share.json @@ -15,11 +15,12 @@ "detail": { "title": "Share" }, - "date": "Date", + "documentDate": "Document Date", + "valueDate": "Value Date", "action": "Action", "quantity": "Quantity", - "comment": "Comment", - "member": "Member" + "remark": "Remark", + "membership": "Membership" } } } diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java index 80dc172a..99a0217f 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java @@ -1,15 +1,17 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; + import org.hostsharing.hsadminng.domain.Asset; import org.hostsharing.hsadminng.domain.Membership; -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; import org.hostsharing.hsadminng.repository.AssetRepository; -import org.hostsharing.hsadminng.service.AssetQueryService; import org.hostsharing.hsadminng.service.AssetService; import org.hostsharing.hsadminng.service.dto.AssetDTO; import org.hostsharing.hsadminng.service.mapper.AssetMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.AssetCriteria; +import org.hostsharing.hsadminng.service.AssetQueryService; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,11 +33,14 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; + +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import org.hostsharing.hsadminng.domain.enumeration.AssetAction; /** * Test class for the AssetResource REST controller. * @@ -45,8 +50,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(classes = HsadminNgApp.class) public class AssetResourceIntTest { - private static final LocalDate DEFAULT_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_DATE = LocalDate.now(ZoneId.systemDefault()); + 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; @@ -54,8 +62,8 @@ public class AssetResourceIntTest { private static final BigDecimal DEFAULT_AMOUNT = new BigDecimal(1); private static final BigDecimal UPDATED_AMOUNT = new BigDecimal(2); - private static final String DEFAULT_COMMENT = "AAAAAAAAAA"; - private static final String UPDATED_COMMENT = "BBBBBBBBBB"; + private static final String DEFAULT_REMARK = "AAAAAAAAAA"; + private static final String UPDATED_REMARK = "BBBBBBBBBB"; @Autowired private AssetRepository assetRepository; @@ -108,15 +116,16 @@ public class AssetResourceIntTest { */ public static Asset createEntity(EntityManager em) { Asset asset = new Asset() - .date(DEFAULT_DATE) + .documentDate(DEFAULT_DOCUMENT_DATE) + .valueDate(DEFAULT_VALUE_DATE) .action(DEFAULT_ACTION) .amount(DEFAULT_AMOUNT) - .comment(DEFAULT_COMMENT); + .remark(DEFAULT_REMARK); // Add required entity Membership membership = MembershipResourceIntTest.createEntity(em); em.persist(membership); em.flush(); - asset.setMember(membership); + asset.setMembership(membership); return asset; } @@ -141,10 +150,11 @@ public class AssetResourceIntTest { List assetList = assetRepository.findAll(); assertThat(assetList).hasSize(databaseSizeBeforeCreate + 1); Asset testAsset = assetList.get(assetList.size() - 1); - assertThat(testAsset.getDate()).isEqualTo(DEFAULT_DATE); + 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.getComment()).isEqualTo(DEFAULT_COMMENT); + assertThat(testAsset.getRemark()).isEqualTo(DEFAULT_REMARK); } @Test @@ -169,10 +179,29 @@ public class AssetResourceIntTest { @Test @Transactional - public void checkDateIsRequired() throws Exception { + public void checkDocumentDateIsRequired() throws Exception { int databaseSizeBeforeTest = assetRepository.findAll().size(); // set the field null - asset.setDate(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); @@ -235,10 +264,11 @@ public class AssetResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(asset.getId().intValue()))) - .andExpect(jsonPath("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) + .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("$.[*].comment").value(hasItem(DEFAULT_COMMENT.toString()))); + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); } @Test @@ -252,75 +282,142 @@ public class AssetResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(asset.getId().intValue())) - .andExpect(jsonPath("$.date").value(DEFAULT_DATE.toString())) + .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("$.comment").value(DEFAULT_COMMENT.toString())); + .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); } @Test @Transactional - public void getAllAssetsByDateIsEqualToSomething() throws Exception { + public void getAllAssetsByDocumentDateIsEqualToSomething() throws Exception { // Initialize the database assetRepository.saveAndFlush(asset); - // Get all the assetList where date equals to DEFAULT_DATE - defaultAssetShouldBeFound("date.equals=" + DEFAULT_DATE); + // Get all the assetList where documentDate equals to DEFAULT_DOCUMENT_DATE + defaultAssetShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); - // Get all the assetList where date equals to UPDATED_DATE - defaultAssetShouldNotBeFound("date.equals=" + UPDATED_DATE); + // Get all the assetList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultAssetShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); } @Test @Transactional - public void getAllAssetsByDateIsInShouldWork() throws Exception { + public void getAllAssetsByDocumentDateIsInShouldWork() throws Exception { // Initialize the database assetRepository.saveAndFlush(asset); - // Get all the assetList where date in DEFAULT_DATE or UPDATED_DATE - defaultAssetShouldBeFound("date.in=" + DEFAULT_DATE + "," + UPDATED_DATE); + // 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 date equals to UPDATED_DATE - defaultAssetShouldNotBeFound("date.in=" + UPDATED_DATE); + // Get all the assetList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultAssetShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); } @Test @Transactional - public void getAllAssetsByDateIsNullOrNotNull() throws Exception { + public void getAllAssetsByDocumentDateIsNullOrNotNull() throws Exception { // Initialize the database assetRepository.saveAndFlush(asset); - // Get all the assetList where date is not null - defaultAssetShouldBeFound("date.specified=true"); + // Get all the assetList where documentDate is not null + defaultAssetShouldBeFound("documentDate.specified=true"); - // Get all the assetList where date is null - defaultAssetShouldNotBeFound("date.specified=false"); + // Get all the assetList where documentDate is null + defaultAssetShouldNotBeFound("documentDate.specified=false"); } @Test @Transactional - public void getAllAssetsByDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllAssetsByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database assetRepository.saveAndFlush(asset); - // Get all the assetList where date greater than or equals to DEFAULT_DATE - defaultAssetShouldBeFound("date.greaterOrEqualThan=" + DEFAULT_DATE); + // 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 date greater than or equals to UPDATED_DATE - defaultAssetShouldNotBeFound("date.greaterOrEqualThan=" + UPDATED_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 getAllAssetsByDateIsLessThanSomething() throws Exception { + public void getAllAssetsByDocumentDateIsLessThanSomething() throws Exception { // Initialize the database assetRepository.saveAndFlush(asset); - // Get all the assetList where date less than or equals to DEFAULT_DATE - defaultAssetShouldNotBeFound("date.lessThan=" + DEFAULT_DATE); + // 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 date less than or equals to UPDATED_DATE - defaultAssetShouldBeFound("date.lessThan=" + UPDATED_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); } @@ -404,59 +501,59 @@ public class AssetResourceIntTest { @Test @Transactional - public void getAllAssetsByCommentIsEqualToSomething() throws Exception { + public void getAllAssetsByRemarkIsEqualToSomething() throws Exception { // Initialize the database assetRepository.saveAndFlush(asset); - // Get all the assetList where comment equals to DEFAULT_COMMENT - defaultAssetShouldBeFound("comment.equals=" + DEFAULT_COMMENT); + // Get all the assetList where remark equals to DEFAULT_REMARK + defaultAssetShouldBeFound("remark.equals=" + DEFAULT_REMARK); - // Get all the assetList where comment equals to UPDATED_COMMENT - defaultAssetShouldNotBeFound("comment.equals=" + UPDATED_COMMENT); + // Get all the assetList where remark equals to UPDATED_REMARK + defaultAssetShouldNotBeFound("remark.equals=" + UPDATED_REMARK); } @Test @Transactional - public void getAllAssetsByCommentIsInShouldWork() throws Exception { + public void getAllAssetsByRemarkIsInShouldWork() throws Exception { // Initialize the database assetRepository.saveAndFlush(asset); - // Get all the assetList where comment in DEFAULT_COMMENT or UPDATED_COMMENT - defaultAssetShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT); + // Get all the assetList where remark in DEFAULT_REMARK or UPDATED_REMARK + defaultAssetShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK); - // Get all the assetList where comment equals to UPDATED_COMMENT - defaultAssetShouldNotBeFound("comment.in=" + UPDATED_COMMENT); + // Get all the assetList where remark equals to UPDATED_REMARK + defaultAssetShouldNotBeFound("remark.in=" + UPDATED_REMARK); } @Test @Transactional - public void getAllAssetsByCommentIsNullOrNotNull() throws Exception { + public void getAllAssetsByRemarkIsNullOrNotNull() throws Exception { // Initialize the database assetRepository.saveAndFlush(asset); - // Get all the assetList where comment is not null - defaultAssetShouldBeFound("comment.specified=true"); + // Get all the assetList where remark is not null + defaultAssetShouldBeFound("remark.specified=true"); - // Get all the assetList where comment is null - defaultAssetShouldNotBeFound("comment.specified=false"); + // Get all the assetList where remark is null + defaultAssetShouldNotBeFound("remark.specified=false"); } @Test @Transactional - public void getAllAssetsByMemberIsEqualToSomething() throws Exception { + public void getAllAssetsByMembershipIsEqualToSomething() throws Exception { // Initialize the database - Membership member = MembershipResourceIntTest.createEntity(em); - em.persist(member); + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); em.flush(); - asset.setMember(member); + asset.setMembership(membership); assetRepository.saveAndFlush(asset); - Long memberId = member.getId(); + Long membershipId = membership.getId(); - // Get all the assetList where member equals to memberId - defaultAssetShouldBeFound("memberId.equals=" + memberId); + // Get all the assetList where membership equals to membershipId + defaultAssetShouldBeFound("membershipId.equals=" + membershipId); - // Get all the assetList where member equals to memberId + 1 - defaultAssetShouldNotBeFound("memberId.equals=" + (memberId + 1)); + // Get all the assetList where membership equals to membershipId + 1 + defaultAssetShouldNotBeFound("membershipId.equals=" + (membershipId + 1)); } /** @@ -467,10 +564,11 @@ public class AssetResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(asset.getId().intValue()))) - .andExpect(jsonPath("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) + .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("$.[*].comment").value(hasItem(DEFAULT_COMMENT))); + .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)) @@ -518,10 +616,11 @@ public class AssetResourceIntTest { // Disconnect from session so that the updates on updatedAsset are not directly saved in db em.detach(updatedAsset); updatedAsset - .date(UPDATED_DATE) + .documentDate(UPDATED_DOCUMENT_DATE) + .valueDate(UPDATED_VALUE_DATE) .action(UPDATED_ACTION) .amount(UPDATED_AMOUNT) - .comment(UPDATED_COMMENT); + .remark(UPDATED_REMARK); AssetDTO assetDTO = assetMapper.toDto(updatedAsset); restAssetMockMvc.perform(put("/api/assets") @@ -533,10 +632,11 @@ public class AssetResourceIntTest { List assetList = assetRepository.findAll(); assertThat(assetList).hasSize(databaseSizeBeforeUpdate); Asset testAsset = assetList.get(assetList.size() - 1); - assertThat(testAsset.getDate()).isEqualTo(UPDATED_DATE); + 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.getComment()).isEqualTo(UPDATED_COMMENT); + assertThat(testAsset.getRemark()).isEqualTo(UPDATED_REMARK); } @Test diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java index d22cad45..d8fa9656 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java @@ -1,15 +1,18 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; + import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.CustomerContact; import org.hostsharing.hsadminng.domain.Membership; +import org.hostsharing.hsadminng.domain.SepaMandate; import org.hostsharing.hsadminng.repository.CustomerRepository; -import org.hostsharing.hsadminng.service.CustomerQueryService; import org.hostsharing.hsadminng.service.CustomerService; import org.hostsharing.hsadminng.service.dto.CustomerDTO; import org.hostsharing.hsadminng.service.mapper.CustomerMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.CustomerCriteria; +import org.hostsharing.hsadminng.service.CustomerQueryService; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,9 +31,10 @@ import org.springframework.validation.Validator; import javax.persistence.EntityManager; import java.util.List; + +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -43,8 +47,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(classes = HsadminNgApp.class) public class CustomerResourceIntTest { - private static final Integer DEFAULT_NUMBER = 10000; - private static final Integer UPDATED_NUMBER = 10001; + private static final Integer DEFAULT_REFERENCE = 10000; + private static final Integer UPDATED_REFERENCE = 10001; private static final String DEFAULT_PREFIX = "lzv"; private static final String UPDATED_PREFIX = "zf"; @@ -52,17 +56,20 @@ public class CustomerResourceIntTest { private static final String DEFAULT_NAME = "AAAAAAAAAA"; private static final String UPDATED_NAME = "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_CONTRACTUAL_SALUTATION = "AAAAAAAAAA"; - private static final String UPDATED_CONTRACTUAL_SALUTATION = "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_BILLING_SALUTATION = "AAAAAAAAAA"; - private static final String UPDATED_BILLING_SALUTATION = "BBBBBBBBBB"; + private static final String DEFAULT_REMARK = "AAAAAAAAAA"; + private static final String UPDATED_REMARK = "BBBBBBBBBB"; @Autowired private CustomerRepository customerRepository; @@ -115,13 +122,14 @@ public class CustomerResourceIntTest { */ public static Customer createEntity(EntityManager em) { Customer customer = new Customer() - .number(DEFAULT_NUMBER) + .reference(DEFAULT_REFERENCE) .prefix(DEFAULT_PREFIX) .name(DEFAULT_NAME) - .contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS) .contractualSalutation(DEFAULT_CONTRACTUAL_SALUTATION) + .contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS) + .billingSalutation(DEFAULT_BILLING_SALUTATION) .billingAddress(DEFAULT_BILLING_ADDRESS) - .billingSalutation(DEFAULT_BILLING_SALUTATION); + .remark(DEFAULT_REMARK); return customer; } @@ -146,13 +154,14 @@ public class CustomerResourceIntTest { List customerList = customerRepository.findAll(); assertThat(customerList).hasSize(databaseSizeBeforeCreate + 1); Customer testCustomer = customerList.get(customerList.size() - 1); - assertThat(testCustomer.getNumber()).isEqualTo(DEFAULT_NUMBER); + assertThat(testCustomer.getReference()).isEqualTo(DEFAULT_REFERENCE); assertThat(testCustomer.getPrefix()).isEqualTo(DEFAULT_PREFIX); assertThat(testCustomer.getName()).isEqualTo(DEFAULT_NAME); - assertThat(testCustomer.getContractualAddress()).isEqualTo(DEFAULT_CONTRACTUAL_ADDRESS); assertThat(testCustomer.getContractualSalutation()).isEqualTo(DEFAULT_CONTRACTUAL_SALUTATION); - assertThat(testCustomer.getBillingAddress()).isEqualTo(DEFAULT_BILLING_ADDRESS); + 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 @@ -177,10 +186,10 @@ public class CustomerResourceIntTest { @Test @Transactional - public void checkNumberIsRequired() throws Exception { + public void checkReferenceIsRequired() throws Exception { int databaseSizeBeforeTest = customerRepository.findAll().size(); // set the field null - customer.setNumber(null); + customer.setReference(null); // Create the Customer, which fails. CustomerDTO customerDTO = customerMapper.toDto(customer); @@ -262,13 +271,14 @@ public class CustomerResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(customer.getId().intValue()))) - .andExpect(jsonPath("$.[*].number").value(hasItem(DEFAULT_NUMBER))) + .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("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS.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("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION.toString()))); + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); } @Test @@ -282,78 +292,79 @@ public class CustomerResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(customer.getId().intValue())) - .andExpect(jsonPath("$.number").value(DEFAULT_NUMBER)) + .andExpect(jsonPath("$.reference").value(DEFAULT_REFERENCE)) .andExpect(jsonPath("$.prefix").value(DEFAULT_PREFIX.toString())) .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())) - .andExpect(jsonPath("$.contractualAddress").value(DEFAULT_CONTRACTUAL_ADDRESS.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("$.billingSalutation").value(DEFAULT_BILLING_SALUTATION.toString())); + .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); } @Test @Transactional - public void getAllCustomersByNumberIsEqualToSomething() throws Exception { + public void getAllCustomersByReferenceIsEqualToSomething() throws Exception { // Initialize the database customerRepository.saveAndFlush(customer); - // Get all the customerList where number equals to DEFAULT_NUMBER - defaultCustomerShouldBeFound("number.equals=" + DEFAULT_NUMBER); + // Get all the customerList where reference equals to DEFAULT_REFERENCE + defaultCustomerShouldBeFound("reference.equals=" + DEFAULT_REFERENCE); - // Get all the customerList where number equals to UPDATED_NUMBER - defaultCustomerShouldNotBeFound("number.equals=" + UPDATED_NUMBER); + // Get all the customerList where reference equals to UPDATED_REFERENCE + defaultCustomerShouldNotBeFound("reference.equals=" + UPDATED_REFERENCE); } @Test @Transactional - public void getAllCustomersByNumberIsInShouldWork() throws Exception { + public void getAllCustomersByReferenceIsInShouldWork() throws Exception { // Initialize the database customerRepository.saveAndFlush(customer); - // Get all the customerList where number in DEFAULT_NUMBER or UPDATED_NUMBER - defaultCustomerShouldBeFound("number.in=" + DEFAULT_NUMBER + "," + UPDATED_NUMBER); + // Get all the customerList where reference in DEFAULT_REFERENCE or UPDATED_REFERENCE + defaultCustomerShouldBeFound("reference.in=" + DEFAULT_REFERENCE + "," + UPDATED_REFERENCE); - // Get all the customerList where number equals to UPDATED_NUMBER - defaultCustomerShouldNotBeFound("number.in=" + UPDATED_NUMBER); + // Get all the customerList where reference equals to UPDATED_REFERENCE + defaultCustomerShouldNotBeFound("reference.in=" + UPDATED_REFERENCE); } @Test @Transactional - public void getAllCustomersByNumberIsNullOrNotNull() throws Exception { + public void getAllCustomersByReferenceIsNullOrNotNull() throws Exception { // Initialize the database customerRepository.saveAndFlush(customer); - // Get all the customerList where number is not null - defaultCustomerShouldBeFound("number.specified=true"); + // Get all the customerList where reference is not null + defaultCustomerShouldBeFound("reference.specified=true"); - // Get all the customerList where number is null - defaultCustomerShouldNotBeFound("number.specified=false"); + // Get all the customerList where reference is null + defaultCustomerShouldNotBeFound("reference.specified=false"); } @Test @Transactional - public void getAllCustomersByNumberIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllCustomersByReferenceIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database customerRepository.saveAndFlush(customer); - // Get all the customerList where number greater than or equals to DEFAULT_NUMBER - defaultCustomerShouldBeFound("number.greaterOrEqualThan=" + DEFAULT_NUMBER); + // Get all the customerList where reference greater than or equals to DEFAULT_REFERENCE + defaultCustomerShouldBeFound("reference.greaterOrEqualThan=" + DEFAULT_REFERENCE); - // Get all the customerList where number greater than or equals to (DEFAULT_NUMBER + 1) - defaultCustomerShouldNotBeFound("number.greaterOrEqualThan=" + (DEFAULT_NUMBER + 1)); + // Get all the customerList where reference greater than or equals to (DEFAULT_REFERENCE + 1) + defaultCustomerShouldNotBeFound("reference.greaterOrEqualThan=" + (DEFAULT_REFERENCE + 1)); } @Test @Transactional - public void getAllCustomersByNumberIsLessThanSomething() throws Exception { + public void getAllCustomersByReferenceIsLessThanSomething() throws Exception { // Initialize the database customerRepository.saveAndFlush(customer); - // Get all the customerList where number less than or equals to DEFAULT_NUMBER - defaultCustomerShouldNotBeFound("number.lessThan=" + DEFAULT_NUMBER); + // Get all the customerList where reference less than or equals to DEFAULT_REFERENCE + defaultCustomerShouldNotBeFound("reference.lessThan=" + DEFAULT_REFERENCE); - // Get all the customerList where number less than or equals to (DEFAULT_NUMBER + 1) - defaultCustomerShouldBeFound("number.lessThan=" + (DEFAULT_NUMBER + 1)); + // Get all the customerList where reference less than or equals to (DEFAULT_REFERENCE + 1) + defaultCustomerShouldBeFound("reference.lessThan=" + (DEFAULT_REFERENCE + 1)); } @@ -435,45 +446,6 @@ public class CustomerResourceIntTest { defaultCustomerShouldNotBeFound("name.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 getAllCustomersByContractualSalutationIsEqualToSomething() throws Exception { @@ -515,41 +487,41 @@ public class CustomerResourceIntTest { @Test @Transactional - public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception { + public void getAllCustomersByContractualAddressIsEqualToSomething() 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 contractualAddress equals to DEFAULT_CONTRACTUAL_ADDRESS + defaultCustomerShouldBeFound("contractualAddress.equals=" + DEFAULT_CONTRACTUAL_ADDRESS); - // Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS - defaultCustomerShouldNotBeFound("billingAddress.equals=" + UPDATED_BILLING_ADDRESS); + // Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldNotBeFound("contractualAddress.equals=" + UPDATED_CONTRACTUAL_ADDRESS); } @Test @Transactional - public void getAllCustomersByBillingAddressIsInShouldWork() throws Exception { + public void getAllCustomersByContractualAddressIsInShouldWork() 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 contractualAddress in DEFAULT_CONTRACTUAL_ADDRESS or UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldBeFound("contractualAddress.in=" + DEFAULT_CONTRACTUAL_ADDRESS + "," + UPDATED_CONTRACTUAL_ADDRESS); - // Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS - defaultCustomerShouldNotBeFound("billingAddress.in=" + UPDATED_BILLING_ADDRESS); + // Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS + defaultCustomerShouldNotBeFound("contractualAddress.in=" + UPDATED_CONTRACTUAL_ADDRESS); } @Test @Transactional - public void getAllCustomersByBillingAddressIsNullOrNotNull() throws Exception { + public void getAllCustomersByContractualAddressIsNullOrNotNull() 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 contractualAddress is not null + defaultCustomerShouldBeFound("contractualAddress.specified=true"); - // Get all the customerList where billingAddress is null - defaultCustomerShouldNotBeFound("billingAddress.specified=false"); + // Get all the customerList where contractualAddress is null + defaultCustomerShouldNotBeFound("contractualAddress.specified=false"); } @Test @@ -593,22 +565,81 @@ public class CustomerResourceIntTest { @Test @Transactional - public void getAllCustomersByRoleIsEqualToSomething() throws Exception { + public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception { // Initialize the database - CustomerContact role = CustomerContactResourceIntTest.createEntity(em); - em.persist(role); - em.flush(); - customer.addRole(role); customerRepository.saveAndFlush(customer); - Long roleId = role.getId(); - // Get all the customerList where role equals to roleId - defaultCustomerShouldBeFound("roleId.equals=" + roleId); + // Get all the customerList where billingAddress equals to DEFAULT_BILLING_ADDRESS + defaultCustomerShouldBeFound("billingAddress.equals=" + DEFAULT_BILLING_ADDRESS); - // Get all the customerList where role equals to roleId + 1 - defaultCustomerShouldNotBeFound("roleId.equals=" + (roleId + 1)); + // 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 @@ -628,6 +659,25 @@ public class CustomerResourceIntTest { 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 */ @@ -636,13 +686,14 @@ public class CustomerResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(customer.getId().intValue()))) - .andExpect(jsonPath("$.[*].number").value(hasItem(DEFAULT_NUMBER))) + .andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE))) .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX))) .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))) - .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS))) .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("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION))); + .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)) @@ -690,13 +741,14 @@ public class CustomerResourceIntTest { // Disconnect from session so that the updates on updatedCustomer are not directly saved in db em.detach(updatedCustomer); updatedCustomer - .number(UPDATED_NUMBER) + .reference(UPDATED_REFERENCE) .prefix(UPDATED_PREFIX) .name(UPDATED_NAME) - .contractualAddress(UPDATED_CONTRACTUAL_ADDRESS) .contractualSalutation(UPDATED_CONTRACTUAL_SALUTATION) + .contractualAddress(UPDATED_CONTRACTUAL_ADDRESS) + .billingSalutation(UPDATED_BILLING_SALUTATION) .billingAddress(UPDATED_BILLING_ADDRESS) - .billingSalutation(UPDATED_BILLING_SALUTATION); + .remark(UPDATED_REMARK); CustomerDTO customerDTO = customerMapper.toDto(updatedCustomer); restCustomerMockMvc.perform(put("/api/customers") @@ -708,13 +760,14 @@ public class CustomerResourceIntTest { List customerList = customerRepository.findAll(); assertThat(customerList).hasSize(databaseSizeBeforeUpdate); Customer testCustomer = customerList.get(customerList.size() - 1); - assertThat(testCustomer.getNumber()).isEqualTo(UPDATED_NUMBER); + assertThat(testCustomer.getReference()).isEqualTo(UPDATED_REFERENCE); assertThat(testCustomer.getPrefix()).isEqualTo(UPDATED_PREFIX); assertThat(testCustomer.getName()).isEqualTo(UPDATED_NAME); - assertThat(testCustomer.getContractualAddress()).isEqualTo(UPDATED_CONTRACTUAL_ADDRESS); assertThat(testCustomer.getContractualSalutation()).isEqualTo(UPDATED_CONTRACTUAL_SALUTATION); - assertThat(testCustomer.getBillingAddress()).isEqualTo(UPDATED_BILLING_ADDRESS); + 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 diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java index 97b8eed0..a267711d 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java @@ -1,16 +1,19 @@ package org.hostsharing.hsadminng.web.rest; import org.hostsharing.hsadminng.HsadminNgApp; -import org.hostsharing.hsadminng.domain.Asset; -import org.hostsharing.hsadminng.domain.Customer; + import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.domain.Share; +import org.hostsharing.hsadminng.domain.Asset; +import org.hostsharing.hsadminng.domain.Customer; import org.hostsharing.hsadminng.repository.MembershipRepository; -import org.hostsharing.hsadminng.service.MembershipQueryService; import org.hostsharing.hsadminng.service.MembershipService; import org.hostsharing.hsadminng.service.dto.MembershipDTO; import org.hostsharing.hsadminng.service.mapper.MembershipMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.MembershipCriteria; +import org.hostsharing.hsadminng.service.MembershipQueryService; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,9 +34,10 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; + +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -46,11 +50,17 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(classes = HsadminNgApp.class) public class MembershipResourceIntTest { - private static final LocalDate DEFAULT_SINCE_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_SINCE_DATE = LocalDate.now(ZoneId.systemDefault()); + 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_UNTIL_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault()); + private static final LocalDate DEFAULT_MEMBER_FROM = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_MEMBER_FROM = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_MEMBER_UNTIL = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_MEMBER_UNTIL = LocalDate.now(ZoneId.systemDefault()); + + private static final String DEFAULT_REMARK = "AAAAAAAAAA"; + private static final String UPDATED_REMARK = "BBBBBBBBBB"; @Autowired private MembershipRepository membershipRepository; @@ -103,8 +113,10 @@ public class MembershipResourceIntTest { */ public static Membership createEntity(EntityManager em) { Membership membership = new Membership() - .sinceDate(DEFAULT_SINCE_DATE) - .untilDate(DEFAULT_UNTIL_DATE); + .documentDate(DEFAULT_DOCUMENT_DATE) + .memberFrom(DEFAULT_MEMBER_FROM) + .memberUntil(DEFAULT_MEMBER_UNTIL) + .remark(DEFAULT_REMARK); // Add required entity Customer customer = CustomerResourceIntTest.createEntity(em); em.persist(customer); @@ -134,8 +146,10 @@ public class MembershipResourceIntTest { List membershipList = membershipRepository.findAll(); assertThat(membershipList).hasSize(databaseSizeBeforeCreate + 1); Membership testMembership = membershipList.get(membershipList.size() - 1); - assertThat(testMembership.getSinceDate()).isEqualTo(DEFAULT_SINCE_DATE); - assertThat(testMembership.getUntilDate()).isEqualTo(DEFAULT_UNTIL_DATE); + assertThat(testMembership.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE); + assertThat(testMembership.getMemberFrom()).isEqualTo(DEFAULT_MEMBER_FROM); + assertThat(testMembership.getMemberUntil()).isEqualTo(DEFAULT_MEMBER_UNTIL); + assertThat(testMembership.getRemark()).isEqualTo(DEFAULT_REMARK); } @Test @@ -160,10 +174,29 @@ public class MembershipResourceIntTest { @Test @Transactional - public void checkSinceDateIsRequired() throws Exception { + public void checkDocumentDateIsRequired() throws Exception { int databaseSizeBeforeTest = membershipRepository.findAll().size(); // set the field null - membership.setSinceDate(null); + membership.setDocumentDate(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 checkMemberFromIsRequired() throws Exception { + int databaseSizeBeforeTest = membershipRepository.findAll().size(); + // set the field null + membership.setMemberFrom(null); // Create the Membership, which fails. MembershipDTO membershipDTO = membershipMapper.toDto(membership); @@ -188,8 +221,10 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue()))) - .andExpect(jsonPath("$.[*].sinceDate").value(hasItem(DEFAULT_SINCE_DATE.toString()))) - .andExpect(jsonPath("$.[*].untilDate").value(hasItem(DEFAULT_UNTIL_DATE.toString()))); + .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString()))) + .andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); } @Test @@ -203,142 +238,249 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(membership.getId().intValue())) - .andExpect(jsonPath("$.sinceDate").value(DEFAULT_SINCE_DATE.toString())) - .andExpect(jsonPath("$.untilDate").value(DEFAULT_UNTIL_DATE.toString())); + .andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.memberFrom").value(DEFAULT_MEMBER_FROM.toString())) + .andExpect(jsonPath("$.memberUntil").value(DEFAULT_MEMBER_UNTIL.toString())) + .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); } @Test @Transactional - public void getAllMembershipsBySinceDateIsEqualToSomething() throws Exception { + public void getAllMembershipsByDocumentDateIsEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate equals to DEFAULT_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.equals=" + DEFAULT_SINCE_DATE); + // Get all the membershipList where documentDate equals to DEFAULT_DOCUMENT_DATE + defaultMembershipShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); - // Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.equals=" + UPDATED_SINCE_DATE); + // Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsBySinceDateIsInShouldWork() throws Exception { + public void getAllMembershipsByDocumentDateIsInShouldWork() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate in DEFAULT_SINCE_DATE or UPDATED_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.in=" + DEFAULT_SINCE_DATE + "," + UPDATED_SINCE_DATE); + // Get all the membershipList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE + defaultMembershipShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE); - // Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.in=" + UPDATED_SINCE_DATE); + // Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsBySinceDateIsNullOrNotNull() throws Exception { + public void getAllMembershipsByDocumentDateIsNullOrNotNull() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate is not null - defaultMembershipShouldBeFound("sinceDate.specified=true"); + // Get all the membershipList where documentDate is not null + defaultMembershipShouldBeFound("documentDate.specified=true"); - // Get all the membershipList where sinceDate is null - defaultMembershipShouldNotBeFound("sinceDate.specified=false"); + // Get all the membershipList where documentDate is null + defaultMembershipShouldNotBeFound("documentDate.specified=false"); } @Test @Transactional - public void getAllMembershipsBySinceDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllMembershipsByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate greater than or equals to DEFAULT_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.greaterOrEqualThan=" + DEFAULT_SINCE_DATE); + // Get all the membershipList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE + defaultMembershipShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE); - // Get all the membershipList where sinceDate greater than or equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.greaterOrEqualThan=" + UPDATED_SINCE_DATE); + // Get all the membershipList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsBySinceDateIsLessThanSomething() throws Exception { + public void getAllMembershipsByDocumentDateIsLessThanSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where sinceDate less than or equals to DEFAULT_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.lessThan=" + DEFAULT_SINCE_DATE); + // Get all the membershipList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE); - // Get all the membershipList where sinceDate less than or equals to UPDATED_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.lessThan=" + UPDATED_SINCE_DATE); + // Get all the membershipList where documentDate less than or equals to UPDATED_DOCUMENT_DATE + defaultMembershipShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE); } @Test @Transactional - public void getAllMembershipsByUntilDateIsEqualToSomething() throws Exception { + public void getAllMembershipsByMemberFromIsEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.equals=" + DEFAULT_UNTIL_DATE); + // Get all the membershipList where memberFrom equals to DEFAULT_MEMBER_FROM + defaultMembershipShouldBeFound("memberFrom.equals=" + DEFAULT_MEMBER_FROM); - // Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.equals=" + UPDATED_UNTIL_DATE); + // Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM + defaultMembershipShouldNotBeFound("memberFrom.equals=" + UPDATED_MEMBER_FROM); } @Test @Transactional - public void getAllMembershipsByUntilDateIsInShouldWork() throws Exception { + public void getAllMembershipsByMemberFromIsInShouldWork() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate in DEFAULT_UNTIL_DATE or UPDATED_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.in=" + DEFAULT_UNTIL_DATE + "," + UPDATED_UNTIL_DATE); + // Get all the membershipList where memberFrom in DEFAULT_MEMBER_FROM or UPDATED_MEMBER_FROM + defaultMembershipShouldBeFound("memberFrom.in=" + DEFAULT_MEMBER_FROM + "," + UPDATED_MEMBER_FROM); - // Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.in=" + UPDATED_UNTIL_DATE); + // Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM + defaultMembershipShouldNotBeFound("memberFrom.in=" + UPDATED_MEMBER_FROM); } @Test @Transactional - public void getAllMembershipsByUntilDateIsNullOrNotNull() throws Exception { + public void getAllMembershipsByMemberFromIsNullOrNotNull() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate is not null - defaultMembershipShouldBeFound("untilDate.specified=true"); + // Get all the membershipList where memberFrom is not null + defaultMembershipShouldBeFound("memberFrom.specified=true"); - // Get all the membershipList where untilDate is null - defaultMembershipShouldNotBeFound("untilDate.specified=false"); + // Get all the membershipList where memberFrom is null + defaultMembershipShouldNotBeFound("memberFrom.specified=false"); } @Test @Transactional - public void getAllMembershipsByUntilDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllMembershipsByMemberFromIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate greater than or equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.greaterOrEqualThan=" + DEFAULT_UNTIL_DATE); + // Get all the membershipList where memberFrom greater than or equals to DEFAULT_MEMBER_FROM + defaultMembershipShouldBeFound("memberFrom.greaterOrEqualThan=" + DEFAULT_MEMBER_FROM); - // Get all the membershipList where untilDate greater than or equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.greaterOrEqualThan=" + UPDATED_UNTIL_DATE); + // Get all the membershipList where memberFrom greater than or equals to UPDATED_MEMBER_FROM + defaultMembershipShouldNotBeFound("memberFrom.greaterOrEqualThan=" + UPDATED_MEMBER_FROM); } @Test @Transactional - public void getAllMembershipsByUntilDateIsLessThanSomething() throws Exception { + public void getAllMembershipsByMemberFromIsLessThanSomething() throws Exception { // Initialize the database membershipRepository.saveAndFlush(membership); - // Get all the membershipList where untilDate less than or equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.lessThan=" + DEFAULT_UNTIL_DATE); + // Get all the membershipList where memberFrom less than or equals to DEFAULT_MEMBER_FROM + defaultMembershipShouldNotBeFound("memberFrom.lessThan=" + DEFAULT_MEMBER_FROM); - // Get all the membershipList where untilDate less than or equals to UPDATED_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.lessThan=" + UPDATED_UNTIL_DATE); + // Get all the membershipList where memberFrom less than or equals to UPDATED_MEMBER_FROM + defaultMembershipShouldBeFound("memberFrom.lessThan=" + UPDATED_MEMBER_FROM); } + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil equals to DEFAULT_MEMBER_UNTIL + defaultMembershipShouldBeFound("memberUntil.equals=" + DEFAULT_MEMBER_UNTIL); + + // Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL + defaultMembershipShouldNotBeFound("memberUntil.equals=" + UPDATED_MEMBER_UNTIL); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil in DEFAULT_MEMBER_UNTIL or UPDATED_MEMBER_UNTIL + defaultMembershipShouldBeFound("memberUntil.in=" + DEFAULT_MEMBER_UNTIL + "," + UPDATED_MEMBER_UNTIL); + + // Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL + defaultMembershipShouldNotBeFound("memberUntil.in=" + UPDATED_MEMBER_UNTIL); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil is not null + defaultMembershipShouldBeFound("memberUntil.specified=true"); + + // Get all the membershipList where memberUntil is null + defaultMembershipShouldNotBeFound("memberUntil.specified=false"); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil greater than or equals to DEFAULT_MEMBER_UNTIL + defaultMembershipShouldBeFound("memberUntil.greaterOrEqualThan=" + DEFAULT_MEMBER_UNTIL); + + // Get all the membershipList where memberUntil greater than or equals to UPDATED_MEMBER_UNTIL + defaultMembershipShouldNotBeFound("memberUntil.greaterOrEqualThan=" + UPDATED_MEMBER_UNTIL); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsLessThanSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil less than or equals to DEFAULT_MEMBER_UNTIL + defaultMembershipShouldNotBeFound("memberUntil.lessThan=" + DEFAULT_MEMBER_UNTIL); + + // Get all the membershipList where memberUntil less than or equals to UPDATED_MEMBER_UNTIL + defaultMembershipShouldBeFound("memberUntil.lessThan=" + UPDATED_MEMBER_UNTIL); + } + + + @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 { @@ -403,8 +545,10 @@ public class MembershipResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue()))) - .andExpect(jsonPath("$.[*].sinceDate").value(hasItem(DEFAULT_SINCE_DATE.toString()))) - .andExpect(jsonPath("$.[*].untilDate").value(hasItem(DEFAULT_UNTIL_DATE.toString()))); + .andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString()))) + .andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK))); // Check, that the count call also returns 1 restMembershipMockMvc.perform(get("/api/memberships/count?sort=id,desc&" + filter)) @@ -452,8 +596,10 @@ public class MembershipResourceIntTest { // Disconnect from session so that the updates on updatedMembership are not directly saved in db em.detach(updatedMembership); updatedMembership - .sinceDate(UPDATED_SINCE_DATE) - .untilDate(UPDATED_UNTIL_DATE); + .documentDate(UPDATED_DOCUMENT_DATE) + .memberFrom(UPDATED_MEMBER_FROM) + .memberUntil(UPDATED_MEMBER_UNTIL) + .remark(UPDATED_REMARK); MembershipDTO membershipDTO = membershipMapper.toDto(updatedMembership); restMembershipMockMvc.perform(put("/api/memberships") @@ -465,8 +611,10 @@ public class MembershipResourceIntTest { List membershipList = membershipRepository.findAll(); assertThat(membershipList).hasSize(databaseSizeBeforeUpdate); Membership testMembership = membershipList.get(membershipList.size() - 1); - assertThat(testMembership.getSinceDate()).isEqualTo(UPDATED_SINCE_DATE); - assertThat(testMembership.getUntilDate()).isEqualTo(UPDATED_UNTIL_DATE); + assertThat(testMembership.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE); + assertThat(testMembership.getMemberFrom()).isEqualTo(UPDATED_MEMBER_FROM); + assertThat(testMembership.getMemberUntil()).isEqualTo(UPDATED_MEMBER_UNTIL); + assertThat(testMembership.getRemark()).isEqualTo(UPDATED_REMARK); } @Test diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java new file mode 100644 index 00000000..78bf4160 --- /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_DOCUMENT_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_VALID_FROM = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_FROM = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_VALID_UNTIL = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_UNTIL = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_LAST_USED = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_LAST_USED = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_CANCELLATION_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_CANCELLATION_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final 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) + .documentDate(DEFAULT_DOCUMENT_DATE) + .validFrom(DEFAULT_VALID_FROM) + .validUntil(DEFAULT_VALID_UNTIL) + .lastUsed(DEFAULT_LAST_USED) + .cancellationDate(DEFAULT_CANCELLATION_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.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE); + assertThat(testSepaMandate.getValidFrom()).isEqualTo(DEFAULT_VALID_FROM); + assertThat(testSepaMandate.getValidUntil()).isEqualTo(DEFAULT_VALID_UNTIL); + assertThat(testSepaMandate.getLastUsed()).isEqualTo(DEFAULT_LAST_USED); + assertThat(testSepaMandate.getCancellationDate()).isEqualTo(DEFAULT_CANCELLATION_DATE); + assertThat(testSepaMandate.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 checkDocumentDateIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setDocumentDate(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 checkValidFromIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setValidFrom(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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString()))) + .andExpect(jsonPath("$.[*].validUntil").value(hasItem(DEFAULT_VALID_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString()))) + .andExpect(jsonPath("$.[*].cancellationDate").value(hasItem(DEFAULT_CANCELLATION_DATE.toString()))) + .andExpect(jsonPath("$.[*].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("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.validFrom").value(DEFAULT_VALID_FROM.toString())) + .andExpect(jsonPath("$.validUntil").value(DEFAULT_VALID_UNTIL.toString())) + .andExpect(jsonPath("$.lastUsed").value(DEFAULT_LAST_USED.toString())) + .andExpect(jsonPath("$.cancellationDate").value(DEFAULT_CANCELLATION_DATE.toString())) + .andExpect(jsonPath("$.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 getAllSepaMandatesByDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate equals to DEFAULT_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); + + // Get all the sepaMandateList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE); + + // Get all the sepaMandateList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate is not null + defaultSepaMandateShouldBeFound("documentDate.specified=true"); + + // Get all the sepaMandateList where documentDate is null + defaultSepaMandateShouldNotBeFound("documentDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the sepaMandateList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the sepaMandateList where documentDate less than or equals to UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.equals=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.equals=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom in DEFAULT_VALID_FROM or UPDATED_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.in=" + DEFAULT_VALID_FROM + "," + UPDATED_VALID_FROM); + + // Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.in=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom is not null + defaultSepaMandateShouldBeFound("validFrom.specified=true"); + + // Get all the sepaMandateList where validFrom is null + defaultSepaMandateShouldNotBeFound("validFrom.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom greater than or equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.greaterOrEqualThan=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom greater than or equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.greaterOrEqualThan=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom less than or equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.lessThan=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom less than or equals to UPDATED_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.lessThan=" + UPDATED_VALID_FROM); + } + + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil equals to DEFAULT_VALID_UNTIL + defaultSepaMandateShouldBeFound("validUntil.equals=" + DEFAULT_VALID_UNTIL); + + // Get all the sepaMandateList where validUntil equals to UPDATED_VALID_UNTIL + defaultSepaMandateShouldNotBeFound("validUntil.equals=" + UPDATED_VALID_UNTIL); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil in DEFAULT_VALID_UNTIL or UPDATED_VALID_UNTIL + defaultSepaMandateShouldBeFound("validUntil.in=" + DEFAULT_VALID_UNTIL + "," + UPDATED_VALID_UNTIL); + + // Get all the sepaMandateList where validUntil equals to UPDATED_VALID_UNTIL + defaultSepaMandateShouldNotBeFound("validUntil.in=" + UPDATED_VALID_UNTIL); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil is not null + defaultSepaMandateShouldBeFound("validUntil.specified=true"); + + // Get all the sepaMandateList where validUntil is null + defaultSepaMandateShouldNotBeFound("validUntil.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil greater than or equals to DEFAULT_VALID_UNTIL + defaultSepaMandateShouldBeFound("validUntil.greaterOrEqualThan=" + DEFAULT_VALID_UNTIL); + + // Get all the sepaMandateList where validUntil greater than or equals to UPDATED_VALID_UNTIL + defaultSepaMandateShouldNotBeFound("validUntil.greaterOrEqualThan=" + UPDATED_VALID_UNTIL); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil less than or equals to DEFAULT_VALID_UNTIL + defaultSepaMandateShouldNotBeFound("validUntil.lessThan=" + DEFAULT_VALID_UNTIL); + + // Get all the sepaMandateList where validUntil less than or equals to UPDATED_VALID_UNTIL + defaultSepaMandateShouldBeFound("validUntil.lessThan=" + UPDATED_VALID_UNTIL); + } + + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed equals to DEFAULT_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.equals=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.equals=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed in DEFAULT_LAST_USED or UPDATED_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.in=" + DEFAULT_LAST_USED + "," + UPDATED_LAST_USED); + + // Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.in=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed is not null + defaultSepaMandateShouldBeFound("lastUsed.specified=true"); + + // Get all the sepaMandateList where lastUsed is null + defaultSepaMandateShouldNotBeFound("lastUsed.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed greater than or equals to DEFAULT_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.greaterOrEqualThan=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed greater than or equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.greaterOrEqualThan=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed less than or equals to DEFAULT_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.lessThan=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed less than or equals to UPDATED_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.lessThan=" + UPDATED_LAST_USED); + } + + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate equals to DEFAULT_CANCELLATION_DATE + defaultSepaMandateShouldBeFound("cancellationDate.equals=" + DEFAULT_CANCELLATION_DATE); + + // Get all the sepaMandateList where cancellationDate equals to UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldNotBeFound("cancellationDate.equals=" + UPDATED_CANCELLATION_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate in DEFAULT_CANCELLATION_DATE or UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldBeFound("cancellationDate.in=" + DEFAULT_CANCELLATION_DATE + "," + UPDATED_CANCELLATION_DATE); + + // Get all the sepaMandateList where cancellationDate equals to UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldNotBeFound("cancellationDate.in=" + UPDATED_CANCELLATION_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate is not null + defaultSepaMandateShouldBeFound("cancellationDate.specified=true"); + + // Get all the sepaMandateList where cancellationDate is null + defaultSepaMandateShouldNotBeFound("cancellationDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate greater than or equals to DEFAULT_CANCELLATION_DATE + defaultSepaMandateShouldBeFound("cancellationDate.greaterOrEqualThan=" + DEFAULT_CANCELLATION_DATE); + + // Get all the sepaMandateList where cancellationDate greater than or equals to UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldNotBeFound("cancellationDate.greaterOrEqualThan=" + UPDATED_CANCELLATION_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate less than or equals to DEFAULT_CANCELLATION_DATE + defaultSepaMandateShouldNotBeFound("cancellationDate.lessThan=" + DEFAULT_CANCELLATION_DATE); + + // Get all the sepaMandateList where cancellationDate less than or equals to UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldBeFound("cancellationDate.lessThan=" + UPDATED_CANCELLATION_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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString()))) + .andExpect(jsonPath("$.[*].validUntil").value(hasItem(DEFAULT_VALID_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString()))) + .andExpect(jsonPath("$.[*].cancellationDate").value(hasItem(DEFAULT_CANCELLATION_DATE.toString()))) + .andExpect(jsonPath("$.[*].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) + .documentDate(UPDATED_DOCUMENT_DATE) + .validFrom(UPDATED_VALID_FROM) + .validUntil(UPDATED_VALID_UNTIL) + .lastUsed(UPDATED_LAST_USED) + .cancellationDate(UPDATED_CANCELLATION_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.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE); + assertThat(testSepaMandate.getValidFrom()).isEqualTo(UPDATED_VALID_FROM); + assertThat(testSepaMandate.getValidUntil()).isEqualTo(UPDATED_VALID_UNTIL); + assertThat(testSepaMandate.getLastUsed()).isEqualTo(UPDATED_LAST_USED); + assertThat(testSepaMandate.getCancellationDate()).isEqualTo(UPDATED_CANCELLATION_DATE); + assertThat(testSepaMandate.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 index 44aa1dca..3b99a17c 100644 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java @@ -1,15 +1,17 @@ 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.enumeration.ShareAction; +import org.hostsharing.hsadminng.domain.Membership; import org.hostsharing.hsadminng.repository.ShareRepository; -import org.hostsharing.hsadminng.service.ShareQueryService; import org.hostsharing.hsadminng.service.ShareService; import org.hostsharing.hsadminng.service.dto.ShareDTO; import org.hostsharing.hsadminng.service.mapper.ShareMapper; import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; +import org.hostsharing.hsadminng.service.dto.ShareCriteria; +import org.hostsharing.hsadminng.service.ShareQueryService; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,11 +32,14 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.List; + +import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import org.hostsharing.hsadminng.domain.enumeration.ShareAction; /** * Test class for the ShareResource REST controller. * @@ -44,8 +49,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest(classes = HsadminNgApp.class) public class ShareResourceIntTest { - private static final LocalDate DEFAULT_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_DATE = LocalDate.now(ZoneId.systemDefault()); + 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; @@ -53,8 +61,8 @@ public class ShareResourceIntTest { private static final Integer DEFAULT_QUANTITY = 1; private static final Integer UPDATED_QUANTITY = 2; - private static final String DEFAULT_COMMENT = "AAAAAAAAAA"; - private static final String UPDATED_COMMENT = "BBBBBBBBBB"; + private static final String DEFAULT_REMARK = "AAAAAAAAAA"; + private static final String UPDATED_REMARK = "BBBBBBBBBB"; @Autowired private ShareRepository shareRepository; @@ -107,15 +115,16 @@ public class ShareResourceIntTest { */ public static Share createEntity(EntityManager em) { Share share = new Share() - .date(DEFAULT_DATE) + .documentDate(DEFAULT_DOCUMENT_DATE) + .valueDate(DEFAULT_VALUE_DATE) .action(DEFAULT_ACTION) .quantity(DEFAULT_QUANTITY) - .comment(DEFAULT_COMMENT); + .remark(DEFAULT_REMARK); // Add required entity Membership membership = MembershipResourceIntTest.createEntity(em); em.persist(membership); em.flush(); - share.setMember(membership); + share.setMembership(membership); return share; } @@ -140,10 +149,11 @@ public class ShareResourceIntTest { List shareList = shareRepository.findAll(); assertThat(shareList).hasSize(databaseSizeBeforeCreate + 1); Share testShare = shareList.get(shareList.size() - 1); - assertThat(testShare.getDate()).isEqualTo(DEFAULT_DATE); + 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.getComment()).isEqualTo(DEFAULT_COMMENT); + assertThat(testShare.getRemark()).isEqualTo(DEFAULT_REMARK); } @Test @@ -168,10 +178,29 @@ public class ShareResourceIntTest { @Test @Transactional - public void checkDateIsRequired() throws Exception { + public void checkDocumentDateIsRequired() throws Exception { int databaseSizeBeforeTest = shareRepository.findAll().size(); // set the field null - share.setDate(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); @@ -234,10 +263,11 @@ public class ShareResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(share.getId().intValue()))) - .andExpect(jsonPath("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) + .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("$.[*].comment").value(hasItem(DEFAULT_COMMENT.toString()))); + .andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString()))); } @Test @@ -251,75 +281,142 @@ public class ShareResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(share.getId().intValue())) - .andExpect(jsonPath("$.date").value(DEFAULT_DATE.toString())) + .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("$.comment").value(DEFAULT_COMMENT.toString())); + .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); } @Test @Transactional - public void getAllSharesByDateIsEqualToSomething() throws Exception { + public void getAllSharesByDocumentDateIsEqualToSomething() throws Exception { // Initialize the database shareRepository.saveAndFlush(share); - // Get all the shareList where date equals to DEFAULT_DATE - defaultShareShouldBeFound("date.equals=" + DEFAULT_DATE); + // Get all the shareList where documentDate equals to DEFAULT_DOCUMENT_DATE + defaultShareShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); - // Get all the shareList where date equals to UPDATED_DATE - defaultShareShouldNotBeFound("date.equals=" + UPDATED_DATE); + // Get all the shareList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultShareShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); } @Test @Transactional - public void getAllSharesByDateIsInShouldWork() throws Exception { + public void getAllSharesByDocumentDateIsInShouldWork() throws Exception { // Initialize the database shareRepository.saveAndFlush(share); - // Get all the shareList where date in DEFAULT_DATE or UPDATED_DATE - defaultShareShouldBeFound("date.in=" + DEFAULT_DATE + "," + UPDATED_DATE); + // 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 date equals to UPDATED_DATE - defaultShareShouldNotBeFound("date.in=" + UPDATED_DATE); + // Get all the shareList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultShareShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); } @Test @Transactional - public void getAllSharesByDateIsNullOrNotNull() throws Exception { + public void getAllSharesByDocumentDateIsNullOrNotNull() throws Exception { // Initialize the database shareRepository.saveAndFlush(share); - // Get all the shareList where date is not null - defaultShareShouldBeFound("date.specified=true"); + // Get all the shareList where documentDate is not null + defaultShareShouldBeFound("documentDate.specified=true"); - // Get all the shareList where date is null - defaultShareShouldNotBeFound("date.specified=false"); + // Get all the shareList where documentDate is null + defaultShareShouldNotBeFound("documentDate.specified=false"); } @Test @Transactional - public void getAllSharesByDateIsGreaterThanOrEqualToSomething() throws Exception { + public void getAllSharesByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { // Initialize the database shareRepository.saveAndFlush(share); - // Get all the shareList where date greater than or equals to DEFAULT_DATE - defaultShareShouldBeFound("date.greaterOrEqualThan=" + DEFAULT_DATE); + // 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 date greater than or equals to UPDATED_DATE - defaultShareShouldNotBeFound("date.greaterOrEqualThan=" + UPDATED_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 getAllSharesByDateIsLessThanSomething() throws Exception { + public void getAllSharesByDocumentDateIsLessThanSomething() throws Exception { // Initialize the database shareRepository.saveAndFlush(share); - // Get all the shareList where date less than or equals to DEFAULT_DATE - defaultShareShouldNotBeFound("date.lessThan=" + DEFAULT_DATE); + // 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 date less than or equals to UPDATED_DATE - defaultShareShouldBeFound("date.lessThan=" + UPDATED_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); } @@ -430,59 +527,59 @@ public class ShareResourceIntTest { @Test @Transactional - public void getAllSharesByCommentIsEqualToSomething() throws Exception { + public void getAllSharesByRemarkIsEqualToSomething() throws Exception { // Initialize the database shareRepository.saveAndFlush(share); - // Get all the shareList where comment equals to DEFAULT_COMMENT - defaultShareShouldBeFound("comment.equals=" + DEFAULT_COMMENT); + // Get all the shareList where remark equals to DEFAULT_REMARK + defaultShareShouldBeFound("remark.equals=" + DEFAULT_REMARK); - // Get all the shareList where comment equals to UPDATED_COMMENT - defaultShareShouldNotBeFound("comment.equals=" + UPDATED_COMMENT); + // Get all the shareList where remark equals to UPDATED_REMARK + defaultShareShouldNotBeFound("remark.equals=" + UPDATED_REMARK); } @Test @Transactional - public void getAllSharesByCommentIsInShouldWork() throws Exception { + public void getAllSharesByRemarkIsInShouldWork() throws Exception { // Initialize the database shareRepository.saveAndFlush(share); - // Get all the shareList where comment in DEFAULT_COMMENT or UPDATED_COMMENT - defaultShareShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT); + // Get all the shareList where remark in DEFAULT_REMARK or UPDATED_REMARK + defaultShareShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK); - // Get all the shareList where comment equals to UPDATED_COMMENT - defaultShareShouldNotBeFound("comment.in=" + UPDATED_COMMENT); + // Get all the shareList where remark equals to UPDATED_REMARK + defaultShareShouldNotBeFound("remark.in=" + UPDATED_REMARK); } @Test @Transactional - public void getAllSharesByCommentIsNullOrNotNull() throws Exception { + public void getAllSharesByRemarkIsNullOrNotNull() throws Exception { // Initialize the database shareRepository.saveAndFlush(share); - // Get all the shareList where comment is not null - defaultShareShouldBeFound("comment.specified=true"); + // Get all the shareList where remark is not null + defaultShareShouldBeFound("remark.specified=true"); - // Get all the shareList where comment is null - defaultShareShouldNotBeFound("comment.specified=false"); + // Get all the shareList where remark is null + defaultShareShouldNotBeFound("remark.specified=false"); } @Test @Transactional - public void getAllSharesByMemberIsEqualToSomething() throws Exception { + public void getAllSharesByMembershipIsEqualToSomething() throws Exception { // Initialize the database - Membership member = MembershipResourceIntTest.createEntity(em); - em.persist(member); + Membership membership = MembershipResourceIntTest.createEntity(em); + em.persist(membership); em.flush(); - share.setMember(member); + share.setMembership(membership); shareRepository.saveAndFlush(share); - Long memberId = member.getId(); + Long membershipId = membership.getId(); - // Get all the shareList where member equals to memberId - defaultShareShouldBeFound("memberId.equals=" + memberId); + // Get all the shareList where membership equals to membershipId + defaultShareShouldBeFound("membershipId.equals=" + membershipId); - // Get all the shareList where member equals to memberId + 1 - defaultShareShouldNotBeFound("memberId.equals=" + (memberId + 1)); + // Get all the shareList where membership equals to membershipId + 1 + defaultShareShouldNotBeFound("membershipId.equals=" + (membershipId + 1)); } /** @@ -493,10 +590,11 @@ public class ShareResourceIntTest { .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(share.getId().intValue()))) - .andExpect(jsonPath("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) + .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("$.[*].comment").value(hasItem(DEFAULT_COMMENT))); + .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)) @@ -544,10 +642,11 @@ public class ShareResourceIntTest { // Disconnect from session so that the updates on updatedShare are not directly saved in db em.detach(updatedShare); updatedShare - .date(UPDATED_DATE) + .documentDate(UPDATED_DOCUMENT_DATE) + .valueDate(UPDATED_VALUE_DATE) .action(UPDATED_ACTION) .quantity(UPDATED_QUANTITY) - .comment(UPDATED_COMMENT); + .remark(UPDATED_REMARK); ShareDTO shareDTO = shareMapper.toDto(updatedShare); restShareMockMvc.perform(put("/api/shares") @@ -559,10 +658,11 @@ public class ShareResourceIntTest { List shareList = shareRepository.findAll(); assertThat(shareList).hasSize(databaseSizeBeforeUpdate); Share testShare = shareList.get(shareList.size() - 1); - assertThat(testShare.getDate()).isEqualTo(UPDATED_DATE); + 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.getComment()).isEqualTo(UPDATED_COMMENT); + assertThat(testShare.getRemark()).isEqualTo(UPDATED_REMARK); } @Test 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 index 0278f8ab..20bcdf53 100644 --- 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 @@ -1,7 +1,7 @@ /* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; import { AssetUpdateComponent } from 'app/entities/asset/asset-update.component'; 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 index 99eabace..28250778 100644 --- a/src/test/javascript/spec/app/entities/asset/asset.service.spec.ts +++ b/src/test/javascript/spec/app/entities/asset/asset.service.spec.ts @@ -25,14 +25,15 @@ describe('Service Tests', () => { httpMock = injector.get(HttpTestingController); currentDate = moment(); - elemDefault = new Asset(0, currentDate, AssetAction.PAYMENT, 0, 'AAAAAAA'); + elemDefault = new Asset(0, currentDate, currentDate, AssetAction.PAYMENT, 0, 'AAAAAAA'); }); describe('Service methods', async () => { it('should find an element', async () => { const returnedFromService = Object.assign( { - date: currentDate.format(DATE_FORMAT) + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT) }, elemDefault ); @@ -49,13 +50,15 @@ describe('Service Tests', () => { const returnedFromService = Object.assign( { id: 0, - date: currentDate.format(DATE_FORMAT) + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT) }, elemDefault ); const expected = Object.assign( { - date: currentDate + documentDate: currentDate, + valueDate: currentDate }, returnedFromService ); @@ -70,17 +73,19 @@ describe('Service Tests', () => { it('should update a Asset', async () => { const returnedFromService = Object.assign( { - date: currentDate.format(DATE_FORMAT), + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT), action: 'BBBBBB', amount: 1, - comment: 'BBBBBB' + remark: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - date: currentDate + documentDate: currentDate, + valueDate: currentDate }, returnedFromService ); @@ -95,16 +100,18 @@ describe('Service Tests', () => { it('should return a list of Asset', async () => { const returnedFromService = Object.assign( { - date: currentDate.format(DATE_FORMAT), + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT), action: 'BBBBBB', amount: 1, - comment: 'BBBBBB' + remark: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - date: currentDate + documentDate: currentDate, + valueDate: currentDate }, returnedFromService ); 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 index 2249e64e..e50a46df 100644 --- 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 @@ -1,7 +1,7 @@ /* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; import { CustomerUpdateComponent } from 'app/entities/customer/customer-update.component'; diff --git a/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts b/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts index 8cbf4977..53f01f13 100644 --- a/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts +++ b/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts @@ -1,9 +1,11 @@ /* tslint:disable max-line-length */ -import { getTestBed, TestBed } from '@angular/core/testing'; +import { TestBed, getTestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { map, take } from 'rxjs/operators'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; +import { take, map } from 'rxjs/operators'; import { CustomerService } from 'app/entities/customer/customer.service'; -import { Customer, ICustomer } from 'app/shared/model/customer.model'; +import { ICustomer, Customer } from 'app/shared/model/customer.model'; describe('Service Tests', () => { describe('Customer Service', () => { @@ -19,7 +21,7 @@ describe('Service Tests', () => { service = injector.get(CustomerService); httpMock = injector.get(HttpTestingController); - elemDefault = new Customer(0, 0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA'); + elemDefault = new Customer(0, 0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA'); }); describe('Service methods', async () => { @@ -53,13 +55,14 @@ describe('Service Tests', () => { it('should update a Customer', async () => { const returnedFromService = Object.assign( { - number: 1, + reference: 1, prefix: 'BBBBBB', name: 'BBBBBB', - contractualAddress: 'BBBBBB', contractualSalutation: 'BBBBBB', + contractualAddress: 'BBBBBB', + billingSalutation: 'BBBBBB', billingAddress: 'BBBBBB', - billingSalutation: 'BBBBBB' + remark: 'BBBBBB' }, elemDefault ); @@ -76,13 +79,14 @@ describe('Service Tests', () => { it('should return a list of Customer', async () => { const returnedFromService = Object.assign( { - number: 1, + reference: 1, prefix: 'BBBBBB', name: 'BBBBBB', - contractualAddress: 'BBBBBB', contractualSalutation: 'BBBBBB', + contractualAddress: 'BBBBBB', + billingSalutation: 'BBBBBB', billingAddress: 'BBBBBB', - billingSalutation: 'BBBBBB' + remark: 'BBBBBB' }, elemDefault ); 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 index 3fa8f65c..abd5a5a2 100644 --- 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 @@ -1,7 +1,7 @@ /* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; import { MembershipUpdateComponent } from 'app/entities/membership/membership-update.component'; diff --git a/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts b/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts index d608d510..765beeec 100644 --- a/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts +++ b/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts @@ -25,15 +25,16 @@ describe('Service Tests', () => { httpMock = injector.get(HttpTestingController); currentDate = moment(); - elemDefault = new Membership(0, currentDate, currentDate); + elemDefault = new Membership(0, currentDate, currentDate, currentDate, 'AAAAAAA'); }); describe('Service methods', async () => { it('should find an element', async () => { const returnedFromService = Object.assign( { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) + documentDate: currentDate.format(DATE_FORMAT), + memberFrom: currentDate.format(DATE_FORMAT), + memberUntil: currentDate.format(DATE_FORMAT) }, elemDefault ); @@ -50,15 +51,17 @@ describe('Service Tests', () => { const returnedFromService = Object.assign( { id: 0, - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) + documentDate: currentDate.format(DATE_FORMAT), + memberFrom: currentDate.format(DATE_FORMAT), + memberUntil: currentDate.format(DATE_FORMAT) }, elemDefault ); const expected = Object.assign( { - sinceDate: currentDate, - untilDate: currentDate + documentDate: currentDate, + memberFrom: currentDate, + memberUntil: currentDate }, returnedFromService ); @@ -73,16 +76,19 @@ describe('Service Tests', () => { it('should update a Membership', async () => { const returnedFromService = Object.assign( { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) + documentDate: currentDate.format(DATE_FORMAT), + memberFrom: currentDate.format(DATE_FORMAT), + memberUntil: currentDate.format(DATE_FORMAT), + remark: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - sinceDate: currentDate, - untilDate: currentDate + documentDate: currentDate, + memberFrom: currentDate, + memberUntil: currentDate }, returnedFromService ); @@ -97,15 +103,18 @@ describe('Service Tests', () => { it('should return a list of Membership', async () => { const returnedFromService = Object.assign( { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) + documentDate: currentDate.format(DATE_FORMAT), + memberFrom: currentDate.format(DATE_FORMAT), + memberUntil: currentDate.format(DATE_FORMAT), + remark: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - sinceDate: currentDate, - untilDate: currentDate + documentDate: currentDate, + memberFrom: currentDate, + memberUntil: currentDate }, returnedFromService ); 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..0ff6222c --- /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( + { + documentDate: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validUntil: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancellationDate: currentDate.format(DATE_FORMAT) + }, + 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, + documentDate: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validUntil: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancellationDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + validFrom: currentDate, + validUntil: currentDate, + lastUsed: currentDate, + cancellationDate: 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', + documentDate: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validUntil: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancellationDate: currentDate.format(DATE_FORMAT), + remark: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + documentDate: currentDate, + validFrom: currentDate, + validUntil: currentDate, + lastUsed: currentDate, + cancellationDate: 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', + documentDate: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validUntil: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancellationDate: currentDate.format(DATE_FORMAT), + remark: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + validFrom: currentDate, + validUntil: currentDate, + lastUsed: currentDate, + cancellationDate: 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-update.component.spec.ts b/src/test/javascript/spec/app/entities/share/share-update.component.spec.ts index f19de7be..279be464 100644 --- 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 @@ -1,7 +1,7 @@ /* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { HsadminNgTestModule } from '../../../test.module'; import { ShareUpdateComponent } from 'app/entities/share/share-update.component'; 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 index b3288c82..73bf3281 100644 --- a/src/test/javascript/spec/app/entities/share/share.service.spec.ts +++ b/src/test/javascript/spec/app/entities/share/share.service.spec.ts @@ -25,14 +25,15 @@ describe('Service Tests', () => { httpMock = injector.get(HttpTestingController); currentDate = moment(); - elemDefault = new Share(0, currentDate, ShareAction.SUBSCRIPTION, 0, 'AAAAAAA'); + elemDefault = new Share(0, currentDate, currentDate, ShareAction.SUBSCRIPTION, 0, 'AAAAAAA'); }); describe('Service methods', async () => { it('should find an element', async () => { const returnedFromService = Object.assign( { - date: currentDate.format(DATE_FORMAT) + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT) }, elemDefault ); @@ -49,13 +50,15 @@ describe('Service Tests', () => { const returnedFromService = Object.assign( { id: 0, - date: currentDate.format(DATE_FORMAT) + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT) }, elemDefault ); const expected = Object.assign( { - date: currentDate + documentDate: currentDate, + valueDate: currentDate }, returnedFromService ); @@ -70,17 +73,19 @@ describe('Service Tests', () => { it('should update a Share', async () => { const returnedFromService = Object.assign( { - date: currentDate.format(DATE_FORMAT), + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT), action: 'BBBBBB', quantity: 1, - comment: 'BBBBBB' + remark: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - date: currentDate + documentDate: currentDate, + valueDate: currentDate }, returnedFromService ); @@ -95,16 +100,18 @@ describe('Service Tests', () => { it('should return a list of Share', async () => { const returnedFromService = Object.assign( { - date: currentDate.format(DATE_FORMAT), + documentDate: currentDate.format(DATE_FORMAT), + valueDate: currentDate.format(DATE_FORMAT), action: 'BBBBBB', quantity: 1, - comment: 'BBBBBB' + remark: 'BBBBBB' }, elemDefault ); const expected = Object.assign( { - date: currentDate + documentDate: currentDate, + valueDate: currentDate }, returnedFromService ); From c6be30895e9501212e07f76e353f6c9f4859d82f Mon Sep 17 00:00:00 2001 From: Michael Hierweck Date: Thu, 18 Apr 2019 16:18:26 +0200 Subject: [PATCH 3/5] Customer JDL --- .jhipster/Asset.json | 54 -- .jhipster/Contact.json | 49 -- .jhipster/Customer.json | 92 -- .jhipster/CustomerContact.json | 40 - .jhipster/Membership.json | 47 -- .jhipster/Share.json | 54 -- .../hostsharing/hsadminng/domain/Asset.java | 156 ---- .../hostsharing/hsadminng/domain/Contact.java | 148 ---- .../hsadminng/domain/Customer.java | 246 ------ .../hsadminng/domain/CustomerContact.java | 119 --- .../hsadminng/domain/Membership.java | 171 ---- .../hostsharing/hsadminng/domain/Share.java | 155 ---- .../domain/enumeration/AssetAction.java | 8 - .../enumeration/CustomerContactRole.java | 8 - .../domain/enumeration/ShareAction.java | 8 - .../hsadminng/repository/AssetRepository.java | 15 - .../repository/ContactRepository.java | 15 - .../repository/CustomerContactRepository.java | 15 - .../repository/CustomerRepository.java | 15 - .../repository/MembershipRepository.java | 15 - .../hsadminng/repository/ShareRepository.java | 15 - .../hsadminng/service/AssetQueryService.java | 111 --- .../hsadminng/service/AssetService.java | 84 -- .../service/ContactQueryService.java | 108 --- .../hsadminng/service/ContactService.java | 84 -- .../service/CustomerContactQueryService.java | 106 --- .../service/CustomerContactService.java | 84 -- .../service/CustomerQueryService.java | 123 --- .../hsadminng/service/CustomerService.java | 84 -- .../service/MembershipQueryService.java | 113 --- .../hsadminng/service/MembershipService.java | 84 -- .../hsadminng/service/ShareQueryService.java | 111 --- .../hsadminng/service/ShareService.java | 84 -- .../hsadminng/service/dto/AssetCriteria.java | 136 --- .../hsadminng/service/dto/AssetDTO.java | 111 --- .../service/dto/ContactCriteria.java | 115 --- .../hsadminng/service/dto/ContactDTO.java | 88 -- .../service/dto/CustomerContactCriteria.java | 108 --- .../service/dto/CustomerContactDTO.java | 106 --- .../service/dto/CustomerCriteria.java | 178 ---- .../hsadminng/service/dto/CustomerDTO.java | 138 --- .../service/dto/MembershipCriteria.java | 129 --- .../hsadminng/service/dto/MembershipDTO.java | 95 --- .../hsadminng/service/dto/ShareCriteria.java | 135 --- .../hsadminng/service/dto/ShareDTO.java | 110 --- .../hsadminng/service/mapper/AssetMapper.java | 28 - .../service/mapper/ContactMapper.java | 26 - .../service/mapper/CustomerContactMapper.java | 32 - .../service/mapper/CustomerMapper.java | 27 - .../service/mapper/EntityMapper.java | 21 - .../service/mapper/MembershipMapper.java | 31 - .../hsadminng/service/mapper/ShareMapper.java | 28 - .../hsadminng/web/rest/AssetResource.java | 138 --- .../hsadminng/web/rest/ContactResource.java | 138 --- .../web/rest/CustomerContactResource.java | 138 --- .../hsadminng/web/rest/CustomerResource.java | 138 --- .../web/rest/MembershipResource.java | 138 --- .../hsadminng/web/rest/ShareResource.java | 138 --- src/main/jdl/customer.jdl | 65 +- .../20190403083735_added_entity_Customer.xml | 55 -- .../20190403083736_added_entity_Contact.xml | 41 - ...403083737_added_entity_CustomerContact.xml | 41 - ...ded_entity_constraints_CustomerContact.xml | 24 - ...20190403083738_added_entity_Membership.xml | 39 - ...38_added_entity_constraints_Membership.xml | 18 - .../20190403083739_added_entity_Share.xml | 47 -- ...3083739_added_entity_constraints_Share.xml | 18 - .../20190403083740_added_entity_Asset.xml | 47 -- ...3083740_added_entity_constraints_Asset.xml | 18 - .../resources/config/liquibase/master.xml | 10 - .../asset/asset-delete-dialog.component.html | 19 - .../asset/asset-delete-dialog.component.ts | 65 -- .../asset/asset-detail.component.html | 45 - .../entities/asset/asset-detail.component.ts | 24 - .../asset/asset-update.component.html | 97 --- .../entities/asset/asset-update.component.ts | 78 -- .../app/entities/asset/asset.component.html | 66 -- .../app/entities/asset/asset.component.ts | 108 --- .../webapp/app/entities/asset/asset.module.ts | 34 - .../webapp/app/entities/asset/asset.route.ts | 93 -- .../app/entities/asset/asset.service.ts | 74 -- src/main/webapp/app/entities/asset/index.ts | 6 - .../contact-delete-dialog.component.html | 19 - .../contact-delete-dialog.component.ts | 65 -- .../contact/contact-detail.component.html | 35 - .../contact/contact-detail.component.ts | 24 - .../contact/contact-update.component.html | 69 -- .../contact/contact-update.component.ts | 51 -- .../entities/contact/contact.component.html | 58 -- .../app/entities/contact/contact.component.ts | 108 --- .../app/entities/contact/contact.module.ts | 40 - .../app/entities/contact/contact.route.ts | 93 -- .../app/entities/contact/contact.service.ts | 38 - src/main/webapp/app/entities/contact/index.ts | 6 - ...tomer-contact-delete-dialog.component.html | 19 - ...ustomer-contact-delete-dialog.component.ts | 72 -- .../customer-contact-detail.component.html | 39 - .../customer-contact-detail.component.ts | 24 - .../customer-contact-update.component.html | 64 -- .../customer-contact-update.component.ts | 92 -- .../customer-contact.component.html | 66 -- .../customer-contact.component.ts | 108 --- .../customer-contact.module.ts | 45 - .../customer-contact.route.ts | 93 -- .../customer-contact.service.ts | 38 - .../app/entities/customer-contact/index.ts | 6 - .../customer-delete-dialog.component.html | 19 - .../customer-delete-dialog.component.ts | 65 -- .../customer/customer-detail.component.html | 51 -- .../customer/customer-detail.component.ts | 24 - .../customer/customer-update.component.html | 142 ---- .../customer/customer-update.component.ts | 51 -- .../entities/customer/customer.component.html | 77 -- .../entities/customer/customer.component.ts | 108 --- .../app/entities/customer/customer.module.ts | 40 - .../app/entities/customer/customer.route.ts | 93 -- .../app/entities/customer/customer.service.ts | 38 - .../webapp/app/entities/customer/index.ts | 6 - src/main/webapp/app/entities/entity.module.ts | 42 +- .../webapp/app/entities/membership/index.ts | 6 - .../membership-delete-dialog.component.html | 19 - .../membership-delete-dialog.component.ts | 69 -- .../membership-detail.component.html | 37 - .../membership/membership-detail.component.ts | 24 - .../membership-update.component.html | 65 -- .../membership/membership-update.component.ts | 79 -- .../membership/membership.component.html | 62 -- .../membership/membership.component.ts | 108 --- .../entities/membership/membership.module.ts | 40 - .../entities/membership/membership.route.ts | 93 -- .../entities/membership/membership.service.ts | 77 -- src/main/webapp/app/entities/share/index.ts | 6 - .../share/share-delete-dialog.component.html | 19 - .../share/share-delete-dialog.component.ts | 65 -- .../share/share-detail.component.html | 45 - .../entities/share/share-detail.component.ts | 24 - .../share/share-update.component.html | 93 -- .../entities/share/share-update.component.ts | 78 -- .../app/entities/share/share.component.html | 66 -- .../app/entities/share/share.component.ts | 108 --- .../webapp/app/entities/share/share.module.ts | 34 - .../webapp/app/entities/share/share.route.ts | 93 -- .../app/entities/share/share.service.ts | 74 -- .../app/layouts/navbar/navbar.component.html | 36 - .../webapp/app/shared/model/asset.model.ts | 30 - .../webapp/app/shared/model/contact.model.ts | 19 - .../shared/model/customer-contact.model.ts | 25 - .../webapp/app/shared/model/customer.model.ts | 30 - .../app/shared/model/membership.model.ts | 25 - .../webapp/app/shared/model/share.model.ts | 26 - src/main/webapp/i18n/de/asset.json | 25 - src/main/webapp/i18n/de/assetAction.json | 13 - src/main/webapp/i18n/de/contact.json | 24 - src/main/webapp/i18n/de/customer.json | 29 - src/main/webapp/i18n/de/customerContact.json | 23 - .../webapp/i18n/de/customerContactRole.json | 10 - src/main/webapp/i18n/de/global.json | 6 - src/main/webapp/i18n/de/membership.json | 25 - src/main/webapp/i18n/de/share.json | 25 - src/main/webapp/i18n/de/shareAction.json | 9 - src/main/webapp/i18n/en/asset.json | 25 - src/main/webapp/i18n/en/assetAction.json | 13 - src/main/webapp/i18n/en/contact.json | 24 - src/main/webapp/i18n/en/customer.json | 29 - src/main/webapp/i18n/en/customerContact.json | 23 - .../webapp/i18n/en/customerContactRole.json | 10 - src/main/webapp/i18n/en/global.json | 6 - src/main/webapp/i18n/en/membership.json | 25 - src/main/webapp/i18n/en/share.json | 25 - src/main/webapp/i18n/en/shareAction.json | 9 - .../web/rest/AssetResourceIntTest.java | 616 -------------- .../web/rest/ContactResourceIntTest.java | 536 ------------ .../rest/CustomerContactResourceIntTest.java | 431 ---------- .../web/rest/CustomerResourceIntTest.java | 794 ------------------ .../web/rest/MembershipResourceIntTest.java | 546 ------------ .../web/rest/ShareResourceIntTest.java | 642 -------------- .../asset-delete-dialog.component.spec.ts | 52 -- .../asset/asset-detail.component.spec.ts | 40 - .../asset/asset-update.component.spec.ts | 60 -- .../entities/asset/asset.component.spec.ts | 128 --- .../app/entities/asset/asset.service.spec.ts | 135 --- .../contact-delete-dialog.component.spec.ts | 52 -- .../contact/contact-detail.component.spec.ts | 40 - .../contact/contact-update.component.spec.ts | 60 -- .../contact/contact.component.spec.ts | 128 --- .../entities/contact/contact.service.spec.ts | 108 --- ...er-contact-delete-dialog.component.spec.ts | 52 -- .../customer-contact-detail.component.spec.ts | 40 - .../customer-contact-update.component.spec.ts | 60 -- .../customer-contact.component.spec.ts | 128 --- .../customer-contact.service.spec.ts | 104 --- .../customer-delete-dialog.component.spec.ts | 52 -- .../customer-detail.component.spec.ts | 40 - .../customer-update.component.spec.ts | 60 -- .../customer/customer.component.spec.ts | 128 --- .../customer/customer.service.spec.ts | 114 --- ...membership-delete-dialog.component.spec.ts | 52 -- .../membership-detail.component.spec.ts | 40 - .../membership-update.component.spec.ts | 60 -- .../membership/membership.component.spec.ts | 128 --- .../membership/membership.service.spec.ts | 136 --- .../share-delete-dialog.component.spec.ts | 52 -- .../share/share-detail.component.spec.ts | 40 - .../share/share-update.component.spec.ts | 60 -- .../entities/share/share.component.spec.ts | 128 --- .../app/entities/share/share.service.spec.ts | 135 --- 206 files changed, 33 insertions(+), 16148 deletions(-) delete mode 100644 .jhipster/Asset.json delete mode 100644 .jhipster/Contact.json delete mode 100644 .jhipster/Customer.json delete mode 100644 .jhipster/CustomerContact.json delete mode 100644 .jhipster/Membership.json delete mode 100644 .jhipster/Share.json delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Asset.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Contact.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Customer.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/CustomerContact.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Membership.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Share.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/enumeration/AssetAction.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerContactRole.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/domain/enumeration/ShareAction.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/repository/AssetRepository.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/repository/ContactRepository.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/repository/CustomerContactRepository.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/repository/CustomerRepository.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/repository/ShareRepository.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/AssetService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/ContactQueryService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/ContactService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/CustomerContactQueryService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/CustomerContactService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/CustomerService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/MembershipService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/ShareService.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/ContactCriteria.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/ContactDTO.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactCriteria.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactDTO.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/ContactMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerContactMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/EntityMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/ContactResource.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/CustomerContactResource.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/CustomerResource.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/MembershipResource.java delete mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/ShareResource.java delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083738_added_entity_constraints_Membership.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml delete mode 100644 src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml delete mode 100644 src/main/webapp/app/entities/asset/asset-delete-dialog.component.html delete mode 100644 src/main/webapp/app/entities/asset/asset-delete-dialog.component.ts delete mode 100644 src/main/webapp/app/entities/asset/asset-detail.component.html delete mode 100644 src/main/webapp/app/entities/asset/asset-detail.component.ts delete mode 100644 src/main/webapp/app/entities/asset/asset-update.component.html delete mode 100644 src/main/webapp/app/entities/asset/asset-update.component.ts delete mode 100644 src/main/webapp/app/entities/asset/asset.component.html delete mode 100644 src/main/webapp/app/entities/asset/asset.component.ts delete mode 100644 src/main/webapp/app/entities/asset/asset.module.ts delete mode 100644 src/main/webapp/app/entities/asset/asset.route.ts delete mode 100644 src/main/webapp/app/entities/asset/asset.service.ts delete mode 100644 src/main/webapp/app/entities/asset/index.ts delete mode 100644 src/main/webapp/app/entities/contact/contact-delete-dialog.component.html delete mode 100644 src/main/webapp/app/entities/contact/contact-delete-dialog.component.ts delete mode 100644 src/main/webapp/app/entities/contact/contact-detail.component.html delete mode 100644 src/main/webapp/app/entities/contact/contact-detail.component.ts delete mode 100644 src/main/webapp/app/entities/contact/contact-update.component.html delete mode 100644 src/main/webapp/app/entities/contact/contact-update.component.ts delete mode 100644 src/main/webapp/app/entities/contact/contact.component.html delete mode 100644 src/main/webapp/app/entities/contact/contact.component.ts delete mode 100644 src/main/webapp/app/entities/contact/contact.module.ts delete mode 100644 src/main/webapp/app/entities/contact/contact.route.ts delete mode 100644 src/main/webapp/app/entities/contact/contact.service.ts delete mode 100644 src/main/webapp/app/entities/contact/index.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.html delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.html delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-update.component.html delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact-update.component.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.component.html delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.component.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.module.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.route.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/customer-contact.service.ts delete mode 100644 src/main/webapp/app/entities/customer-contact/index.ts delete mode 100644 src/main/webapp/app/entities/customer/customer-delete-dialog.component.html delete mode 100644 src/main/webapp/app/entities/customer/customer-delete-dialog.component.ts delete mode 100644 src/main/webapp/app/entities/customer/customer-detail.component.html delete mode 100644 src/main/webapp/app/entities/customer/customer-detail.component.ts delete mode 100644 src/main/webapp/app/entities/customer/customer-update.component.html delete mode 100644 src/main/webapp/app/entities/customer/customer-update.component.ts delete mode 100644 src/main/webapp/app/entities/customer/customer.component.html delete mode 100644 src/main/webapp/app/entities/customer/customer.component.ts delete mode 100644 src/main/webapp/app/entities/customer/customer.module.ts delete mode 100644 src/main/webapp/app/entities/customer/customer.route.ts delete mode 100644 src/main/webapp/app/entities/customer/customer.service.ts delete mode 100644 src/main/webapp/app/entities/customer/index.ts delete mode 100644 src/main/webapp/app/entities/membership/index.ts delete mode 100644 src/main/webapp/app/entities/membership/membership-delete-dialog.component.html delete mode 100644 src/main/webapp/app/entities/membership/membership-delete-dialog.component.ts delete mode 100644 src/main/webapp/app/entities/membership/membership-detail.component.html delete mode 100644 src/main/webapp/app/entities/membership/membership-detail.component.ts delete mode 100644 src/main/webapp/app/entities/membership/membership-update.component.html delete mode 100644 src/main/webapp/app/entities/membership/membership-update.component.ts delete mode 100644 src/main/webapp/app/entities/membership/membership.component.html delete mode 100644 src/main/webapp/app/entities/membership/membership.component.ts delete mode 100644 src/main/webapp/app/entities/membership/membership.module.ts delete mode 100644 src/main/webapp/app/entities/membership/membership.route.ts delete mode 100644 src/main/webapp/app/entities/membership/membership.service.ts delete mode 100644 src/main/webapp/app/entities/share/index.ts delete mode 100644 src/main/webapp/app/entities/share/share-delete-dialog.component.html delete mode 100644 src/main/webapp/app/entities/share/share-delete-dialog.component.ts delete mode 100644 src/main/webapp/app/entities/share/share-detail.component.html delete mode 100644 src/main/webapp/app/entities/share/share-detail.component.ts delete mode 100644 src/main/webapp/app/entities/share/share-update.component.html delete mode 100644 src/main/webapp/app/entities/share/share-update.component.ts delete mode 100644 src/main/webapp/app/entities/share/share.component.html delete mode 100644 src/main/webapp/app/entities/share/share.component.ts delete mode 100644 src/main/webapp/app/entities/share/share.module.ts delete mode 100644 src/main/webapp/app/entities/share/share.route.ts delete mode 100644 src/main/webapp/app/entities/share/share.service.ts delete mode 100644 src/main/webapp/app/shared/model/asset.model.ts delete mode 100644 src/main/webapp/app/shared/model/contact.model.ts delete mode 100644 src/main/webapp/app/shared/model/customer-contact.model.ts delete mode 100644 src/main/webapp/app/shared/model/customer.model.ts delete mode 100644 src/main/webapp/app/shared/model/membership.model.ts delete mode 100644 src/main/webapp/app/shared/model/share.model.ts delete mode 100644 src/main/webapp/i18n/de/asset.json delete mode 100644 src/main/webapp/i18n/de/assetAction.json delete mode 100644 src/main/webapp/i18n/de/contact.json delete mode 100644 src/main/webapp/i18n/de/customer.json delete mode 100644 src/main/webapp/i18n/de/customerContact.json delete mode 100644 src/main/webapp/i18n/de/customerContactRole.json delete mode 100644 src/main/webapp/i18n/de/membership.json delete mode 100644 src/main/webapp/i18n/de/share.json delete mode 100644 src/main/webapp/i18n/de/shareAction.json delete mode 100644 src/main/webapp/i18n/en/asset.json delete mode 100644 src/main/webapp/i18n/en/assetAction.json delete mode 100644 src/main/webapp/i18n/en/contact.json delete mode 100644 src/main/webapp/i18n/en/customer.json delete mode 100644 src/main/webapp/i18n/en/customerContact.json delete mode 100644 src/main/webapp/i18n/en/customerContactRole.json delete mode 100644 src/main/webapp/i18n/en/membership.json delete mode 100644 src/main/webapp/i18n/en/share.json delete mode 100644 src/main/webapp/i18n/en/shareAction.json delete mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java delete mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java delete mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java delete mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java delete mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java delete mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java delete mode 100644 src/test/javascript/spec/app/entities/asset/asset-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/asset/asset-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/asset/asset-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/asset/asset.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/asset/asset.service.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/contact/contact-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/contact/contact-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/contact/contact-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/contact/contact.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/contact/contact.service.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer-contact/customer-contact.service.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer/customer-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer/customer-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer/customer-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer/customer.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/customer/customer.service.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/membership/membership-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/membership/membership-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/membership/membership-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/membership/membership.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/membership/membership.service.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/share/share-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/share/share-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/share/share-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/share/share.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/share/share.service.spec.ts diff --git a/.jhipster/Asset.json b/.jhipster/Asset.json deleted file mode 100644 index c1e70387..00000000 --- a/.jhipster/Asset.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "Asset", - "fields": [ - { - "fieldName": "date", - "fieldType": "LocalDate", - "fieldValidateRules": [ - "required" - ] - }, - { - "fieldName": "action", - "fieldType": "AssetAction", - "fieldValues": "PAYMENT,HANDOVER,ADOPTION,LOSS,CLEARING,PAYBACK", - "fieldValidateRules": [ - "required" - ] - }, - { - "fieldName": "amount", - "fieldType": "BigDecimal", - "fieldValidateRules": [ - "required" - ] - }, - { - "fieldName": "comment", - "fieldType": "String", - "fieldValidateRules": [ - "maxlength" - ], - "fieldValidateRulesMaxlength": 160 - } - ], - "relationships": [ - { - "relationshipType": "many-to-one", - "otherEntityName": "membership", - "otherEntityRelationshipName": "asset", - "relationshipValidateRules": "required", - "relationshipName": "member", - "otherEntityField": "id" - } - ], - "changelogDate": "20190403083740", - "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/Contact.json b/.jhipster/Contact.json deleted file mode 100644 index e7aec648..00000000 --- a/.jhipster/Contact.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "Contact", - "fields": [ - { - "fieldName": "firstName", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - }, - { - "fieldName": "lastName", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - }, - { - "fieldName": "email", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - } - ], - "relationships": [ - { - "relationshipType": "one-to-many", - "otherEntityName": "customerContact", - "otherEntityRelationshipName": "contact", - "relationshipName": "role" - } - ], - "changelogDate": "20190403083736", - "entityTableName": "contact", - "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 deleted file mode 100644 index 36d7340c..00000000 --- a/.jhipster/Customer.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "name": "Customer", - "fields": [ - { - "fieldName": "number", - "fieldType": "Integer", - "fieldValidateRules": [ - "required", - "unique", - "min", - "max" - ], - "fieldValidateRulesMin": 10000, - "fieldValidateRulesMax": 99999 - }, - { - "fieldName": "prefix", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "unique", - "pattern" - ], - "fieldValidateRulesPattern": "[a-z][a-z0-9]+" - }, - { - "fieldName": "name", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - }, - { - "fieldName": "contractualAddress", - "fieldType": "String", - "fieldValidateRules": [ - "required", - "maxlength" - ], - "fieldValidateRulesMaxlength": 400 - }, - { - "fieldName": "contractualSalutation", - "fieldType": "String", - "fieldValidateRules": [ - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - }, - { - "fieldName": "billingAddress", - "fieldType": "String", - "fieldValidateRules": [ - "maxlength" - ], - "fieldValidateRulesMaxlength": 400 - }, - { - "fieldName": "billingSalutation", - "fieldType": "String", - "fieldValidateRules": [ - "maxlength" - ], - "fieldValidateRulesMaxlength": 80 - } - ], - "relationships": [ - { - "relationshipType": "one-to-many", - "otherEntityName": "customerContact", - "otherEntityRelationshipName": "customer", - "relationshipName": "role" - }, - { - "relationshipType": "one-to-many", - "otherEntityName": "membership", - "otherEntityRelationshipName": "customer", - "relationshipName": "membership" - } - ], - "changelogDate": "20190403083735", - "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/CustomerContact.json b/.jhipster/CustomerContact.json deleted file mode 100644 index 7004cae7..00000000 --- a/.jhipster/CustomerContact.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "CustomerContact", - "fields": [ - { - "fieldName": "role", - "fieldType": "CustomerContactRole", - "fieldValues": "CONTRACTUAL,TECHNICAL,FINANCIAL", - "fieldValidateRules": [ - "required" - ] - } - ], - "relationships": [ - { - "relationshipType": "many-to-one", - "otherEntityName": "contact", - "otherEntityRelationshipName": "role", - "relationshipValidateRules": "required", - "relationshipName": "contact", - "otherEntityField": "email" - }, - { - "relationshipType": "many-to-one", - "otherEntityName": "customer", - "otherEntityRelationshipName": "role", - "relationshipValidateRules": "required", - "relationshipName": "customer", - "otherEntityField": "prefix" - } - ], - "changelogDate": "20190403083737", - "entityTableName": "customer_contact", - "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 deleted file mode 100644 index c44a5c77..00000000 --- a/.jhipster/Membership.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "Membership", - "fields": [ - { - "fieldName": "sinceDate", - "fieldType": "LocalDate", - "fieldValidateRules": [ - "required" - ] - }, - { - "fieldName": "untilDate", - "fieldType": "LocalDate" - } - ], - "relationships": [ - { - "relationshipType": "one-to-many", - "otherEntityName": "share", - "otherEntityRelationshipName": "member", - "relationshipName": "share" - }, - { - "relationshipType": "one-to-many", - "otherEntityName": "asset", - "otherEntityRelationshipName": "member", - "relationshipName": "asset" - }, - { - "relationshipType": "many-to-one", - "otherEntityName": "customer", - "otherEntityRelationshipName": "membership", - "relationshipValidateRules": "required", - "relationshipName": "customer", - "otherEntityField": "prefix" - } - ], - "changelogDate": "20190403083738", - "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/Share.json b/.jhipster/Share.json deleted file mode 100644 index 630f5a24..00000000 --- a/.jhipster/Share.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "Share", - "fields": [ - { - "fieldName": "date", - "fieldType": "LocalDate", - "fieldValidateRules": [ - "required" - ] - }, - { - "fieldName": "action", - "fieldType": "ShareAction", - "fieldValues": "SUBSCRIPTION,CANCELLATION", - "fieldValidateRules": [ - "required" - ] - }, - { - "fieldName": "quantity", - "fieldType": "Integer", - "fieldValidateRules": [ - "required" - ] - }, - { - "fieldName": "comment", - "fieldType": "String", - "fieldValidateRules": [ - "maxlength" - ], - "fieldValidateRulesMaxlength": 160 - } - ], - "relationships": [ - { - "relationshipType": "many-to-one", - "otherEntityName": "membership", - "otherEntityRelationshipName": "share", - "relationshipValidateRules": "required", - "relationshipName": "member", - "otherEntityField": "id" - } - ], - "changelogDate": "20190403083739", - "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 deleted file mode 100644 index fa69bb84..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/Asset.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.hostsharing.hsadminng.domain; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.io.Serializable; -import java.math.BigDecimal; -import java.time.LocalDate; -import java.util.Objects; - -/** - * 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 = "jhi_date", nullable = false) - private LocalDate date; - - @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 = "jhi_comment", length = 160) - private String comment; - - @ManyToOne(optional = false) - @NotNull - @JsonIgnoreProperties("assets") - private Membership member; - - // 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 getDate() { - return date; - } - - public Asset date(LocalDate date) { - this.date = date; - return this; - } - - public void setDate(LocalDate date) { - this.date = date; - } - - 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 getComment() { - return comment; - } - - public Asset comment(String comment) { - this.comment = comment; - return this; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public Membership getMember() { - return member; - } - - public Asset member(Membership membership) { - this.member = membership; - return this; - } - - public void setMember(Membership membership) { - this.member = 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() + - ", date='" + getDate() + "'" + - ", action='" + getAction() + "'" + - ", amount=" + getAmount() + - ", comment='" + getComment() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Contact.java b/src/main/java/org/hostsharing/hsadminng/domain/Contact.java deleted file mode 100644 index 761b9b90..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/Contact.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.hostsharing.hsadminng.domain; - - -import com.fasterxml.jackson.annotation.JsonIgnore; - -import javax.persistence.*; -import javax.validation.constraints.*; - -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; -import java.util.Objects; - -/** - * A Contact. - */ -@Entity -@Table(name = "contact") -public class Contact implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") - @SequenceGenerator(name = "sequenceGenerator") - private Long id; - - @NotNull - @Size(max = 80) - @Column(name = "first_name", length = 80, nullable = false) - private String firstName; - - @NotNull - @Size(max = 80) - @Column(name = "last_name", length = 80, nullable = false) - private String lastName; - - @NotNull - @Size(max = 80) - @Column(name = "email", length = 80, nullable = false) - private String email; - - @OneToMany(mappedBy = "contact") - private Set roles = 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 String getFirstName() { - return firstName; - } - - public Contact firstName(String firstName) { - this.firstName = firstName; - return this; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public Contact lastName(String lastName) { - this.lastName = lastName; - return this; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public Contact email(String email) { - this.email = email; - return this; - } - - public void setEmail(String email) { - this.email = email; - } - - public Set getRoles() { - return roles; - } - - public Contact roles(Set customerContacts) { - this.roles = customerContacts; - return this; - } - - public Contact addRole(CustomerContact customerContact) { - this.roles.add(customerContact); - customerContact.setContact(this); - return this; - } - - public Contact removeRole(CustomerContact customerContact) { - this.roles.remove(customerContact); - customerContact.setContact(null); - return this; - } - - public void setRoles(Set customerContacts) { - this.roles = customerContacts; - } - // 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; - } - Contact contact = (Contact) o; - if (contact.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), contact.getId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getId()); - } - - @Override - public String toString() { - return "Contact{" + - "id=" + getId() + - ", firstName='" + getFirstName() + "'" + - ", lastName='" + getLastName() + "'" + - ", email='" + getEmail() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java deleted file mode 100644 index de1d9e78..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/Customer.java +++ /dev/null @@ -1,246 +0,0 @@ -package org.hostsharing.hsadminng.domain; - - -import javax.persistence.*; -import javax.validation.constraints.*; -import java.io.Serializable; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -/** - * 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 = "jhi_number", nullable = false, unique = true) - private Integer number; - - @NotNull - @Pattern(regexp = "[a-z][a-z0-9]+") - @Column(name = "prefix", nullable = false, unique = true) - private String prefix; - - @NotNull - @Size(max = 80) - @Column(name = "name", length = 80, nullable = false) - private String name; - - @NotNull - @Size(max = 400) - @Column(name = "contractual_address", length = 400, nullable = false) - private String contractualAddress; - - @Size(max = 80) - @Column(name = "contractual_salutation", length = 80) - private String contractualSalutation; - - @Size(max = 400) - @Column(name = "billing_address", length = 400) - private String billingAddress; - - @Size(max = 80) - @Column(name = "billing_salutation", length = 80) - private String billingSalutation; - - @OneToMany(mappedBy = "customer") - private Set roles = new HashSet<>(); - @OneToMany(mappedBy = "customer") - private Set memberships = 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 getNumber() { - return number; - } - - public Customer number(Integer number) { - this.number = number; - return this; - } - - public void setNumber(Integer number) { - this.number = number; - } - - 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 String getContractualAddress() { - return contractualAddress; - } - - public Customer contractualAddress(String contractualAddress) { - this.contractualAddress = contractualAddress; - return this; - } - - public void setContractualAddress(String contractualAddress) { - this.contractualAddress = contractualAddress; - } - - 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 getBillingAddress() { - return billingAddress; - } - - public Customer billingAddress(String billingAddress) { - this.billingAddress = billingAddress; - return this; - } - - public void setBillingAddress(String billingAddress) { - this.billingAddress = billingAddress; - } - - public String getBillingSalutation() { - return billingSalutation; - } - - public Customer billingSalutation(String billingSalutation) { - this.billingSalutation = billingSalutation; - return this; - } - - public void setBillingSalutation(String billingSalutation) { - this.billingSalutation = billingSalutation; - } - - public Set getRoles() { - return roles; - } - - public Customer roles(Set customerContacts) { - this.roles = customerContacts; - return this; - } - - public Customer addRole(CustomerContact customerContact) { - this.roles.add(customerContact); - customerContact.setCustomer(this); - return this; - } - - public Customer removeRole(CustomerContact customerContact) { - this.roles.remove(customerContact); - customerContact.setCustomer(null); - return this; - } - - public void setRoles(Set customerContacts) { - this.roles = customerContacts; - } - - 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; - } - // 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() + - ", number=" + getNumber() + - ", prefix='" + getPrefix() + "'" + - ", name='" + getName() + "'" + - ", contractualAddress='" + getContractualAddress() + "'" + - ", contractualSalutation='" + getContractualSalutation() + "'" + - ", billingAddress='" + getBillingAddress() + "'" + - ", billingSalutation='" + getBillingSalutation() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/CustomerContact.java b/src/main/java/org/hostsharing/hsadminng/domain/CustomerContact.java deleted file mode 100644 index f740361a..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/CustomerContact.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.hostsharing.hsadminng.domain; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import javax.persistence.*; -import javax.validation.constraints.*; - -import java.io.Serializable; -import java.util.Objects; - -import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole; - -/** - * A CustomerContact. - */ -@Entity -@Table(name = "customer_contact") -public class CustomerContact implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") - @SequenceGenerator(name = "sequenceGenerator") - private Long id; - - @NotNull - @Enumerated(EnumType.STRING) - @Column(name = "jhi_role", nullable = false) - private CustomerContactRole role; - - @ManyToOne(optional = false) - @NotNull - @JsonIgnoreProperties("roles") - private Contact contact; - - @ManyToOne(optional = false) - @NotNull - @JsonIgnoreProperties("roles") - 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 CustomerContactRole getRole() { - return role; - } - - public CustomerContact role(CustomerContactRole role) { - this.role = role; - return this; - } - - public void setRole(CustomerContactRole role) { - this.role = role; - } - - public Contact getContact() { - return contact; - } - - public CustomerContact contact(Contact contact) { - this.contact = contact; - return this; - } - - public void setContact(Contact contact) { - this.contact = contact; - } - - public Customer getCustomer() { - return customer; - } - - public CustomerContact 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; - } - CustomerContact customerContact = (CustomerContact) o; - if (customerContact.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), customerContact.getId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getId()); - } - - @Override - public String toString() { - return "CustomerContact{" + - "id=" + getId() + - ", role='" + getRole() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java deleted file mode 100644 index 93f20433..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/Membership.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.hostsharing.hsadminng.domain; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.time.LocalDate; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -/** - * 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 = "since_date", nullable = false) - private LocalDate sinceDate; - - @Column(name = "until_date") - private LocalDate untilDate; - - @OneToMany(mappedBy = "member") - private Set shares = new HashSet<>(); - @OneToMany(mappedBy = "member") - 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 getSinceDate() { - return sinceDate; - } - - public Membership sinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; - return this; - } - - public void setSinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; - } - - public LocalDate getUntilDate() { - return untilDate; - } - - public Membership untilDate(LocalDate untilDate) { - this.untilDate = untilDate; - return this; - } - - public void setUntilDate(LocalDate untilDate) { - this.untilDate = untilDate; - } - - 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.setMember(this); - return this; - } - - public Membership removeShare(Share share) { - this.shares.remove(share); - share.setMember(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.setMember(this); - return this; - } - - public Membership removeAsset(Asset asset) { - this.assets.remove(asset); - asset.setMember(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() + - ", sinceDate='" + getSinceDate() + "'" + - ", untilDate='" + getUntilDate() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/Share.java b/src/main/java/org/hostsharing/hsadminng/domain/Share.java deleted file mode 100644 index 0d91abc1..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/Share.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.hostsharing.hsadminng.domain; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.hostsharing.hsadminng.domain.enumeration.ShareAction; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.io.Serializable; -import java.time.LocalDate; -import java.util.Objects; - -/** - * 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 = "jhi_date", nullable = false) - private LocalDate date; - - @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 = "jhi_comment", length = 160) - private String comment; - - @ManyToOne(optional = false) - @NotNull - @JsonIgnoreProperties("shares") - private Membership member; - - // 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 getDate() { - return date; - } - - public Share date(LocalDate date) { - this.date = date; - return this; - } - - public void setDate(LocalDate date) { - this.date = date; - } - - 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 getComment() { - return comment; - } - - public Share comment(String comment) { - this.comment = comment; - return this; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public Membership getMember() { - return member; - } - - public Share member(Membership membership) { - this.member = membership; - return this; - } - - public void setMember(Membership membership) { - this.member = 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() + - ", date='" + getDate() + "'" + - ", action='" + getAction() + "'" + - ", quantity=" + getQuantity() + - ", comment='" + getComment() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/AssetAction.java b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/AssetAction.java deleted file mode 100644 index a42d7a04..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/AssetAction.java +++ /dev/null @@ -1,8 +0,0 @@ -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/CustomerContactRole.java b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerContactRole.java deleted file mode 100644 index 736a7ff6..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/CustomerContactRole.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.hostsharing.hsadminng.domain.enumeration; - -/** - * The CustomerContactRole enumeration. - */ -public enum CustomerContactRole { - CONTRACTUAL, TECHNICAL, FINANCIAL -} diff --git a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/ShareAction.java b/src/main/java/org/hostsharing/hsadminng/domain/enumeration/ShareAction.java deleted file mode 100644 index 032d8638..00000000 --- a/src/main/java/org/hostsharing/hsadminng/domain/enumeration/ShareAction.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.hostsharing.hsadminng.domain.enumeration; - -/** - * The ShareAction enumeration. - */ -public enum ShareAction { - SUBSCRIPTION, CANCELLATION -} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/AssetRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/AssetRepository.java deleted file mode 100644 index 31c5a947..00000000 --- a/src/main/java/org/hostsharing/hsadminng/repository/AssetRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -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/ContactRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/ContactRepository.java deleted file mode 100644 index 6bc2d4dc..00000000 --- a/src/main/java/org/hostsharing/hsadminng/repository/ContactRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hostsharing.hsadminng.repository; - -import org.hostsharing.hsadminng.domain.Contact; -import org.springframework.data.jpa.repository.*; -import org.springframework.stereotype.Repository; - - -/** - * Spring Data repository for the Contact entity. - */ -@SuppressWarnings("unused") -@Repository -public interface ContactRepository extends JpaRepository, JpaSpecificationExecutor { - -} diff --git a/src/main/java/org/hostsharing/hsadminng/repository/CustomerContactRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/CustomerContactRepository.java deleted file mode 100644 index 88dba2c9..00000000 --- a/src/main/java/org/hostsharing/hsadminng/repository/CustomerContactRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hostsharing.hsadminng.repository; - -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.springframework.data.jpa.repository.*; -import org.springframework.stereotype.Repository; - - -/** - * Spring Data repository for the CustomerContact entity. - */ -@SuppressWarnings("unused") -@Repository -public interface CustomerContactRepository 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 deleted file mode 100644 index 11367351..00000000 --- a/src/main/java/org/hostsharing/hsadminng/repository/CustomerRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 8382a19b..00000000 --- a/src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -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/ShareRepository.java b/src/main/java/org/hostsharing/hsadminng/repository/ShareRepository.java deleted file mode 100644 index 660f4d9b..00000000 --- a/src/main/java/org/hostsharing/hsadminng/repository/ShareRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 81853758..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java +++ /dev/null @@ -1,111 +0,0 @@ -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.getDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getDate(), Asset_.date)); - } - 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.getComment() != null) { - specification = specification.and(buildStringSpecification(criteria.getComment(), Asset_.comment)); - } - if (criteria.getMemberId() != null) { - specification = specification.and(buildSpecification(criteria.getMemberId(), - root -> root.join(Asset_.member, 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 deleted file mode 100644 index 0b6ab5a9..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/AssetService.java +++ /dev/null @@ -1,84 +0,0 @@ -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/ContactQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/ContactQueryService.java deleted file mode 100644 index 6c153b1b..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/ContactQueryService.java +++ /dev/null @@ -1,108 +0,0 @@ -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.Contact; -import org.hostsharing.hsadminng.domain.*; // for static metamodels -import org.hostsharing.hsadminng.repository.ContactRepository; -import org.hostsharing.hsadminng.service.dto.ContactCriteria; -import org.hostsharing.hsadminng.service.dto.ContactDTO; -import org.hostsharing.hsadminng.service.mapper.ContactMapper; - -/** - * Service for executing complex queries for Contact entities in the database. - * The main input is a {@link ContactCriteria} which gets converted to {@link Specification}, - * in a way that all the filters must apply. - * It returns a {@link List} of {@link ContactDTO} or a {@link Page} of {@link ContactDTO} which fulfills the criteria. - */ -@Service -@Transactional(readOnly = true) -public class ContactQueryService extends QueryService { - - private final Logger log = LoggerFactory.getLogger(ContactQueryService.class); - - private final ContactRepository contactRepository; - - private final ContactMapper contactMapper; - - public ContactQueryService(ContactRepository contactRepository, ContactMapper contactMapper) { - this.contactRepository = contactRepository; - this.contactMapper = contactMapper; - } - - /** - * Return a {@link List} of {@link ContactDTO} 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(ContactCriteria criteria) { - log.debug("find by criteria : {}", criteria); - final Specification specification = createSpecification(criteria); - return contactMapper.toDto(contactRepository.findAll(specification)); - } - - /** - * Return a {@link Page} of {@link ContactDTO} 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(ContactCriteria criteria, Pageable page) { - log.debug("find by criteria : {}, page: {}", criteria, page); - final Specification specification = createSpecification(criteria); - return contactRepository.findAll(specification, page) - .map(contactMapper::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(ContactCriteria criteria) { - log.debug("count by criteria : {}", criteria); - final Specification specification = createSpecification(criteria); - return contactRepository.count(specification); - } - - /** - * Function to convert ContactCriteria to a {@link Specification} - */ - private Specification createSpecification(ContactCriteria criteria) { - Specification specification = Specification.where(null); - if (criteria != null) { - if (criteria.getId() != null) { - specification = specification.and(buildSpecification(criteria.getId(), Contact_.id)); - } - if (criteria.getFirstName() != null) { - specification = specification.and(buildStringSpecification(criteria.getFirstName(), Contact_.firstName)); - } - if (criteria.getLastName() != null) { - specification = specification.and(buildStringSpecification(criteria.getLastName(), Contact_.lastName)); - } - if (criteria.getEmail() != null) { - specification = specification.and(buildStringSpecification(criteria.getEmail(), Contact_.email)); - } - if (criteria.getRoleId() != null) { - specification = specification.and(buildSpecification(criteria.getRoleId(), - root -> root.join(Contact_.roles, JoinType.LEFT).get(CustomerContact_.id))); - } - } - return specification; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/ContactService.java b/src/main/java/org/hostsharing/hsadminng/service/ContactService.java deleted file mode 100644 index d75b7fb3..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/ContactService.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.hostsharing.hsadminng.service; - -import org.hostsharing.hsadminng.domain.Contact; -import org.hostsharing.hsadminng.repository.ContactRepository; -import org.hostsharing.hsadminng.service.dto.ContactDTO; -import org.hostsharing.hsadminng.service.mapper.ContactMapper; -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 Contact. - */ -@Service -@Transactional -public class ContactService { - - private final Logger log = LoggerFactory.getLogger(ContactService.class); - - private final ContactRepository contactRepository; - - private final ContactMapper contactMapper; - - public ContactService(ContactRepository contactRepository, ContactMapper contactMapper) { - this.contactRepository = contactRepository; - this.contactMapper = contactMapper; - } - - /** - * Save a contact. - * - * @param contactDTO the entity to save - * @return the persisted entity - */ - public ContactDTO save(ContactDTO contactDTO) { - log.debug("Request to save Contact : {}", contactDTO); - Contact contact = contactMapper.toEntity(contactDTO); - contact = contactRepository.save(contact); - return contactMapper.toDto(contact); - } - - /** - * Get all the contacts. - * - * @param pageable the pagination information - * @return the list of entities - */ - @Transactional(readOnly = true) - public Page findAll(Pageable pageable) { - log.debug("Request to get all Contacts"); - return contactRepository.findAll(pageable) - .map(contactMapper::toDto); - } - - - /** - * Get one contact 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 Contact : {}", id); - return contactRepository.findById(id) - .map(contactMapper::toDto); - } - - /** - * Delete the contact by id. - * - * @param id the id of the entity - */ - public void delete(Long id) { - log.debug("Request to delete Contact : {}", id); - contactRepository.deleteById(id); - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerContactQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerContactQueryService.java deleted file mode 100644 index 3675596d..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerContactQueryService.java +++ /dev/null @@ -1,106 +0,0 @@ -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.CustomerContact; -import org.hostsharing.hsadminng.domain.*; // for static metamodels -import org.hostsharing.hsadminng.repository.CustomerContactRepository; -import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria; -import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper; - -/** - * Service for executing complex queries for CustomerContact entities in the database. - * The main input is a {@link CustomerContactCriteria} which gets converted to {@link Specification}, - * in a way that all the filters must apply. - * It returns a {@link List} of {@link CustomerContactDTO} or a {@link Page} of {@link CustomerContactDTO} which fulfills the criteria. - */ -@Service -@Transactional(readOnly = true) -public class CustomerContactQueryService extends QueryService { - - private final Logger log = LoggerFactory.getLogger(CustomerContactQueryService.class); - - private final CustomerContactRepository customerContactRepository; - - private final CustomerContactMapper customerContactMapper; - - public CustomerContactQueryService(CustomerContactRepository customerContactRepository, CustomerContactMapper customerContactMapper) { - this.customerContactRepository = customerContactRepository; - this.customerContactMapper = customerContactMapper; - } - - /** - * Return a {@link List} of {@link CustomerContactDTO} 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(CustomerContactCriteria criteria) { - log.debug("find by criteria : {}", criteria); - final Specification specification = createSpecification(criteria); - return customerContactMapper.toDto(customerContactRepository.findAll(specification)); - } - - /** - * Return a {@link Page} of {@link CustomerContactDTO} 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(CustomerContactCriteria criteria, Pageable page) { - log.debug("find by criteria : {}, page: {}", criteria, page); - final Specification specification = createSpecification(criteria); - return customerContactRepository.findAll(specification, page) - .map(customerContactMapper::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(CustomerContactCriteria criteria) { - log.debug("count by criteria : {}", criteria); - final Specification specification = createSpecification(criteria); - return customerContactRepository.count(specification); - } - - /** - * Function to convert CustomerContactCriteria to a {@link Specification} - */ - private Specification createSpecification(CustomerContactCriteria criteria) { - Specification specification = Specification.where(null); - if (criteria != null) { - if (criteria.getId() != null) { - specification = specification.and(buildSpecification(criteria.getId(), CustomerContact_.id)); - } - if (criteria.getRole() != null) { - specification = specification.and(buildSpecification(criteria.getRole(), CustomerContact_.role)); - } - if (criteria.getContactId() != null) { - specification = specification.and(buildSpecification(criteria.getContactId(), - root -> root.join(CustomerContact_.contact, JoinType.LEFT).get(Contact_.id))); - } - if (criteria.getCustomerId() != null) { - specification = specification.and(buildSpecification(criteria.getCustomerId(), - root -> root.join(CustomerContact_.customer, JoinType.LEFT).get(Customer_.id))); - } - } - return specification; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerContactService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerContactService.java deleted file mode 100644 index 222ae0a8..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerContactService.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.hostsharing.hsadminng.service; - -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.hostsharing.hsadminng.repository.CustomerContactRepository; -import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper; -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 CustomerContact. - */ -@Service -@Transactional -public class CustomerContactService { - - private final Logger log = LoggerFactory.getLogger(CustomerContactService.class); - - private final CustomerContactRepository customerContactRepository; - - private final CustomerContactMapper customerContactMapper; - - public CustomerContactService(CustomerContactRepository customerContactRepository, CustomerContactMapper customerContactMapper) { - this.customerContactRepository = customerContactRepository; - this.customerContactMapper = customerContactMapper; - } - - /** - * Save a customerContact. - * - * @param customerContactDTO the entity to save - * @return the persisted entity - */ - public CustomerContactDTO save(CustomerContactDTO customerContactDTO) { - log.debug("Request to save CustomerContact : {}", customerContactDTO); - CustomerContact customerContact = customerContactMapper.toEntity(customerContactDTO); - customerContact = customerContactRepository.save(customerContact); - return customerContactMapper.toDto(customerContact); - } - - /** - * Get all the customerContacts. - * - * @param pageable the pagination information - * @return the list of entities - */ - @Transactional(readOnly = true) - public Page findAll(Pageable pageable) { - log.debug("Request to get all CustomerContacts"); - return customerContactRepository.findAll(pageable) - .map(customerContactMapper::toDto); - } - - - /** - * Get one customerContact 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 CustomerContact : {}", id); - return customerContactRepository.findById(id) - .map(customerContactMapper::toDto); - } - - /** - * Delete the customerContact by id. - * - * @param id the id of the entity - */ - public void delete(Long id) { - log.debug("Request to delete CustomerContact : {}", id); - customerContactRepository.deleteById(id); - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java deleted file mode 100644 index 214369a7..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.hostsharing.hsadminng.service; - -import io.github.jhipster.service.QueryService; -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.CustomerContact_; -import org.hostsharing.hsadminng.domain.Customer_; -import org.hostsharing.hsadminng.domain.Membership_; -import org.hostsharing.hsadminng.repository.CustomerRepository; -import org.hostsharing.hsadminng.service.dto.CustomerCriteria; -import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.domain.Page; -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 javax.persistence.criteria.JoinType; -import java.util.List; - -/** - * 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.getNumber() != null) { - specification = specification.and(buildRangeSpecification(criteria.getNumber(), Customer_.number)); - } - 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.getContractualAddress() != null) { - specification = specification.and(buildStringSpecification(criteria.getContractualAddress(), Customer_.contractualAddress)); - } - if (criteria.getContractualSalutation() != null) { - specification = specification.and(buildStringSpecification(criteria.getContractualSalutation(), Customer_.contractualSalutation)); - } - if (criteria.getBillingAddress() != null) { - specification = specification.and(buildStringSpecification(criteria.getBillingAddress(), Customer_.billingAddress)); - } - if (criteria.getBillingSalutation() != null) { - specification = specification.and(buildStringSpecification(criteria.getBillingSalutation(), Customer_.billingSalutation)); - } - if (criteria.getRoleId() != null) { - specification = specification.and(buildSpecification(criteria.getRoleId(), - root -> root.join(Customer_.roles, JoinType.LEFT).get(CustomerContact_.id))); - } - if (criteria.getMembershipId() != null) { - specification = specification.and(buildSpecification(criteria.getMembershipId(), - root -> root.join(Customer_.memberships, JoinType.LEFT).get(Membership_.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 deleted file mode 100644 index d7153deb..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/CustomerService.java +++ /dev/null @@ -1,84 +0,0 @@ -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 deleted file mode 100644 index 66f86f14..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java +++ /dev/null @@ -1,113 +0,0 @@ -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.getSinceDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getSinceDate(), Membership_.sinceDate)); - } - if (criteria.getUntilDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getUntilDate(), Membership_.untilDate)); - } - 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 deleted file mode 100644 index 53fb74cb..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/MembershipService.java +++ /dev/null @@ -1,84 +0,0 @@ -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/ShareQueryService.java b/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java deleted file mode 100644 index 17e51676..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java +++ /dev/null @@ -1,111 +0,0 @@ -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.getDate() != null) { - specification = specification.and(buildRangeSpecification(criteria.getDate(), Share_.date)); - } - 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.getComment() != null) { - specification = specification.and(buildStringSpecification(criteria.getComment(), Share_.comment)); - } - if (criteria.getMemberId() != null) { - specification = specification.and(buildSpecification(criteria.getMemberId(), - root -> root.join(Share_.member, 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 deleted file mode 100644 index 925deb7e..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/ShareService.java +++ /dev/null @@ -1,84 +0,0 @@ -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 deleted file mode 100644 index c9898fb9..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java +++ /dev/null @@ -1,136 +0,0 @@ -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 date; - - private AssetActionFilter action; - - private BigDecimalFilter amount; - - private StringFilter comment; - - private LongFilter memberId; - - public LongFilter getId() { - return id; - } - - public void setId(LongFilter id) { - this.id = id; - } - - public LocalDateFilter getDate() { - return date; - } - - public void setDate(LocalDateFilter date) { - this.date = date; - } - - 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 getComment() { - return comment; - } - - public void setComment(StringFilter comment) { - this.comment = comment; - } - - public LongFilter getMemberId() { - return memberId; - } - - public void setMemberId(LongFilter memberId) { - this.memberId = memberId; - } - - - @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(date, that.date) && - Objects.equals(action, that.action) && - Objects.equals(amount, that.amount) && - Objects.equals(comment, that.comment) && - Objects.equals(memberId, that.memberId); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - date, - action, - amount, - comment, - memberId - ); - } - - @Override - public String toString() { - return "AssetCriteria{" + - (id != null ? "id=" + id + ", " : "") + - (date != null ? "date=" + date + ", " : "") + - (action != null ? "action=" + action + ", " : "") + - (amount != null ? "amount=" + amount + ", " : "") + - (comment != null ? "comment=" + comment + ", " : "") + - (memberId != null ? "memberId=" + memberId + ", " : "") + - "}"; - } - -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java deleted file mode 100644 index 9897321a..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java +++ /dev/null @@ -1,111 +0,0 @@ -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 date; - - @NotNull - private AssetAction action; - - @NotNull - private BigDecimal amount; - - @Size(max = 160) - private String comment; - - - private Long memberId; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public LocalDate getDate() { - return date; - } - - public void setDate(LocalDate date) { - this.date = date; - } - - 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 getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public Long getMemberId() { - return memberId; - } - - public void setMemberId(Long membershipId) { - this.memberId = membershipId; - } - - @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() + - ", date='" + getDate() + "'" + - ", action='" + getAction() + "'" + - ", amount=" + getAmount() + - ", comment='" + getComment() + "'" + - ", member=" + getMemberId() + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/ContactCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ContactCriteria.java deleted file mode 100644 index 1fe3cbee..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ContactCriteria.java +++ /dev/null @@ -1,115 +0,0 @@ -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; - -/** - * Criteria class for the Contact entity. This class is used in ContactResource to - * receive all the possible filtering options from the Http GET request parameters. - * For example the following could be a valid requests: - * /contacts?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 ContactCriteria implements Serializable { - - private static final long serialVersionUID = 1L; - - private LongFilter id; - - private StringFilter firstName; - - private StringFilter lastName; - - private StringFilter email; - - private LongFilter roleId; - - public LongFilter getId() { - return id; - } - - public void setId(LongFilter id) { - this.id = id; - } - - public StringFilter getFirstName() { - return firstName; - } - - public void setFirstName(StringFilter firstName) { - this.firstName = firstName; - } - - public StringFilter getLastName() { - return lastName; - } - - public void setLastName(StringFilter lastName) { - this.lastName = lastName; - } - - public StringFilter getEmail() { - return email; - } - - public void setEmail(StringFilter email) { - this.email = email; - } - - public LongFilter getRoleId() { - return roleId; - } - - public void setRoleId(LongFilter roleId) { - this.roleId = roleId; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ContactCriteria that = (ContactCriteria) o; - return - Objects.equals(id, that.id) && - Objects.equals(firstName, that.firstName) && - Objects.equals(lastName, that.lastName) && - Objects.equals(email, that.email) && - Objects.equals(roleId, that.roleId); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - firstName, - lastName, - email, - roleId - ); - } - - @Override - public String toString() { - return "ContactCriteria{" + - (id != null ? "id=" + id + ", " : "") + - (firstName != null ? "firstName=" + firstName + ", " : "") + - (lastName != null ? "lastName=" + lastName + ", " : "") + - (email != null ? "email=" + email + ", " : "") + - (roleId != null ? "roleId=" + roleId + ", " : "") + - "}"; - } - -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/ContactDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ContactDTO.java deleted file mode 100644 index c5a7ba0d..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ContactDTO.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.hostsharing.hsadminng.service.dto; -import javax.validation.constraints.*; -import java.io.Serializable; -import java.util.Objects; - -/** - * A DTO for the Contact entity. - */ -public class ContactDTO implements Serializable { - - private Long id; - - @NotNull - @Size(max = 80) - private String firstName; - - @NotNull - @Size(max = 80) - private String lastName; - - @NotNull - @Size(max = 80) - private String email; - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - ContactDTO contactDTO = (ContactDTO) o; - if (contactDTO.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), contactDTO.getId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getId()); - } - - @Override - public String toString() { - return "ContactDTO{" + - "id=" + getId() + - ", firstName='" + getFirstName() + "'" + - ", lastName='" + getLastName() + "'" + - ", email='" + getEmail() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactCriteria.java deleted file mode 100644 index d4173724..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactCriteria.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.hostsharing.hsadminng.service.dto; - -import java.io.Serializable; -import java.util.Objects; -import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole; -import io.github.jhipster.service.filter.BooleanFilter; -import io.github.jhipster.service.filter.DoubleFilter; -import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.FloatFilter; -import io.github.jhipster.service.filter.IntegerFilter; -import io.github.jhipster.service.filter.LongFilter; -import io.github.jhipster.service.filter.StringFilter; - -/** - * Criteria class for the CustomerContact entity. This class is used in CustomerContactResource to - * receive all the possible filtering options from the Http GET request parameters. - * For example the following could be a valid requests: - * /customer-contacts?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 CustomerContactCriteria implements Serializable { - /** - * Class for filtering CustomerContactRole - */ - public static class CustomerContactRoleFilter extends Filter { - } - - private static final long serialVersionUID = 1L; - - private LongFilter id; - - private CustomerContactRoleFilter role; - - private LongFilter contactId; - - private LongFilter customerId; - - public LongFilter getId() { - return id; - } - - public void setId(LongFilter id) { - this.id = id; - } - - public CustomerContactRoleFilter getRole() { - return role; - } - - public void setRole(CustomerContactRoleFilter role) { - this.role = role; - } - - public LongFilter getContactId() { - return contactId; - } - - public void setContactId(LongFilter contactId) { - this.contactId = contactId; - } - - 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 CustomerContactCriteria that = (CustomerContactCriteria) o; - return - Objects.equals(id, that.id) && - Objects.equals(role, that.role) && - Objects.equals(contactId, that.contactId) && - Objects.equals(customerId, that.customerId); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - role, - contactId, - customerId - ); - } - - @Override - public String toString() { - return "CustomerContactCriteria{" + - (id != null ? "id=" + id + ", " : "") + - (role != null ? "role=" + role + ", " : "") + - (contactId != null ? "contactId=" + contactId + ", " : "") + - (customerId != null ? "customerId=" + customerId + ", " : "") + - "}"; - } - -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactDTO.java deleted file mode 100644 index 97fa8f8b..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerContactDTO.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.hostsharing.hsadminng.service.dto; -import javax.validation.constraints.*; -import java.io.Serializable; -import java.util.Objects; -import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole; - -/** - * A DTO for the CustomerContact entity. - */ -public class CustomerContactDTO implements Serializable { - - private Long id; - - @NotNull - private CustomerContactRole role; - - - private Long contactId; - - private String contactEmail; - - private Long customerId; - - private String customerPrefix; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public CustomerContactRole getRole() { - return role; - } - - public void setRole(CustomerContactRole role) { - this.role = role; - } - - public Long getContactId() { - return contactId; - } - - public void setContactId(Long contactId) { - this.contactId = contactId; - } - - public String getContactEmail() { - return contactEmail; - } - - public void setContactEmail(String contactEmail) { - this.contactEmail = contactEmail; - } - - 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; - } - - CustomerContactDTO customerContactDTO = (CustomerContactDTO) o; - if (customerContactDTO.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), customerContactDTO.getId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(getId()); - } - - @Override - public String toString() { - return "CustomerContactDTO{" + - "id=" + getId() + - ", role='" + getRole() + "'" + - ", contact=" + getContactId() + - ", contact='" + getContactEmail() + "'" + - ", customer=" + getCustomerId() + - ", customer='" + getCustomerPrefix() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java deleted file mode 100644 index c46dd0d3..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java +++ /dev/null @@ -1,178 +0,0 @@ -package org.hostsharing.hsadminng.service.dto; - -import io.github.jhipster.service.filter.Filter; -import io.github.jhipster.service.filter.IntegerFilter; -import io.github.jhipster.service.filter.LongFilter; -import io.github.jhipster.service.filter.StringFilter; - -import java.io.Serializable; -import java.util.Objects; - -/** - * 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 { - - private static final long serialVersionUID = 1L; - - private LongFilter id; - - private IntegerFilter number; - - private StringFilter prefix; - - private StringFilter name; - - private StringFilter contractualAddress; - - private StringFilter contractualSalutation; - - private StringFilter billingAddress; - - private StringFilter billingSalutation; - - private LongFilter roleId; - - private LongFilter membershipId; - - public LongFilter getId() { - return id; - } - - public void setId(LongFilter id) { - this.id = id; - } - - public IntegerFilter getNumber() { - return number; - } - - public void setNumber(IntegerFilter number) { - this.number = number; - } - - 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 StringFilter getContractualAddress() { - return contractualAddress; - } - - public void setContractualAddress(StringFilter contractualAddress) { - this.contractualAddress = contractualAddress; - } - - public StringFilter getContractualSalutation() { - return contractualSalutation; - } - - public void setContractualSalutation(StringFilter contractualSalutation) { - this.contractualSalutation = contractualSalutation; - } - - public StringFilter getBillingAddress() { - return billingAddress; - } - - public void setBillingAddress(StringFilter billingAddress) { - this.billingAddress = billingAddress; - } - - public StringFilter getBillingSalutation() { - return billingSalutation; - } - - public void setBillingSalutation(StringFilter billingSalutation) { - this.billingSalutation = billingSalutation; - } - - public LongFilter getRoleId() { - return roleId; - } - - public void setRoleId(LongFilter roleId) { - this.roleId = roleId; - } - - 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 CustomerCriteria that = (CustomerCriteria) o; - return - Objects.equals(id, that.id) && - Objects.equals(number, that.number) && - Objects.equals(prefix, that.prefix) && - Objects.equals(name, that.name) && - Objects.equals(contractualAddress, that.contractualAddress) && - Objects.equals(contractualSalutation, that.contractualSalutation) && - Objects.equals(billingAddress, that.billingAddress) && - Objects.equals(billingSalutation, that.billingSalutation) && - Objects.equals(roleId, that.roleId) && - Objects.equals(membershipId, that.membershipId); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - number, - prefix, - name, - contractualAddress, - contractualSalutation, - billingAddress, - billingSalutation, - roleId, - membershipId - ); - } - - @Override - public String toString() { - return "CustomerCriteria{" + - (id != null ? "id=" + id + ", " : "") + - (number != null ? "number=" + number + ", " : "") + - (prefix != null ? "prefix=" + prefix + ", " : "") + - (name != null ? "name=" + name + ", " : "") + - (contractualAddress != null ? "contractualAddress=" + contractualAddress + ", " : "") + - (contractualSalutation != null ? "contractualSalutation=" + contractualSalutation + ", " : "") + - (billingAddress != null ? "billingAddress=" + billingAddress + ", " : "") + - (billingSalutation != null ? "billingSalutation=" + billingSalutation + ", " : "") + - (roleId != null ? "roleId=" + roleId + ", " : "") + - (membershipId != null ? "membershipId=" + membershipId + ", " : "") + - "}"; - } - -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java deleted file mode 100644 index ff8bf3d8..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.hostsharing.hsadminng.service.dto; -import javax.validation.constraints.*; -import java.io.Serializable; -import java.util.Objects; - -/** - * A DTO for the Customer entity. - */ -public class CustomerDTO implements Serializable { - - private Long id; - - @NotNull - @Min(value = 10000) - @Max(value = 99999) - private Integer number; - - @NotNull - @Pattern(regexp = "[a-z][a-z0-9]+") - private String prefix; - - @NotNull - @Size(max = 80) - private String name; - - @NotNull - @Size(max = 400) - private String contractualAddress; - - @Size(max = 80) - private String contractualSalutation; - - @Size(max = 400) - private String billingAddress; - - @Size(max = 80) - private String billingSalutation; - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Integer getNumber() { - return number; - } - - public void setNumber(Integer number) { - this.number = number; - } - - 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 String getContractualAddress() { - return contractualAddress; - } - - public void setContractualAddress(String contractualAddress) { - this.contractualAddress = contractualAddress; - } - - public String getContractualSalutation() { - return contractualSalutation; - } - - public void setContractualSalutation(String contractualSalutation) { - this.contractualSalutation = contractualSalutation; - } - - public String getBillingAddress() { - return billingAddress; - } - - public void setBillingAddress(String billingAddress) { - this.billingAddress = billingAddress; - } - - public String getBillingSalutation() { - return billingSalutation; - } - - public void setBillingSalutation(String billingSalutation) { - this.billingSalutation = billingSalutation; - } - - @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() + - ", number=" + getNumber() + - ", prefix='" + getPrefix() + "'" + - ", name='" + getName() + "'" + - ", contractualAddress='" + getContractualAddress() + "'" + - ", contractualSalutation='" + getContractualSalutation() + "'" + - ", billingAddress='" + getBillingAddress() + "'" + - ", billingSalutation='" + getBillingSalutation() + "'" + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java deleted file mode 100644 index 6e8e7b45..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java +++ /dev/null @@ -1,129 +0,0 @@ -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 sinceDate; - - private LocalDateFilter untilDate; - - private LongFilter shareId; - - private LongFilter assetId; - - private LongFilter customerId; - - public LongFilter getId() { - return id; - } - - public void setId(LongFilter id) { - this.id = id; - } - - public LocalDateFilter getSinceDate() { - return sinceDate; - } - - public void setSinceDate(LocalDateFilter sinceDate) { - this.sinceDate = sinceDate; - } - - public LocalDateFilter getUntilDate() { - return untilDate; - } - - public void setUntilDate(LocalDateFilter untilDate) { - this.untilDate = untilDate; - } - - 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(sinceDate, that.sinceDate) && - Objects.equals(untilDate, that.untilDate) && - Objects.equals(shareId, that.shareId) && - Objects.equals(assetId, that.assetId) && - Objects.equals(customerId, that.customerId); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - sinceDate, - untilDate, - shareId, - assetId, - customerId - ); - } - - @Override - public String toString() { - return "MembershipCriteria{" + - (id != null ? "id=" + id + ", " : "") + - (sinceDate != null ? "sinceDate=" + sinceDate + ", " : "") + - (untilDate != null ? "untilDate=" + untilDate + ", " : "") + - (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 deleted file mode 100644 index 12232fed..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java +++ /dev/null @@ -1,95 +0,0 @@ -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 sinceDate; - - private LocalDate untilDate; - - - private Long customerId; - - private String customerPrefix; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public LocalDate getSinceDate() { - return sinceDate; - } - - public void setSinceDate(LocalDate sinceDate) { - this.sinceDate = sinceDate; - } - - public LocalDate getUntilDate() { - return untilDate; - } - - public void setUntilDate(LocalDate untilDate) { - this.untilDate = untilDate; - } - - 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() + - ", sinceDate='" + getSinceDate() + "'" + - ", untilDate='" + getUntilDate() + "'" + - ", 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 deleted file mode 100644 index 1db1aff5..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java +++ /dev/null @@ -1,135 +0,0 @@ -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 date; - - private ShareActionFilter action; - - private IntegerFilter quantity; - - private StringFilter comment; - - private LongFilter memberId; - - public LongFilter getId() { - return id; - } - - public void setId(LongFilter id) { - this.id = id; - } - - public LocalDateFilter getDate() { - return date; - } - - public void setDate(LocalDateFilter date) { - this.date = date; - } - - 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 getComment() { - return comment; - } - - public void setComment(StringFilter comment) { - this.comment = comment; - } - - public LongFilter getMemberId() { - return memberId; - } - - public void setMemberId(LongFilter memberId) { - this.memberId = memberId; - } - - - @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(date, that.date) && - Objects.equals(action, that.action) && - Objects.equals(quantity, that.quantity) && - Objects.equals(comment, that.comment) && - Objects.equals(memberId, that.memberId); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - date, - action, - quantity, - comment, - memberId - ); - } - - @Override - public String toString() { - return "ShareCriteria{" + - (id != null ? "id=" + id + ", " : "") + - (date != null ? "date=" + date + ", " : "") + - (action != null ? "action=" + action + ", " : "") + - (quantity != null ? "quantity=" + quantity + ", " : "") + - (comment != null ? "comment=" + comment + ", " : "") + - (memberId != null ? "memberId=" + memberId + ", " : "") + - "}"; - } - -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java b/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java deleted file mode 100644 index 1ae37049..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java +++ /dev/null @@ -1,110 +0,0 @@ -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 date; - - @NotNull - private ShareAction action; - - @NotNull - private Integer quantity; - - @Size(max = 160) - private String comment; - - - private Long memberId; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public LocalDate getDate() { - return date; - } - - public void setDate(LocalDate date) { - this.date = date; - } - - 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 getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public Long getMemberId() { - return memberId; - } - - public void setMemberId(Long membershipId) { - this.memberId = membershipId; - } - - @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() + - ", date='" + getDate() + "'" + - ", action='" + getAction() + "'" + - ", quantity=" + getQuantity() + - ", comment='" + getComment() + "'" + - ", member=" + getMemberId() + - "}"; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java deleted file mode 100644 index 5d39692e..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -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 = "member.id", target = "memberId") - AssetDTO toDto(Asset asset); - - @Mapping(source = "memberId", target = "member") - 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/ContactMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/ContactMapper.java deleted file mode 100644 index 26974051..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/ContactMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hostsharing.hsadminng.service.mapper; - -import org.hostsharing.hsadminng.domain.*; -import org.hostsharing.hsadminng.service.dto.ContactDTO; - -import org.mapstruct.*; - -/** - * Mapper for the entity Contact and its DTO ContactDTO. - */ -@Mapper(componentModel = "spring", uses = {}) -public interface ContactMapper extends EntityMapper { - - - @Mapping(target = "roles", ignore = true) - Contact toEntity(ContactDTO contactDTO); - - default Contact fromId(Long id) { - if (id == null) { - return null; - } - Contact contact = new Contact(); - contact.setId(id); - return contact; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerContactMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerContactMapper.java deleted file mode 100644 index 3e4671e2..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerContactMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hostsharing.hsadminng.service.mapper; - -import org.hostsharing.hsadminng.domain.*; -import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; - -import org.mapstruct.*; - -/** - * Mapper for the entity CustomerContact and its DTO CustomerContactDTO. - */ -@Mapper(componentModel = "spring", uses = {ContactMapper.class, CustomerMapper.class}) -public interface CustomerContactMapper extends EntityMapper { - - @Mapping(source = "contact.id", target = "contactId") - @Mapping(source = "contact.email", target = "contactEmail") - @Mapping(source = "customer.id", target = "customerId") - @Mapping(source = "customer.prefix", target = "customerPrefix") - CustomerContactDTO toDto(CustomerContact customerContact); - - @Mapping(source = "contactId", target = "contact") - @Mapping(source = "customerId", target = "customer") - CustomerContact toEntity(CustomerContactDTO customerContactDTO); - - default CustomerContact fromId(Long id) { - if (id == null) { - return null; - } - CustomerContact customerContact = new CustomerContact(); - customerContact.setId(id); - return customerContact; - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java deleted file mode 100644 index 4bb2f1e9..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hostsharing.hsadminng.service.mapper; - -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; - -/** - * Mapper for the entity Customer and its DTO CustomerDTO. - */ -@Mapper(componentModel = "spring", uses = {}) -public interface CustomerMapper extends EntityMapper { - - - @Mapping(target = "roles", ignore = true) - @Mapping(target = "memberships", 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 deleted file mode 100644 index 65955272..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/EntityMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 02a45ace..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -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/ShareMapper.java b/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java deleted file mode 100644 index c5ed7f33..00000000 --- a/src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -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 = "member.id", target = "memberId") - ShareDTO toDto(Share share); - - @Mapping(source = "memberId", target = "member") - 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 deleted file mode 100644 index 3e142f28..00000000 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java +++ /dev/null @@ -1,138 +0,0 @@ -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/ContactResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/ContactResource.java deleted file mode 100644 index df5670f7..00000000 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/ContactResource.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; -import org.hostsharing.hsadminng.service.ContactService; -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.ContactDTO; -import org.hostsharing.hsadminng.service.dto.ContactCriteria; -import org.hostsharing.hsadminng.service.ContactQueryService; -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 Contact. - */ -@RestController -@RequestMapping("/api") -public class ContactResource { - - private final Logger log = LoggerFactory.getLogger(ContactResource.class); - - private static final String ENTITY_NAME = "contact"; - - private final ContactService contactService; - - private final ContactQueryService contactQueryService; - - public ContactResource(ContactService contactService, ContactQueryService contactQueryService) { - this.contactService = contactService; - this.contactQueryService = contactQueryService; - } - - /** - * POST /contacts : Create a new contact. - * - * @param contactDTO the contactDTO to create - * @return the ResponseEntity with status 201 (Created) and with body the new contactDTO, or with status 400 (Bad Request) if the contact has already an ID - * @throws URISyntaxException if the Location URI syntax is incorrect - */ - @PostMapping("/contacts") - public ResponseEntity createContact(@Valid @RequestBody ContactDTO contactDTO) throws URISyntaxException { - log.debug("REST request to save Contact : {}", contactDTO); - if (contactDTO.getId() != null) { - throw new BadRequestAlertException("A new contact cannot already have an ID", ENTITY_NAME, "idexists"); - } - ContactDTO result = contactService.save(contactDTO); - return ResponseEntity.created(new URI("/api/contacts/" + result.getId())) - .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) - .body(result); - } - - /** - * PUT /contacts : Updates an existing contact. - * - * @param contactDTO the contactDTO to update - * @return the ResponseEntity with status 200 (OK) and with body the updated contactDTO, - * or with status 400 (Bad Request) if the contactDTO is not valid, - * or with status 500 (Internal Server Error) if the contactDTO couldn't be updated - * @throws URISyntaxException if the Location URI syntax is incorrect - */ - @PutMapping("/contacts") - public ResponseEntity updateContact(@Valid @RequestBody ContactDTO contactDTO) throws URISyntaxException { - log.debug("REST request to update Contact : {}", contactDTO); - if (contactDTO.getId() == null) { - throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); - } - ContactDTO result = contactService.save(contactDTO); - return ResponseEntity.ok() - .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, contactDTO.getId().toString())) - .body(result); - } - - /** - * GET /contacts : get all the contacts. - * - * @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 contacts in body - */ - @GetMapping("/contacts") - public ResponseEntity> getAllContacts(ContactCriteria criteria, Pageable pageable) { - log.debug("REST request to get Contacts by criteria: {}", criteria); - Page page = contactQueryService.findByCriteria(criteria, pageable); - HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/contacts"); - return ResponseEntity.ok().headers(headers).body(page.getContent()); - } - - /** - * GET /contacts/count : count all the contacts. - * - * @param criteria the criterias which the requested entities should match - * @return the ResponseEntity with status 200 (OK) and the count in body - */ - @GetMapping("/contacts/count") - public ResponseEntity countContacts(ContactCriteria criteria) { - log.debug("REST request to count Contacts by criteria: {}", criteria); - return ResponseEntity.ok().body(contactQueryService.countByCriteria(criteria)); - } - - /** - * GET /contacts/:id : get the "id" contact. - * - * @param id the id of the contactDTO to retrieve - * @return the ResponseEntity with status 200 (OK) and with body the contactDTO, or with status 404 (Not Found) - */ - @GetMapping("/contacts/{id}") - public ResponseEntity getContact(@PathVariable Long id) { - log.debug("REST request to get Contact : {}", id); - Optional contactDTO = contactService.findOne(id); - return ResponseUtil.wrapOrNotFound(contactDTO); - } - - /** - * DELETE /contacts/:id : delete the "id" contact. - * - * @param id the id of the contactDTO to delete - * @return the ResponseEntity with status 200 (OK) - */ - @DeleteMapping("/contacts/{id}") - public ResponseEntity deleteContact(@PathVariable Long id) { - log.debug("REST request to delete Contact : {}", id); - contactService.delete(id); - return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); - } -} diff --git a/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerContactResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerContactResource.java deleted file mode 100644 index 5308c4a3..00000000 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerContactResource.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; -import org.hostsharing.hsadminng.service.CustomerContactService; -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.CustomerContactDTO; -import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria; -import org.hostsharing.hsadminng.service.CustomerContactQueryService; -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 CustomerContact. - */ -@RestController -@RequestMapping("/api") -public class CustomerContactResource { - - private final Logger log = LoggerFactory.getLogger(CustomerContactResource.class); - - private static final String ENTITY_NAME = "customerContact"; - - private final CustomerContactService customerContactService; - - private final CustomerContactQueryService customerContactQueryService; - - public CustomerContactResource(CustomerContactService customerContactService, CustomerContactQueryService customerContactQueryService) { - this.customerContactService = customerContactService; - this.customerContactQueryService = customerContactQueryService; - } - - /** - * POST /customer-contacts : Create a new customerContact. - * - * @param customerContactDTO the customerContactDTO to create - * @return the ResponseEntity with status 201 (Created) and with body the new customerContactDTO, or with status 400 (Bad Request) if the customerContact has already an ID - * @throws URISyntaxException if the Location URI syntax is incorrect - */ - @PostMapping("/customer-contacts") - public ResponseEntity createCustomerContact(@Valid @RequestBody CustomerContactDTO customerContactDTO) throws URISyntaxException { - log.debug("REST request to save CustomerContact : {}", customerContactDTO); - if (customerContactDTO.getId() != null) { - throw new BadRequestAlertException("A new customerContact cannot already have an ID", ENTITY_NAME, "idexists"); - } - CustomerContactDTO result = customerContactService.save(customerContactDTO); - return ResponseEntity.created(new URI("/api/customer-contacts/" + result.getId())) - .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) - .body(result); - } - - /** - * PUT /customer-contacts : Updates an existing customerContact. - * - * @param customerContactDTO the customerContactDTO to update - * @return the ResponseEntity with status 200 (OK) and with body the updated customerContactDTO, - * or with status 400 (Bad Request) if the customerContactDTO is not valid, - * or with status 500 (Internal Server Error) if the customerContactDTO couldn't be updated - * @throws URISyntaxException if the Location URI syntax is incorrect - */ - @PutMapping("/customer-contacts") - public ResponseEntity updateCustomerContact(@Valid @RequestBody CustomerContactDTO customerContactDTO) throws URISyntaxException { - log.debug("REST request to update CustomerContact : {}", customerContactDTO); - if (customerContactDTO.getId() == null) { - throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); - } - CustomerContactDTO result = customerContactService.save(customerContactDTO); - return ResponseEntity.ok() - .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, customerContactDTO.getId().toString())) - .body(result); - } - - /** - * GET /customer-contacts : get all the customerContacts. - * - * @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 customerContacts in body - */ - @GetMapping("/customer-contacts") - public ResponseEntity> getAllCustomerContacts(CustomerContactCriteria criteria, Pageable pageable) { - log.debug("REST request to get CustomerContacts by criteria: {}", criteria); - Page page = customerContactQueryService.findByCriteria(criteria, pageable); - HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/customer-contacts"); - return ResponseEntity.ok().headers(headers).body(page.getContent()); - } - - /** - * GET /customer-contacts/count : count all the customerContacts. - * - * @param criteria the criterias which the requested entities should match - * @return the ResponseEntity with status 200 (OK) and the count in body - */ - @GetMapping("/customer-contacts/count") - public ResponseEntity countCustomerContacts(CustomerContactCriteria criteria) { - log.debug("REST request to count CustomerContacts by criteria: {}", criteria); - return ResponseEntity.ok().body(customerContactQueryService.countByCriteria(criteria)); - } - - /** - * GET /customer-contacts/:id : get the "id" customerContact. - * - * @param id the id of the customerContactDTO to retrieve - * @return the ResponseEntity with status 200 (OK) and with body the customerContactDTO, or with status 404 (Not Found) - */ - @GetMapping("/customer-contacts/{id}") - public ResponseEntity getCustomerContact(@PathVariable Long id) { - log.debug("REST request to get CustomerContact : {}", id); - Optional customerContactDTO = customerContactService.findOne(id); - return ResponseUtil.wrapOrNotFound(customerContactDTO); - } - - /** - * DELETE /customer-contacts/:id : delete the "id" customerContact. - * - * @param id the id of the customerContactDTO to delete - * @return the ResponseEntity with status 200 (OK) - */ - @DeleteMapping("/customer-contacts/{id}") - public ResponseEntity deleteCustomerContact(@PathVariable Long id) { - log.debug("REST request to delete CustomerContact : {}", id); - customerContactService.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 deleted file mode 100644 index aa5e3710..00000000 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/CustomerResource.java +++ /dev/null @@ -1,138 +0,0 @@ -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 deleted file mode 100644 index befa075f..00000000 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/MembershipResource.java +++ /dev/null @@ -1,138 +0,0 @@ -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/ShareResource.java b/src/main/java/org/hostsharing/hsadminng/web/rest/ShareResource.java deleted file mode 100644 index d7c2d2f2..00000000 --- a/src/main/java/org/hostsharing/hsadminng/web/rest/ShareResource.java +++ /dev/null @@ -1,138 +0,0 @@ -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 14b17d8f..9af8c485 100644 --- a/src/main/jdl/customer.jdl +++ b/src/main/jdl/customer.jdl @@ -1,37 +1,24 @@ filter all dto all with mapstruct service all with serviceClass -paginate all with infinite-scroll +paginate all with infinite-scroll entity Customer { - number Integer required unique min(10000) max(99999), - prefix String required unique pattern(/[a-z][a-z0-9]+/), + 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), - contractualAddress String required maxlength(400), contractualSalutation String maxlength(80), + contractualAddress String required maxlength(400), + billingSalutation String maxlength(80), billingAddress String maxlength(400), - billingSalutation String maxlength(80) -} - -entity Contact { - firstName String required maxlength(80), - lastName String required maxlength(80), - email String required maxlength(80) -} - -enum CustomerContactRole { - CONTRACTUAL, - TECHNICAL, - FINANCIAL -} - -entity CustomerContact { - role CustomerContactRole required + remark String maxlength(160) } entity Membership { - sinceDate LocalDate required, - untilDate LocalDate + documentDate LocalDate required, + memberFrom LocalDate required, + memberUntil LocalDate, + remark String maxlength(160) } enum ShareAction { @@ -40,10 +27,11 @@ enum ShareAction { } entity Share { - date LocalDate required, + documentDate LocalDate required, + valueDate LocalDate required, action ShareAction required, quantity Integer required, - comment String maxlength(160) + remark String maxlength(160) } enum AssetAction { @@ -56,17 +44,28 @@ enum AssetAction { } entity Asset { - date LocalDate required, + documentDate LocalDate required, + valueDate LocalDate required, action AssetAction required, amount BigDecimal required, - comment String maxlength(160) + remark String maxlength(160) +} + +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, + remark String maxlength(160) } relationship OneToMany { - Contact{role} to CustomerContact{contact(email) required}, - Customer{role} to CustomerContact{customer(prefix) required}, - Customer to Membership{customer(prefix) required}, - Membership to Share{member required}, - Membership to Asset{member required} + 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} } - diff --git a/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml b/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml deleted file mode 100644 index b888eebe..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083735_added_entity_Customer.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml b/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml deleted file mode 100644 index da4e0b9d..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083736_added_entity_Contact.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml b/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml deleted file mode 100644 index f9e6013b..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_CustomerContact.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml b/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml deleted file mode 100644 index bfad5a7e..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083737_added_entity_constraints_CustomerContact.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml b/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml deleted file mode 100644 index 95973eb5..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_Membership.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_constraints_Membership.xml b/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_constraints_Membership.xml deleted file mode 100644 index 47849491..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083738_added_entity_constraints_Membership.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml b/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml deleted file mode 100644 index 24fd082a..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_Share.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml b/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml deleted file mode 100644 index a5b4cebd..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083739_added_entity_constraints_Share.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml b/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml deleted file mode 100644 index 682f4e2c..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_Asset.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml b/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml deleted file mode 100644 index 329a22b8..00000000 --- a/src/main/resources/config/liquibase/changelog/20190403083740_added_entity_constraints_Asset.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index 97a01937..f2b0b1f7 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -5,16 +5,6 @@ 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 deleted file mode 100644 index bd1b9f78..00000000 --- a/src/main/webapp/app/entities/asset/asset-delete-dialog.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
    - - - -
    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 deleted file mode 100644 index ff1dd113..00000000 --- a/src/main/webapp/app/entities/asset/asset-delete-dialog.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -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 deleted file mode 100644 index 29a4b452..00000000 --- a/src/main/webapp/app/entities/asset/asset-detail.component.html +++ /dev/null @@ -1,45 +0,0 @@ -
    -
    -
    -

    Asset {{asset.id}}

    -
    - -
    -
    Date
    -
    - {{asset.date}} -
    -
    Action
    -
    - {{asset.action}} -
    -
    Amount
    -
    - {{asset.amount}} -
    -
    Comment
    -
    - {{asset.comment}} -
    -
    Member
    -
    - -
    -
    - - - - -
    -
    -
    diff --git a/src/main/webapp/app/entities/asset/asset-detail.component.ts b/src/main/webapp/app/entities/asset/asset-detail.component.ts deleted file mode 100644 index 635ee255..00000000 --- a/src/main/webapp/app/entities/asset/asset-detail.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index 0e1fa8d1..00000000 --- a/src/main/webapp/app/entities/asset/asset-update.component.html +++ /dev/null @@ -1,97 +0,0 @@ -
    -
    -
    -

    Create or edit a Asset

    -
    - -
    - - -
    -
    - -
    - - - - -
    -
    - - 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 deleted file mode 100644 index 98147937..00000000 --- a/src/main/webapp/app/entities/asset/asset-update.component.ts +++ /dev/null @@ -1,78 +0,0 @@ -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[]; - dateDp: 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 deleted file mode 100644 index 0ac03e8f..00000000 --- a/src/main/webapp/app/entities/asset/asset.component.html +++ /dev/null @@ -1,66 +0,0 @@ -
    -

    - Assets - -

    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    ID Date Action Amount Comment Member
    {{asset.id}}{{asset.date | date:'mediumDate'}}{{asset.action}}{{asset.amount}}{{asset.comment}} - - -
    - - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/asset/asset.component.ts b/src/main/webapp/app/entities/asset/asset.component.ts deleted file mode 100644 index 4a5c8445..00000000 --- a/src/main/webapp/app/entities/asset/asset.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -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 deleted file mode 100644 index 282a44e4..00000000 --- a/src/main/webapp/app/entities/asset/asset.module.ts +++ /dev/null @@ -1,34 +0,0 @@ -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 deleted file mode 100644 index b7e030d8..00000000 --- a/src/main/webapp/app/entities/asset/asset.route.ts +++ /dev/null @@ -1,93 +0,0 @@ -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 deleted file mode 100644 index 9ef5cbde..00000000 --- a/src/main/webapp/app/entities/asset/asset.service.ts +++ /dev/null @@ -1,74 +0,0 @@ -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, { - date: asset.date != null && asset.date.isValid() ? asset.date.format(DATE_FORMAT) : null - }); - return copy; - } - - protected convertDateFromServer(res: EntityResponseType): EntityResponseType { - if (res.body) { - res.body.date = res.body.date != null ? moment(res.body.date) : null; - } - return res; - } - - protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { - if (res.body) { - res.body.forEach((asset: IAsset) => { - asset.date = asset.date != null ? moment(asset.date) : null; - }); - } - return res; - } -} diff --git a/src/main/webapp/app/entities/asset/index.ts b/src/main/webapp/app/entities/asset/index.ts deleted file mode 100644 index 5f865f3d..00000000 --- a/src/main/webapp/app/entities/asset/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -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/contact/contact-delete-dialog.component.html b/src/main/webapp/app/entities/contact/contact-delete-dialog.component.html deleted file mode 100644 index 725d215a..00000000 --- a/src/main/webapp/app/entities/contact/contact-delete-dialog.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
    - - - -
    diff --git a/src/main/webapp/app/entities/contact/contact-delete-dialog.component.ts b/src/main/webapp/app/entities/contact/contact-delete-dialog.component.ts deleted file mode 100644 index eef90f7f..00000000 --- a/src/main/webapp/app/entities/contact/contact-delete-dialog.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -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 { IContact } from 'app/shared/model/contact.model'; -import { ContactService } from './contact.service'; - -@Component({ - selector: 'jhi-contact-delete-dialog', - templateUrl: './contact-delete-dialog.component.html' -}) -export class ContactDeleteDialogComponent { - contact: IContact; - - constructor(protected contactService: ContactService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} - - clear() { - this.activeModal.dismiss('cancel'); - } - - confirmDelete(id: number) { - this.contactService.delete(id).subscribe(response => { - this.eventManager.broadcast({ - name: 'contactListModification', - content: 'Deleted an contact' - }); - this.activeModal.dismiss(true); - }); - } -} - -@Component({ - selector: 'jhi-contact-delete-popup', - template: '' -}) -export class ContactDeletePopupComponent implements OnInit, OnDestroy { - protected ngbModalRef: NgbModalRef; - - constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} - - ngOnInit() { - this.activatedRoute.data.subscribe(({ contact }) => { - setTimeout(() => { - this.ngbModalRef = this.modalService.open(ContactDeleteDialogComponent as Component, { size: 'lg', backdrop: 'static' }); - this.ngbModalRef.componentInstance.contact = contact; - this.ngbModalRef.result.then( - result => { - this.router.navigate(['/contact', { outlets: { popup: null } }]); - this.ngbModalRef = null; - }, - reason => { - this.router.navigate(['/contact', { outlets: { popup: null } }]); - this.ngbModalRef = null; - } - ); - }, 0); - }); - } - - ngOnDestroy() { - this.ngbModalRef = null; - } -} diff --git a/src/main/webapp/app/entities/contact/contact-detail.component.html b/src/main/webapp/app/entities/contact/contact-detail.component.html deleted file mode 100644 index 37941961..00000000 --- a/src/main/webapp/app/entities/contact/contact-detail.component.html +++ /dev/null @@ -1,35 +0,0 @@ -
    -
    -
    -

    Contact {{contact.id}}

    -
    - -
    -
    First Name
    -
    - {{contact.firstName}} -
    -
    Last Name
    -
    - {{contact.lastName}} -
    -
    Email
    -
    - {{contact.email}} -
    -
    - - - - -
    -
    -
    diff --git a/src/main/webapp/app/entities/contact/contact-detail.component.ts b/src/main/webapp/app/entities/contact/contact-detail.component.ts deleted file mode 100644 index fc19a9d7..00000000 --- a/src/main/webapp/app/entities/contact/contact-detail.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; - -import { IContact } from 'app/shared/model/contact.model'; - -@Component({ - selector: 'jhi-contact-detail', - templateUrl: './contact-detail.component.html' -}) -export class ContactDetailComponent implements OnInit { - contact: IContact; - - constructor(protected activatedRoute: ActivatedRoute) {} - - ngOnInit() { - this.activatedRoute.data.subscribe(({ contact }) => { - this.contact = contact; - }); - } - - previousState() { - window.history.back(); - } -} diff --git a/src/main/webapp/app/entities/contact/contact-update.component.html b/src/main/webapp/app/entities/contact/contact-update.component.html deleted file mode 100644 index c2410a68..00000000 --- a/src/main/webapp/app/entities/contact/contact-update.component.html +++ /dev/null @@ -1,69 +0,0 @@ -
    -
    -
    -

    Create or edit a Contact

    -
    - -
    - - -
    -
    - - -
    - - 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 is required. - - - This field cannot be longer than 80 characters. - -
    -
    - -
    -
    - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/contact/contact-update.component.ts b/src/main/webapp/app/entities/contact/contact-update.component.ts deleted file mode 100644 index 15960791..00000000 --- a/src/main/webapp/app/entities/contact/contact-update.component.ts +++ /dev/null @@ -1,51 +0,0 @@ -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 { IContact } from 'app/shared/model/contact.model'; -import { ContactService } from './contact.service'; - -@Component({ - selector: 'jhi-contact-update', - templateUrl: './contact-update.component.html' -}) -export class ContactUpdateComponent implements OnInit { - contact: IContact; - isSaving: boolean; - - constructor(protected contactService: ContactService, protected activatedRoute: ActivatedRoute) {} - - ngOnInit() { - this.isSaving = false; - this.activatedRoute.data.subscribe(({ contact }) => { - this.contact = contact; - }); - } - - previousState() { - window.history.back(); - } - - save() { - this.isSaving = true; - if (this.contact.id !== undefined) { - this.subscribeToSaveResponse(this.contactService.update(this.contact)); - } else { - this.subscribeToSaveResponse(this.contactService.create(this.contact)); - } - } - - 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/contact/contact.component.html b/src/main/webapp/app/entities/contact/contact.component.html deleted file mode 100644 index 7a99d963..00000000 --- a/src/main/webapp/app/entities/contact/contact.component.html +++ /dev/null @@ -1,58 +0,0 @@ -
    -

    - Contacts - -

    - -
    -
    - - - - - - - - - - - - - - - - - - - -
    ID First Name Last Name Email
    {{contact.id}}{{contact.firstName}}{{contact.lastName}}{{contact.email}} -
    - - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/contact/contact.component.ts b/src/main/webapp/app/entities/contact/contact.component.ts deleted file mode 100644 index 60c0f99d..00000000 --- a/src/main/webapp/app/entities/contact/contact.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -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 { IContact } from 'app/shared/model/contact.model'; -import { AccountService } from 'app/core'; - -import { ITEMS_PER_PAGE } from 'app/shared'; -import { ContactService } from './contact.service'; - -@Component({ - selector: 'jhi-contact', - templateUrl: './contact.component.html' -}) -export class ContactComponent implements OnInit, OnDestroy { - contacts: IContact[]; - currentAccount: any; - eventSubscriber: Subscription; - itemsPerPage: number; - links: any; - page: any; - predicate: any; - reverse: any; - totalItems: number; - - constructor( - protected contactService: ContactService, - protected jhiAlertService: JhiAlertService, - protected eventManager: JhiEventManager, - protected parseLinks: JhiParseLinks, - protected accountService: AccountService - ) { - this.contacts = []; - this.itemsPerPage = ITEMS_PER_PAGE; - this.page = 0; - this.links = { - last: 0 - }; - this.predicate = 'id'; - this.reverse = true; - } - - loadAll() { - this.contactService - .query({ - page: this.page, - size: this.itemsPerPage, - sort: this.sort() - }) - .subscribe( - (res: HttpResponse) => this.paginateContacts(res.body, res.headers), - (res: HttpErrorResponse) => this.onError(res.message) - ); - } - - reset() { - this.page = 0; - this.contacts = []; - this.loadAll(); - } - - loadPage(page) { - this.page = page; - this.loadAll(); - } - - ngOnInit() { - this.loadAll(); - this.accountService.identity().then(account => { - this.currentAccount = account; - }); - this.registerChangeInContacts(); - } - - ngOnDestroy() { - this.eventManager.destroy(this.eventSubscriber); - } - - trackId(index: number, item: IContact) { - return item.id; - } - - registerChangeInContacts() { - this.eventSubscriber = this.eventManager.subscribe('contactListModification', response => this.reset()); - } - - sort() { - const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; - if (this.predicate !== 'id') { - result.push('id'); - } - return result; - } - - protected paginateContacts(data: IContact[], 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.contacts.push(data[i]); - } - } - - protected onError(errorMessage: string) { - this.jhiAlertService.error(errorMessage, null, null); - } -} diff --git a/src/main/webapp/app/entities/contact/contact.module.ts b/src/main/webapp/app/entities/contact/contact.module.ts deleted file mode 100644 index 21e6975d..00000000 --- a/src/main/webapp/app/entities/contact/contact.module.ts +++ /dev/null @@ -1,40 +0,0 @@ -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 { - ContactComponent, - ContactDetailComponent, - ContactUpdateComponent, - ContactDeletePopupComponent, - ContactDeleteDialogComponent, - contactRoute, - contactPopupRoute -} from './'; - -const ENTITY_STATES = [...contactRoute, ...contactPopupRoute]; - -@NgModule({ - imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], - declarations: [ - ContactComponent, - ContactDetailComponent, - ContactUpdateComponent, - ContactDeleteDialogComponent, - ContactDeletePopupComponent - ], - entryComponents: [ContactComponent, ContactUpdateComponent, ContactDeleteDialogComponent, ContactDeletePopupComponent], - providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], - schemas: [CUSTOM_ELEMENTS_SCHEMA] -}) -export class HsadminNgContactModule { - 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/contact/contact.route.ts b/src/main/webapp/app/entities/contact/contact.route.ts deleted file mode 100644 index b3e7490e..00000000 --- a/src/main/webapp/app/entities/contact/contact.route.ts +++ /dev/null @@ -1,93 +0,0 @@ -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 { Contact } from 'app/shared/model/contact.model'; -import { ContactService } from './contact.service'; -import { ContactComponent } from './contact.component'; -import { ContactDetailComponent } from './contact-detail.component'; -import { ContactUpdateComponent } from './contact-update.component'; -import { ContactDeletePopupComponent } from './contact-delete-dialog.component'; -import { IContact } from 'app/shared/model/contact.model'; - -@Injectable({ providedIn: 'root' }) -export class ContactResolve implements Resolve { - constructor(private service: ContactService) {} - - 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((contact: HttpResponse) => contact.body) - ); - } - return of(new Contact()); - } -} - -export const contactRoute: Routes = [ - { - path: '', - component: ContactComponent, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: ':id/view', - component: ContactDetailComponent, - resolve: { - contact: ContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: 'new', - component: ContactUpdateComponent, - resolve: { - contact: ContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: ':id/edit', - component: ContactUpdateComponent, - resolve: { - contact: ContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService] - } -]; - -export const contactPopupRoute: Routes = [ - { - path: ':id/delete', - component: ContactDeletePopupComponent, - resolve: { - contact: ContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.contact.home.title' - }, - canActivate: [UserRouteAccessService], - outlet: 'popup' - } -]; diff --git a/src/main/webapp/app/entities/contact/contact.service.ts b/src/main/webapp/app/entities/contact/contact.service.ts deleted file mode 100644 index 6c516cd4..00000000 --- a/src/main/webapp/app/entities/contact/contact.service.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpResponse } from '@angular/common/http'; -import { Observable } from 'rxjs'; - -import { SERVER_API_URL } from 'app/app.constants'; -import { createRequestOption } from 'app/shared'; -import { IContact } from 'app/shared/model/contact.model'; - -type EntityResponseType = HttpResponse; -type EntityArrayResponseType = HttpResponse; - -@Injectable({ providedIn: 'root' }) -export class ContactService { - public resourceUrl = SERVER_API_URL + 'api/contacts'; - - constructor(protected http: HttpClient) {} - - create(contact: IContact): Observable { - return this.http.post(this.resourceUrl, contact, { observe: 'response' }); - } - - update(contact: IContact): Observable { - return this.http.put(this.resourceUrl, contact, { observe: 'response' }); - } - - find(id: number): Observable { - return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } - - query(req?: any): Observable { - const options = createRequestOption(req); - return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); - } - - delete(id: number): Observable> { - return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } -} diff --git a/src/main/webapp/app/entities/contact/index.ts b/src/main/webapp/app/entities/contact/index.ts deleted file mode 100644 index 08474313..00000000 --- a/src/main/webapp/app/entities/contact/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './contact.service'; -export * from './contact-update.component'; -export * from './contact-delete-dialog.component'; -export * from './contact-detail.component'; -export * from './contact.component'; -export * from './contact.route'; diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.html b/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.html deleted file mode 100644 index d4532275..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
    - - - -
    diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.ts b/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.ts deleted file mode 100644 index 1b5157df..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-delete-dialog.component.ts +++ /dev/null @@ -1,72 +0,0 @@ -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 { ICustomerContact } from 'app/shared/model/customer-contact.model'; -import { CustomerContactService } from './customer-contact.service'; - -@Component({ - selector: 'jhi-customer-contact-delete-dialog', - templateUrl: './customer-contact-delete-dialog.component.html' -}) -export class CustomerContactDeleteDialogComponent { - customerContact: ICustomerContact; - - constructor( - protected customerContactService: CustomerContactService, - public activeModal: NgbActiveModal, - protected eventManager: JhiEventManager - ) {} - - clear() { - this.activeModal.dismiss('cancel'); - } - - confirmDelete(id: number) { - this.customerContactService.delete(id).subscribe(response => { - this.eventManager.broadcast({ - name: 'customerContactListModification', - content: 'Deleted an customerContact' - }); - this.activeModal.dismiss(true); - }); - } -} - -@Component({ - selector: 'jhi-customer-contact-delete-popup', - template: '' -}) -export class CustomerContactDeletePopupComponent implements OnInit, OnDestroy { - protected ngbModalRef: NgbModalRef; - - constructor(protected activatedRoute: ActivatedRoute, protected router: Router, protected modalService: NgbModal) {} - - ngOnInit() { - this.activatedRoute.data.subscribe(({ customerContact }) => { - setTimeout(() => { - this.ngbModalRef = this.modalService.open(CustomerContactDeleteDialogComponent as Component, { - size: 'lg', - backdrop: 'static' - }); - this.ngbModalRef.componentInstance.customerContact = customerContact; - this.ngbModalRef.result.then( - result => { - this.router.navigate(['/customer-contact', { outlets: { popup: null } }]); - this.ngbModalRef = null; - }, - reason => { - this.router.navigate(['/customer-contact', { outlets: { popup: null } }]); - this.ngbModalRef = null; - } - ); - }, 0); - }); - } - - ngOnDestroy() { - this.ngbModalRef = null; - } -} diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.html b/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.html deleted file mode 100644 index 8deb192f..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.html +++ /dev/null @@ -1,39 +0,0 @@ -
    -
    -
    -

    Customer Contact {{customerContact.id}}

    -
    - -
    -
    Role
    -
    - {{customerContact.role}} -
    -
    Contact
    -
    - -
    -
    Customer
    -
    - -
    -
    - - - - -
    -
    -
    diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.ts b/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.ts deleted file mode 100644 index 655af363..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-detail.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; - -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; - -@Component({ - selector: 'jhi-customer-contact-detail', - templateUrl: './customer-contact-detail.component.html' -}) -export class CustomerContactDetailComponent implements OnInit { - customerContact: ICustomerContact; - - constructor(protected activatedRoute: ActivatedRoute) {} - - ngOnInit() { - this.activatedRoute.data.subscribe(({ customerContact }) => { - this.customerContact = customerContact; - }); - } - - previousState() { - window.history.back(); - } -} diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.html b/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.html deleted file mode 100644 index f481c079..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.html +++ /dev/null @@ -1,64 +0,0 @@ -
    -
    -
    -

    Create or edit a Customer Contact

    -
    - -
    - - -
    -
    - - -
    - - This field is required. - -
    -
    - -
    - - -
    -
    - - This field is required. - -
    -
    - - -
    -
    - - This field is required. - -
    -
    -
    - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.ts b/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.ts deleted file mode 100644 index 05302d6b..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact-update.component.ts +++ /dev/null @@ -1,92 +0,0 @@ -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 { JhiAlertService } from 'ng-jhipster'; -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; -import { CustomerContactService } from './customer-contact.service'; -import { IContact } from 'app/shared/model/contact.model'; -import { ContactService } from 'app/entities/contact'; -import { ICustomer } from 'app/shared/model/customer.model'; -import { CustomerService } from 'app/entities/customer'; - -@Component({ - selector: 'jhi-customer-contact-update', - templateUrl: './customer-contact-update.component.html' -}) -export class CustomerContactUpdateComponent implements OnInit { - customerContact: ICustomerContact; - isSaving: boolean; - - contacts: IContact[]; - - customers: ICustomer[]; - - constructor( - protected jhiAlertService: JhiAlertService, - protected customerContactService: CustomerContactService, - protected contactService: ContactService, - protected customerService: CustomerService, - protected activatedRoute: ActivatedRoute - ) {} - - ngOnInit() { - this.isSaving = false; - this.activatedRoute.data.subscribe(({ customerContact }) => { - this.customerContact = customerContact; - }); - this.contactService - .query() - .pipe( - filter((mayBeOk: HttpResponse) => mayBeOk.ok), - map((response: HttpResponse) => response.body) - ) - .subscribe((res: IContact[]) => (this.contacts = res), (res: HttpErrorResponse) => this.onError(res.message)); - 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.customerContact.id !== undefined) { - this.subscribeToSaveResponse(this.customerContactService.update(this.customerContact)); - } else { - this.subscribeToSaveResponse(this.customerContactService.create(this.customerContact)); - } - } - - 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); - } - - trackContactById(index: number, item: IContact) { - return item.id; - } - - trackCustomerById(index: number, item: ICustomer) { - return item.id; - } -} diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact.component.html b/src/main/webapp/app/entities/customer-contact/customer-contact.component.html deleted file mode 100644 index ac4d18d6..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.component.html +++ /dev/null @@ -1,66 +0,0 @@ -
    -

    - Customer Contacts - -

    - -
    -
    - - - - - - - - - - - - - - - - - - - -
    ID Role Contact Customer
    {{customerContact.id}}{{customerContact.role}} - - - - -
    - - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact.component.ts b/src/main/webapp/app/entities/customer-contact/customer-contact.component.ts deleted file mode 100644 index fd174030..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -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 { ICustomerContact } from 'app/shared/model/customer-contact.model'; -import { AccountService } from 'app/core'; - -import { ITEMS_PER_PAGE } from 'app/shared'; -import { CustomerContactService } from './customer-contact.service'; - -@Component({ - selector: 'jhi-customer-contact', - templateUrl: './customer-contact.component.html' -}) -export class CustomerContactComponent implements OnInit, OnDestroy { - customerContacts: ICustomerContact[]; - currentAccount: any; - eventSubscriber: Subscription; - itemsPerPage: number; - links: any; - page: any; - predicate: any; - reverse: any; - totalItems: number; - - constructor( - protected customerContactService: CustomerContactService, - protected jhiAlertService: JhiAlertService, - protected eventManager: JhiEventManager, - protected parseLinks: JhiParseLinks, - protected accountService: AccountService - ) { - this.customerContacts = []; - this.itemsPerPage = ITEMS_PER_PAGE; - this.page = 0; - this.links = { - last: 0 - }; - this.predicate = 'id'; - this.reverse = true; - } - - loadAll() { - this.customerContactService - .query({ - page: this.page, - size: this.itemsPerPage, - sort: this.sort() - }) - .subscribe( - (res: HttpResponse) => this.paginateCustomerContacts(res.body, res.headers), - (res: HttpErrorResponse) => this.onError(res.message) - ); - } - - reset() { - this.page = 0; - this.customerContacts = []; - this.loadAll(); - } - - loadPage(page) { - this.page = page; - this.loadAll(); - } - - ngOnInit() { - this.loadAll(); - this.accountService.identity().then(account => { - this.currentAccount = account; - }); - this.registerChangeInCustomerContacts(); - } - - ngOnDestroy() { - this.eventManager.destroy(this.eventSubscriber); - } - - trackId(index: number, item: ICustomerContact) { - return item.id; - } - - registerChangeInCustomerContacts() { - this.eventSubscriber = this.eventManager.subscribe('customerContactListModification', response => this.reset()); - } - - sort() { - const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; - if (this.predicate !== 'id') { - result.push('id'); - } - return result; - } - - protected paginateCustomerContacts(data: ICustomerContact[], 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.customerContacts.push(data[i]); - } - } - - protected onError(errorMessage: string) { - this.jhiAlertService.error(errorMessage, null, null); - } -} diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact.module.ts b/src/main/webapp/app/entities/customer-contact/customer-contact.module.ts deleted file mode 100644 index 4be5e7cf..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.module.ts +++ /dev/null @@ -1,45 +0,0 @@ -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 { - CustomerContactComponent, - CustomerContactDetailComponent, - CustomerContactUpdateComponent, - CustomerContactDeletePopupComponent, - CustomerContactDeleteDialogComponent, - customerContactRoute, - customerContactPopupRoute -} from './'; - -const ENTITY_STATES = [...customerContactRoute, ...customerContactPopupRoute]; - -@NgModule({ - imports: [HsadminNgSharedModule, RouterModule.forChild(ENTITY_STATES)], - declarations: [ - CustomerContactComponent, - CustomerContactDetailComponent, - CustomerContactUpdateComponent, - CustomerContactDeleteDialogComponent, - CustomerContactDeletePopupComponent - ], - entryComponents: [ - CustomerContactComponent, - CustomerContactUpdateComponent, - CustomerContactDeleteDialogComponent, - CustomerContactDeletePopupComponent - ], - providers: [{ provide: JhiLanguageService, useClass: JhiLanguageService }], - schemas: [CUSTOM_ELEMENTS_SCHEMA] -}) -export class HsadminNgCustomerContactModule { - 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-contact/customer-contact.route.ts b/src/main/webapp/app/entities/customer-contact/customer-contact.route.ts deleted file mode 100644 index 827e2b63..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.route.ts +++ /dev/null @@ -1,93 +0,0 @@ -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 { CustomerContact } from 'app/shared/model/customer-contact.model'; -import { CustomerContactService } from './customer-contact.service'; -import { CustomerContactComponent } from './customer-contact.component'; -import { CustomerContactDetailComponent } from './customer-contact-detail.component'; -import { CustomerContactUpdateComponent } from './customer-contact-update.component'; -import { CustomerContactDeletePopupComponent } from './customer-contact-delete-dialog.component'; -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; - -@Injectable({ providedIn: 'root' }) -export class CustomerContactResolve implements Resolve { - constructor(private service: CustomerContactService) {} - - 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((customerContact: HttpResponse) => customerContact.body) - ); - } - return of(new CustomerContact()); - } -} - -export const customerContactRoute: Routes = [ - { - path: '', - component: CustomerContactComponent, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: ':id/view', - component: CustomerContactDetailComponent, - resolve: { - customerContact: CustomerContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: 'new', - component: CustomerContactUpdateComponent, - resolve: { - customerContact: CustomerContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService] - }, - { - path: ':id/edit', - component: CustomerContactUpdateComponent, - resolve: { - customerContact: CustomerContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService] - } -]; - -export const customerContactPopupRoute: Routes = [ - { - path: ':id/delete', - component: CustomerContactDeletePopupComponent, - resolve: { - customerContact: CustomerContactResolve - }, - data: { - authorities: ['ROLE_USER'], - pageTitle: 'hsadminNgApp.customerContact.home.title' - }, - canActivate: [UserRouteAccessService], - outlet: 'popup' - } -]; diff --git a/src/main/webapp/app/entities/customer-contact/customer-contact.service.ts b/src/main/webapp/app/entities/customer-contact/customer-contact.service.ts deleted file mode 100644 index 49464888..00000000 --- a/src/main/webapp/app/entities/customer-contact/customer-contact.service.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpResponse } from '@angular/common/http'; -import { Observable } from 'rxjs'; - -import { SERVER_API_URL } from 'app/app.constants'; -import { createRequestOption } from 'app/shared'; -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; - -type EntityResponseType = HttpResponse; -type EntityArrayResponseType = HttpResponse; - -@Injectable({ providedIn: 'root' }) -export class CustomerContactService { - public resourceUrl = SERVER_API_URL + 'api/customer-contacts'; - - constructor(protected http: HttpClient) {} - - create(customerContact: ICustomerContact): Observable { - return this.http.post(this.resourceUrl, customerContact, { observe: 'response' }); - } - - update(customerContact: ICustomerContact): Observable { - return this.http.put(this.resourceUrl, customerContact, { observe: 'response' }); - } - - find(id: number): Observable { - return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } - - query(req?: any): Observable { - const options = createRequestOption(req); - return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); - } - - delete(id: number): Observable> { - return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } -} diff --git a/src/main/webapp/app/entities/customer-contact/index.ts b/src/main/webapp/app/entities/customer-contact/index.ts deleted file mode 100644 index 9e0cbba0..00000000 --- a/src/main/webapp/app/entities/customer-contact/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './customer-contact.service'; -export * from './customer-contact-update.component'; -export * from './customer-contact-delete-dialog.component'; -export * from './customer-contact-detail.component'; -export * from './customer-contact.component'; -export * from './customer-contact.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 deleted file mode 100644 index b04a8e62..00000000 --- a/src/main/webapp/app/entities/customer/customer-delete-dialog.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
    - - - -
    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 deleted file mode 100644 index 3c96919d..00000000 --- a/src/main/webapp/app/entities/customer/customer-delete-dialog.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -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 deleted file mode 100644 index fbf98ec0..00000000 --- a/src/main/webapp/app/entities/customer/customer-detail.component.html +++ /dev/null @@ -1,51 +0,0 @@ -
    -
    -
    -

    Customer {{customer.id}}

    -
    - -
    -
    Number
    -
    - {{customer.number}} -
    -
    Prefix
    -
    - {{customer.prefix}} -
    -
    Name
    -
    - {{customer.name}} -
    -
    Contractual Address
    -
    - {{customer.contractualAddress}} -
    -
    Contractual Salutation
    -
    - {{customer.contractualSalutation}} -
    -
    Billing Address
    -
    - {{customer.billingAddress}} -
    -
    Billing Salutation
    -
    - {{customer.billingSalutation}} -
    -
    - - - - -
    -
    -
    diff --git a/src/main/webapp/app/entities/customer/customer-detail.component.ts b/src/main/webapp/app/entities/customer/customer-detail.component.ts deleted file mode 100644 index da1b94e3..00000000 --- a/src/main/webapp/app/entities/customer/customer-detail.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index 43f9d079..00000000 --- a/src/main/webapp/app/entities/customer/customer-update.component.html +++ /dev/null @@ -1,142 +0,0 @@ -
    -
    -
    -

    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 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 400 characters. - -
    -
    -
    - - -
    - - This field cannot be longer than 80 characters. - -
    -
    -
    - - -
    - - This field cannot be longer than 400 characters. - -
    -
    -
    - - -
    - - This field cannot be longer than 80 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 deleted file mode 100644 index 2afd9d0a..00000000 --- a/src/main/webapp/app/entities/customer/customer-update.component.ts +++ /dev/null @@ -1,51 +0,0 @@ -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 { 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; - - 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 deleted file mode 100644 index def61b53..00000000 --- a/src/main/webapp/app/entities/customer/customer.component.html +++ /dev/null @@ -1,77 +0,0 @@ -
    -

    - Customers - -

    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ID Number Prefix Name - - Contractual Address - - Contractual Salutation - - Billing Address - - Billing Salutation - -
    {{customer.id}}{{customer.number}}{{customer.prefix}}{{customer.name}}{{customer.contractualAddress}}{{customer.contractualSalutation}}{{customer.billingAddress}}{{customer.billingSalutation}} -
    - - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/customer/customer.component.ts b/src/main/webapp/app/entities/customer/customer.component.ts deleted file mode 100644 index a1d3ce51..00000000 --- a/src/main/webapp/app/entities/customer/customer.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -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 deleted file mode 100644 index 8d50348c..00000000 --- a/src/main/webapp/app/entities/customer/customer.module.ts +++ /dev/null @@ -1,40 +0,0 @@ -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 deleted file mode 100644 index 269760db..00000000 --- a/src/main/webapp/app/entities/customer/customer.route.ts +++ /dev/null @@ -1,93 +0,0 @@ -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 deleted file mode 100644 index 20710286..00000000 --- a/src/main/webapp/app/entities/customer/customer.service.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpResponse } from '@angular/common/http'; -import { Observable } from 'rxjs'; - -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 { - return this.http.post(this.resourceUrl, customer, { observe: 'response' }); - } - - update(customer: ICustomer): Observable { - return this.http.put(this.resourceUrl, customer, { observe: 'response' }); - } - - find(id: number): Observable { - return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } - - query(req?: any): Observable { - const options = createRequestOption(req); - return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); - } - - delete(id: number): Observable> { - return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); - } -} diff --git a/src/main/webapp/app/entities/customer/index.ts b/src/main/webapp/app/entities/customer/index.ts deleted file mode 100644 index 27ae3ca8..00000000 --- a/src/main/webapp/app/entities/customer/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -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 5739d14f..fed9de39 100644 --- a/src/main/webapp/app/entities/entity.module.ts +++ b/src/main/webapp/app/entities/entity.module.ts @@ -1,49 +1,9 @@ -import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; +import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { RouterModule } from '@angular/router'; @NgModule({ imports: [ RouterModule.forChild([ - { - path: 'customer', - loadChildren: './customer/customer.module#HsadminNgCustomerModule' - }, - { - path: 'contact', - loadChildren: './contact/contact.module#HsadminNgContactModule' - }, - { - path: 'customer-contact', - loadChildren: './customer-contact/customer-contact.module#HsadminNgCustomerContactModule' - }, - { - path: 'membership', - loadChildren: './membership/membership.module#HsadminNgMembershipModule' - }, - { - path: 'share', - loadChildren: './share/share.module#HsadminNgShareModule' - }, - { - path: 'asset', - loadChildren: './asset/asset.module#HsadminNgAssetModule' - }, - { - 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' - } /* 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 deleted file mode 100644 index 13a7f938..00000000 --- a/src/main/webapp/app/entities/membership/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 8749c4ee..00000000 --- a/src/main/webapp/app/entities/membership/membership-delete-dialog.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
    - - - -
    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 deleted file mode 100644 index ac1787db..00000000 --- a/src/main/webapp/app/entities/membership/membership-delete-dialog.component.ts +++ /dev/null @@ -1,69 +0,0 @@ -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 deleted file mode 100644 index 108ef2b7..00000000 --- a/src/main/webapp/app/entities/membership/membership-detail.component.html +++ /dev/null @@ -1,37 +0,0 @@ -
    -
    -
    -

    Membership {{membership.id}}

    -
    - -
    -
    Since Date
    -
    - {{membership.sinceDate}} -
    -
    Until Date
    -
    - {{membership.untilDate}} -
    -
    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 deleted file mode 100644 index ed1105eb..00000000 --- a/src/main/webapp/app/entities/membership/membership-detail.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index 6b30a4c2..00000000 --- a/src/main/webapp/app/entities/membership/membership-update.component.html +++ /dev/null @@ -1,65 +0,0 @@ -
    -
    -
    -

    Create or edit a Membership

    -
    - -
    - - -
    -
    - -
    - - - - -
    -
    - - This field is required. - -
    -
    -
    - -
    - - - - -
    -
    - -
    - - -
    -
    - - This field is required. - -
    -
    -
    - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/membership/membership-update.component.ts b/src/main/webapp/app/entities/membership/membership-update.component.ts deleted file mode 100644 index 92d41047..00000000 --- a/src/main/webapp/app/entities/membership/membership-update.component.ts +++ /dev/null @@ -1,79 +0,0 @@ -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[]; - sinceDateDp: any; - untilDateDp: 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 deleted file mode 100644 index 075546a4..00000000 --- a/src/main/webapp/app/entities/membership/membership.component.html +++ /dev/null @@ -1,62 +0,0 @@ -
    -

    - Memberships - -

    - -
    -
    - - - - - - - - - - - - - - - - - - - -
    ID Since Date Until Date Customer
    {{membership.id}}{{membership.sinceDate | date:'mediumDate'}}{{membership.untilDate | date:'mediumDate'}} - - -
    - - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/membership/membership.component.ts b/src/main/webapp/app/entities/membership/membership.component.ts deleted file mode 100644 index 387df20d..00000000 --- a/src/main/webapp/app/entities/membership/membership.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -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 deleted file mode 100644 index 01e0545f..00000000 --- a/src/main/webapp/app/entities/membership/membership.module.ts +++ /dev/null @@ -1,40 +0,0 @@ -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 deleted file mode 100644 index fbf9f430..00000000 --- a/src/main/webapp/app/entities/membership/membership.route.ts +++ /dev/null @@ -1,93 +0,0 @@ -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 deleted file mode 100644 index 95388263..00000000 --- a/src/main/webapp/app/entities/membership/membership.service.ts +++ /dev/null @@ -1,77 +0,0 @@ -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, { - sinceDate: membership.sinceDate != null && membership.sinceDate.isValid() ? membership.sinceDate.format(DATE_FORMAT) : null, - untilDate: membership.untilDate != null && membership.untilDate.isValid() ? membership.untilDate.format(DATE_FORMAT) : null - }); - return copy; - } - - protected convertDateFromServer(res: EntityResponseType): EntityResponseType { - if (res.body) { - res.body.sinceDate = res.body.sinceDate != null ? moment(res.body.sinceDate) : null; - res.body.untilDate = res.body.untilDate != null ? moment(res.body.untilDate) : null; - } - return res; - } - - protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { - if (res.body) { - res.body.forEach((membership: IMembership) => { - membership.sinceDate = membership.sinceDate != null ? moment(membership.sinceDate) : null; - membership.untilDate = membership.untilDate != null ? moment(membership.untilDate) : null; - }); - } - return res; - } -} diff --git a/src/main/webapp/app/entities/share/index.ts b/src/main/webapp/app/entities/share/index.ts deleted file mode 100644 index ecc5eeaa..00000000 --- a/src/main/webapp/app/entities/share/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 5437602b..00000000 --- a/src/main/webapp/app/entities/share/share-delete-dialog.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
    - - - -
    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 deleted file mode 100644 index 34138baa..00000000 --- a/src/main/webapp/app/entities/share/share-delete-dialog.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -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 deleted file mode 100644 index 24ba66c1..00000000 --- a/src/main/webapp/app/entities/share/share-detail.component.html +++ /dev/null @@ -1,45 +0,0 @@ -
    -
    -
    -

    Share {{share.id}}

    -
    - -
    -
    Date
    -
    - {{share.date}} -
    -
    Action
    -
    - {{share.action}} -
    -
    Quantity
    -
    - {{share.quantity}} -
    -
    Comment
    -
    - {{share.comment}} -
    -
    Member
    -
    - -
    -
    - - - - -
    -
    -
    diff --git a/src/main/webapp/app/entities/share/share-detail.component.ts b/src/main/webapp/app/entities/share/share-detail.component.ts deleted file mode 100644 index 5cd2ed0f..00000000 --- a/src/main/webapp/app/entities/share/share-detail.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index 3f092ec3..00000000 --- a/src/main/webapp/app/entities/share/share-update.component.html +++ /dev/null @@ -1,93 +0,0 @@ -
    -
    -
    -

    Create or edit a Share

    -
    - -
    - - -
    -
    - -
    - - - - -
    -
    - - 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 deleted file mode 100644 index 677a033c..00000000 --- a/src/main/webapp/app/entities/share/share-update.component.ts +++ /dev/null @@ -1,78 +0,0 @@ -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[]; - dateDp: 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 deleted file mode 100644 index 82cead44..00000000 --- a/src/main/webapp/app/entities/share/share.component.html +++ /dev/null @@ -1,66 +0,0 @@ -
    -

    - Shares - -

    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    ID Date Action Quantity Comment Member
    {{share.id}}{{share.date | date:'mediumDate'}}{{share.action}}{{share.quantity}}{{share.comment}} - - -
    - - - -
    -
    -
    -
    diff --git a/src/main/webapp/app/entities/share/share.component.ts b/src/main/webapp/app/entities/share/share.component.ts deleted file mode 100644 index d636295f..00000000 --- a/src/main/webapp/app/entities/share/share.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -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 deleted file mode 100644 index 9fb07b3a..00000000 --- a/src/main/webapp/app/entities/share/share.module.ts +++ /dev/null @@ -1,34 +0,0 @@ -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 deleted file mode 100644 index 36f35a5b..00000000 --- a/src/main/webapp/app/entities/share/share.route.ts +++ /dev/null @@ -1,93 +0,0 @@ -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 deleted file mode 100644 index 4b9389b3..00000000 --- a/src/main/webapp/app/entities/share/share.service.ts +++ /dev/null @@ -1,74 +0,0 @@ -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, { - date: share.date != null && share.date.isValid() ? share.date.format(DATE_FORMAT) : null - }); - return copy; - } - - protected convertDateFromServer(res: EntityResponseType): EntityResponseType { - if (res.body) { - res.body.date = res.body.date != null ? moment(res.body.date) : null; - } - return res; - } - - protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { - if (res.body) { - res.body.forEach((share: IShare) => { - share.date = share.date != null ? moment(share.date) : 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 201ff3aa..c6c63c64 100644 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -27,42 +27,6 @@ diff --git a/src/main/webapp/app/shared/model/asset.model.ts b/src/main/webapp/app/shared/model/asset.model.ts deleted file mode 100644 index aa577d11..00000000 --- a/src/main/webapp/app/shared/model/asset.model.ts +++ /dev/null @@ -1,30 +0,0 @@ -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; - date?: Moment; - action?: AssetAction; - amount?: number; - comment?: string; - memberId?: number; -} - -export class Asset implements IAsset { - constructor( - public id?: number, - public date?: Moment, - public action?: AssetAction, - public amount?: number, - public comment?: string, - public memberId?: number - ) {} -} diff --git a/src/main/webapp/app/shared/model/contact.model.ts b/src/main/webapp/app/shared/model/contact.model.ts deleted file mode 100644 index 8c02a4a2..00000000 --- a/src/main/webapp/app/shared/model/contact.model.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; - -export interface IContact { - id?: number; - firstName?: string; - lastName?: string; - email?: string; - roles?: ICustomerContact[]; -} - -export class Contact implements IContact { - constructor( - public id?: number, - public firstName?: string, - public lastName?: string, - public email?: string, - public roles?: ICustomerContact[] - ) {} -} diff --git a/src/main/webapp/app/shared/model/customer-contact.model.ts b/src/main/webapp/app/shared/model/customer-contact.model.ts deleted file mode 100644 index c1d3f274..00000000 --- a/src/main/webapp/app/shared/model/customer-contact.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -export const enum CustomerContactRole { - CONTRACTUAL = 'CONTRACTUAL', - TECHNICAL = 'TECHNICAL', - FINANCIAL = 'FINANCIAL' -} - -export interface ICustomerContact { - id?: number; - role?: CustomerContactRole; - contactEmail?: string; - contactId?: number; - customerPrefix?: string; - customerId?: number; -} - -export class CustomerContact implements ICustomerContact { - constructor( - public id?: number, - public role?: CustomerContactRole, - public contactEmail?: string, - public contactId?: number, - public customerPrefix?: string, - public customerId?: number - ) {} -} diff --git a/src/main/webapp/app/shared/model/customer.model.ts b/src/main/webapp/app/shared/model/customer.model.ts deleted file mode 100644 index d876bd10..00000000 --- a/src/main/webapp/app/shared/model/customer.model.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ICustomerContact } from 'app/shared/model/customer-contact.model'; -import { IMembership } from 'app/shared/model/membership.model'; - -export interface ICustomer { - id?: number; - number?: number; - prefix?: string; - name?: string; - contractualAddress?: string; - contractualSalutation?: string; - billingAddress?: string; - billingSalutation?: string; - roles?: ICustomerContact[]; - memberships?: IMembership[]; -} - -export class Customer implements ICustomer { - constructor( - public id?: number, - public number?: number, - public prefix?: string, - public name?: string, - public contractualAddress?: string, - public contractualSalutation?: string, - public billingAddress?: string, - public billingSalutation?: string, - public roles?: ICustomerContact[], - public memberships?: IMembership[] - ) {} -} diff --git a/src/main/webapp/app/shared/model/membership.model.ts b/src/main/webapp/app/shared/model/membership.model.ts deleted file mode 100644 index f1ad5337..00000000 --- a/src/main/webapp/app/shared/model/membership.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -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; - sinceDate?: Moment; - untilDate?: Moment; - shares?: IShare[]; - assets?: IAsset[]; - customerPrefix?: string; - customerId?: number; -} - -export class Membership implements IMembership { - constructor( - public id?: number, - public sinceDate?: Moment, - public untilDate?: Moment, - public shares?: IShare[], - public assets?: IAsset[], - 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 deleted file mode 100644 index c3eb8cce..00000000 --- a/src/main/webapp/app/shared/model/share.model.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Moment } from 'moment'; - -export const enum ShareAction { - SUBSCRIPTION = 'SUBSCRIPTION', - CANCELLATION = 'CANCELLATION' -} - -export interface IShare { - id?: number; - date?: Moment; - action?: ShareAction; - quantity?: number; - comment?: string; - memberId?: number; -} - -export class Share implements IShare { - constructor( - public id?: number, - public date?: Moment, - public action?: ShareAction, - public quantity?: number, - public comment?: string, - public memberId?: number - ) {} -} diff --git a/src/main/webapp/i18n/de/asset.json b/src/main/webapp/i18n/de/asset.json deleted file mode 100644 index 8f36a53f..00000000 --- a/src/main/webapp/i18n/de/asset.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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" - }, - "date": "Date", - "action": "Action", - "amount": "Amount", - "comment": "Comment", - "member": "Member" - } - } -} diff --git a/src/main/webapp/i18n/de/assetAction.json b/src/main/webapp/i18n/de/assetAction.json deleted file mode 100644 index d3f1ca77..00000000 --- a/src/main/webapp/i18n/de/assetAction.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "hsadminNgApp": { - "AssetAction": { - "null": "", - "PAYMENT": "PAYMENT", - "HANDOVER": "HANDOVER", - "ADOPTION": "ADOPTION", - "LOSS": "LOSS", - "CLEARING": "CLEARING", - "PAYBACK": "PAYBACK" - } - } -} diff --git a/src/main/webapp/i18n/de/contact.json b/src/main/webapp/i18n/de/contact.json deleted file mode 100644 index 521243c6..00000000 --- a/src/main/webapp/i18n/de/contact.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "hsadminNgApp": { - "contact": { - "home": { - "title": "Contacts", - "createLabel": "Contact erstellen", - "createOrEditLabel": "Contact erstellen oder bearbeiten" - }, - "created": "Contact erstellt mit ID {{ param }}", - "updated": "Contact aktualisiert mit ID {{ param }}", - "deleted": "Contact gelöscht mit ID {{ param }}", - "delete": { - "question": "Soll Contact {{ id }} wirklich dauerhaft gelöscht werden?" - }, - "detail": { - "title": "Contact" - }, - "firstName": "First Name", - "lastName": "Last Name", - "email": "Email", - "role": "Role" - } - } -} diff --git a/src/main/webapp/i18n/de/customer.json b/src/main/webapp/i18n/de/customer.json deleted file mode 100644 index 407c3863..00000000 --- a/src/main/webapp/i18n/de/customer.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "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" - }, - "number": "Number", - "prefix": "Prefix", - "name": "Name", - "contractualAddress": "Contractual Address", - "contractualSalutation": "Contractual Salutation", - "billingAddress": "Billing Address", - "billingSalutation": "Billing Salutation", - "role": "Role", - "membership": "Membership" - } - } -} diff --git a/src/main/webapp/i18n/de/customerContact.json b/src/main/webapp/i18n/de/customerContact.json deleted file mode 100644 index 4f5b69d9..00000000 --- a/src/main/webapp/i18n/de/customerContact.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "hsadminNgApp": { - "customerContact": { - "home": { - "title": "Customer Contacts", - "createLabel": "Customer Contact erstellen", - "createOrEditLabel": "Customer Contact erstellen oder bearbeiten" - }, - "created": "Customer Contact erstellt mit ID {{ param }}", - "updated": "Customer Contact aktualisiert mit ID {{ param }}", - "deleted": "Customer Contact gelöscht mit ID {{ param }}", - "delete": { - "question": "Soll Customer Contact {{ id }} wirklich dauerhaft gelöscht werden?" - }, - "detail": { - "title": "Customer Contact" - }, - "role": "Role", - "contact": "Contact", - "customer": "Customer" - } - } -} diff --git a/src/main/webapp/i18n/de/customerContactRole.json b/src/main/webapp/i18n/de/customerContactRole.json deleted file mode 100644 index 7e654646..00000000 --- a/src/main/webapp/i18n/de/customerContactRole.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "hsadminNgApp": { - "CustomerContactRole": { - "null": "", - "CONTRACTUAL": "CONTRACTUAL", - "TECHNICAL": "TECHNICAL", - "FINANCIAL": "FINANCIAL" - } - } -} diff --git a/src/main/webapp/i18n/de/global.json b/src/main/webapp/i18n/de/global.json index f6ef880f..58d44f23 100644 --- a/src/main/webapp/i18n/de/global.json +++ b/src/main/webapp/i18n/de/global.json @@ -7,12 +7,6 @@ "jhipster-needle-menu-add-element": "JHipster will add additional menu entries here (do not translate!)", "entities": { "main": "Entitäten", - "customer": "Customer", - "contact": "Contact", - "customerContact": "Customer Contact", - "membership": "Membership", - "share": "Share", - "asset": "Asset", "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 deleted file mode 100644 index 95fb3f58..00000000 --- a/src/main/webapp/i18n/de/membership.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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" - }, - "sinceDate": "Since Date", - "untilDate": "Until Date", - "share": "Share", - "asset": "Asset", - "customer": "Customer" - } - } -} diff --git a/src/main/webapp/i18n/de/share.json b/src/main/webapp/i18n/de/share.json deleted file mode 100644 index 702f8f83..00000000 --- a/src/main/webapp/i18n/de/share.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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" - }, - "date": "Date", - "action": "Action", - "quantity": "Quantity", - "comment": "Comment", - "member": "Member" - } - } -} diff --git a/src/main/webapp/i18n/de/shareAction.json b/src/main/webapp/i18n/de/shareAction.json deleted file mode 100644 index 2016c4bb..00000000 --- a/src/main/webapp/i18n/de/shareAction.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "hsadminNgApp": { - "ShareAction": { - "null": "", - "SUBSCRIPTION": "SUBSCRIPTION", - "CANCELLATION": "CANCELLATION" - } - } -} diff --git a/src/main/webapp/i18n/en/asset.json b/src/main/webapp/i18n/en/asset.json deleted file mode 100644 index 128f5716..00000000 --- a/src/main/webapp/i18n/en/asset.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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" - }, - "date": "Date", - "action": "Action", - "amount": "Amount", - "comment": "Comment", - "member": "Member" - } - } -} diff --git a/src/main/webapp/i18n/en/assetAction.json b/src/main/webapp/i18n/en/assetAction.json deleted file mode 100644 index d3f1ca77..00000000 --- a/src/main/webapp/i18n/en/assetAction.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "hsadminNgApp": { - "AssetAction": { - "null": "", - "PAYMENT": "PAYMENT", - "HANDOVER": "HANDOVER", - "ADOPTION": "ADOPTION", - "LOSS": "LOSS", - "CLEARING": "CLEARING", - "PAYBACK": "PAYBACK" - } - } -} diff --git a/src/main/webapp/i18n/en/contact.json b/src/main/webapp/i18n/en/contact.json deleted file mode 100644 index 680664c7..00000000 --- a/src/main/webapp/i18n/en/contact.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "hsadminNgApp": { - "contact": { - "home": { - "title": "Contacts", - "createLabel": "Create a new Contact", - "createOrEditLabel": "Create or edit a Contact" - }, - "created": "A new Contact is created with identifier {{ param }}", - "updated": "A Contact is updated with identifier {{ param }}", - "deleted": "A Contact is deleted with identifier {{ param }}", - "delete": { - "question": "Are you sure you want to delete Contact {{ id }}?" - }, - "detail": { - "title": "Contact" - }, - "firstName": "First Name", - "lastName": "Last Name", - "email": "Email", - "role": "Role" - } - } -} diff --git a/src/main/webapp/i18n/en/customer.json b/src/main/webapp/i18n/en/customer.json deleted file mode 100644 index b58c1345..00000000 --- a/src/main/webapp/i18n/en/customer.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "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" - }, - "number": "Number", - "prefix": "Prefix", - "name": "Name", - "contractualAddress": "Contractual Address", - "contractualSalutation": "Contractual Salutation", - "billingAddress": "Billing Address", - "billingSalutation": "Billing Salutation", - "role": "Role", - "membership": "Membership" - } - } -} diff --git a/src/main/webapp/i18n/en/customerContact.json b/src/main/webapp/i18n/en/customerContact.json deleted file mode 100644 index 57173ebd..00000000 --- a/src/main/webapp/i18n/en/customerContact.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "hsadminNgApp": { - "customerContact": { - "home": { - "title": "Customer Contacts", - "createLabel": "Create a new Customer Contact", - "createOrEditLabel": "Create or edit a Customer Contact" - }, - "created": "A new Customer Contact is created with identifier {{ param }}", - "updated": "A Customer Contact is updated with identifier {{ param }}", - "deleted": "A Customer Contact is deleted with identifier {{ param }}", - "delete": { - "question": "Are you sure you want to delete Customer Contact {{ id }}?" - }, - "detail": { - "title": "Customer Contact" - }, - "role": "Role", - "contact": "Contact", - "customer": "Customer" - } - } -} diff --git a/src/main/webapp/i18n/en/customerContactRole.json b/src/main/webapp/i18n/en/customerContactRole.json deleted file mode 100644 index 7e654646..00000000 --- a/src/main/webapp/i18n/en/customerContactRole.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "hsadminNgApp": { - "CustomerContactRole": { - "null": "", - "CONTRACTUAL": "CONTRACTUAL", - "TECHNICAL": "TECHNICAL", - "FINANCIAL": "FINANCIAL" - } - } -} diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index 3b496f5b..e0927808 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -7,12 +7,6 @@ "jhipster-needle-menu-add-element": "JHipster will add additional menu entries here (do not translate!)", "entities": { "main": "Entities", - "customer": "Customer", - "contact": "Contact", - "customerContact": "Customer Contact", - "membership": "Membership", - "share": "Share", - "asset": "Asset", "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 deleted file mode 100644 index 08b7f156..00000000 --- a/src/main/webapp/i18n/en/membership.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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" - }, - "sinceDate": "Since Date", - "untilDate": "Until Date", - "share": "Share", - "asset": "Asset", - "customer": "Customer" - } - } -} diff --git a/src/main/webapp/i18n/en/share.json b/src/main/webapp/i18n/en/share.json deleted file mode 100644 index 06637120..00000000 --- a/src/main/webapp/i18n/en/share.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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" - }, - "date": "Date", - "action": "Action", - "quantity": "Quantity", - "comment": "Comment", - "member": "Member" - } - } -} diff --git a/src/main/webapp/i18n/en/shareAction.json b/src/main/webapp/i18n/en/shareAction.json deleted file mode 100644 index 2016c4bb..00000000 --- a/src/main/webapp/i18n/en/shareAction.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "hsadminNgApp": { - "ShareAction": { - "null": "", - "SUBSCRIPTION": "SUBSCRIPTION", - "CANCELLATION": "CANCELLATION" - } - } -} diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java deleted file mode 100644 index 80dc172a..00000000 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java +++ /dev/null @@ -1,616 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; - -import org.hostsharing.hsadminng.HsadminNgApp; -import org.hostsharing.hsadminng.domain.Asset; -import org.hostsharing.hsadminng.domain.Membership; -import org.hostsharing.hsadminng.domain.enumeration.AssetAction; -import org.hostsharing.hsadminng.repository.AssetRepository; -import org.hostsharing.hsadminng.service.AssetQueryService; -import org.hostsharing.hsadminng.service.AssetService; -import org.hostsharing.hsadminng.service.dto.AssetDTO; -import org.hostsharing.hsadminng.service.mapper.AssetMapper; -import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.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.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -/** - * Test class for the AssetResource REST controller. - * - * @see AssetResource - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = HsadminNgApp.class) -public class AssetResourceIntTest { - - private static final LocalDate DEFAULT_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_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_COMMENT = "AAAAAAAAAA"; - private static final String UPDATED_COMMENT = "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() - .date(DEFAULT_DATE) - .action(DEFAULT_ACTION) - .amount(DEFAULT_AMOUNT) - .comment(DEFAULT_COMMENT); - // Add required entity - Membership membership = MembershipResourceIntTest.createEntity(em); - em.persist(membership); - em.flush(); - asset.setMember(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.getDate()).isEqualTo(DEFAULT_DATE); - assertThat(testAsset.getAction()).isEqualTo(DEFAULT_ACTION); - assertThat(testAsset.getAmount()).isEqualTo(DEFAULT_AMOUNT); - assertThat(testAsset.getComment()).isEqualTo(DEFAULT_COMMENT); - } - - @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 checkDateIsRequired() throws Exception { - int databaseSizeBeforeTest = assetRepository.findAll().size(); - // set the field null - asset.setDate(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("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) - .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString()))) - .andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue()))) - .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT.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("$.date").value(DEFAULT_DATE.toString())) - .andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString())) - .andExpect(jsonPath("$.amount").value(DEFAULT_AMOUNT.intValue())) - .andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT.toString())); - } - - @Test - @Transactional - public void getAllAssetsByDateIsEqualToSomething() throws Exception { - // Initialize the database - assetRepository.saveAndFlush(asset); - - // Get all the assetList where date equals to DEFAULT_DATE - defaultAssetShouldBeFound("date.equals=" + DEFAULT_DATE); - - // Get all the assetList where date equals to UPDATED_DATE - defaultAssetShouldNotBeFound("date.equals=" + UPDATED_DATE); - } - - @Test - @Transactional - public void getAllAssetsByDateIsInShouldWork() throws Exception { - // Initialize the database - assetRepository.saveAndFlush(asset); - - // Get all the assetList where date in DEFAULT_DATE or UPDATED_DATE - defaultAssetShouldBeFound("date.in=" + DEFAULT_DATE + "," + UPDATED_DATE); - - // Get all the assetList where date equals to UPDATED_DATE - defaultAssetShouldNotBeFound("date.in=" + UPDATED_DATE); - } - - @Test - @Transactional - public void getAllAssetsByDateIsNullOrNotNull() throws Exception { - // Initialize the database - assetRepository.saveAndFlush(asset); - - // Get all the assetList where date is not null - defaultAssetShouldBeFound("date.specified=true"); - - // Get all the assetList where date is null - defaultAssetShouldNotBeFound("date.specified=false"); - } - - @Test - @Transactional - public void getAllAssetsByDateIsGreaterThanOrEqualToSomething() throws Exception { - // Initialize the database - assetRepository.saveAndFlush(asset); - - // Get all the assetList where date greater than or equals to DEFAULT_DATE - defaultAssetShouldBeFound("date.greaterOrEqualThan=" + DEFAULT_DATE); - - // Get all the assetList where date greater than or equals to UPDATED_DATE - defaultAssetShouldNotBeFound("date.greaterOrEqualThan=" + UPDATED_DATE); - } - - @Test - @Transactional - public void getAllAssetsByDateIsLessThanSomething() throws Exception { - // Initialize the database - assetRepository.saveAndFlush(asset); - - // Get all the assetList where date less than or equals to DEFAULT_DATE - defaultAssetShouldNotBeFound("date.lessThan=" + DEFAULT_DATE); - - // Get all the assetList where date less than or equals to UPDATED_DATE - defaultAssetShouldBeFound("date.lessThan=" + UPDATED_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 getAllAssetsByCommentIsEqualToSomething() throws Exception { - // Initialize the database - assetRepository.saveAndFlush(asset); - - // Get all the assetList where comment equals to DEFAULT_COMMENT - defaultAssetShouldBeFound("comment.equals=" + DEFAULT_COMMENT); - - // Get all the assetList where comment equals to UPDATED_COMMENT - defaultAssetShouldNotBeFound("comment.equals=" + UPDATED_COMMENT); - } - - @Test - @Transactional - public void getAllAssetsByCommentIsInShouldWork() throws Exception { - // Initialize the database - assetRepository.saveAndFlush(asset); - - // Get all the assetList where comment in DEFAULT_COMMENT or UPDATED_COMMENT - defaultAssetShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT); - - // Get all the assetList where comment equals to UPDATED_COMMENT - defaultAssetShouldNotBeFound("comment.in=" + UPDATED_COMMENT); - } - - @Test - @Transactional - public void getAllAssetsByCommentIsNullOrNotNull() throws Exception { - // Initialize the database - assetRepository.saveAndFlush(asset); - - // Get all the assetList where comment is not null - defaultAssetShouldBeFound("comment.specified=true"); - - // Get all the assetList where comment is null - defaultAssetShouldNotBeFound("comment.specified=false"); - } - - @Test - @Transactional - public void getAllAssetsByMemberIsEqualToSomething() throws Exception { - // Initialize the database - Membership member = MembershipResourceIntTest.createEntity(em); - em.persist(member); - em.flush(); - asset.setMember(member); - assetRepository.saveAndFlush(asset); - Long memberId = member.getId(); - - // Get all the assetList where member equals to memberId - defaultAssetShouldBeFound("memberId.equals=" + memberId); - - // Get all the assetList where member equals to memberId + 1 - defaultAssetShouldNotBeFound("memberId.equals=" + (memberId + 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("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) - .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString()))) - .andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue()))) - .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT))); - - // 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 - .date(UPDATED_DATE) - .action(UPDATED_ACTION) - .amount(UPDATED_AMOUNT) - .comment(UPDATED_COMMENT); - 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.getDate()).isEqualTo(UPDATED_DATE); - assertThat(testAsset.getAction()).isEqualTo(UPDATED_ACTION); - assertThat(testAsset.getAmount()).isEqualTo(UPDATED_AMOUNT); - assertThat(testAsset.getComment()).isEqualTo(UPDATED_COMMENT); - } - - @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/ContactResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java deleted file mode 100644 index 724a06c3..00000000 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/ContactResourceIntTest.java +++ /dev/null @@ -1,536 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; - -import org.hostsharing.hsadminng.HsadminNgApp; - -import org.hostsharing.hsadminng.domain.Contact; -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.hostsharing.hsadminng.repository.ContactRepository; -import org.hostsharing.hsadminng.service.ContactService; -import org.hostsharing.hsadminng.service.dto.ContactDTO; -import org.hostsharing.hsadminng.service.mapper.ContactMapper; -import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.ContactCriteria; -import org.hostsharing.hsadminng.service.ContactQueryService; - -import org.junit.Before; -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.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 ContactResource REST controller. - * - * @see ContactResource - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = HsadminNgApp.class) -public class ContactResourceIntTest { - - private static final String DEFAULT_FIRST_NAME = "AAAAAAAAAA"; - private static final String UPDATED_FIRST_NAME = "BBBBBBBBBB"; - - private static final String DEFAULT_LAST_NAME = "AAAAAAAAAA"; - private static final String UPDATED_LAST_NAME = "BBBBBBBBBB"; - - private static final String DEFAULT_EMAIL = "AAAAAAAAAA"; - private static final String UPDATED_EMAIL = "BBBBBBBBBB"; - - @Autowired - private ContactRepository contactRepository; - - @Autowired - private ContactMapper contactMapper; - - @Autowired - private ContactService contactService; - - @Autowired - private ContactQueryService contactQueryService; - - @Autowired - private MappingJackson2HttpMessageConverter jacksonMessageConverter; - - @Autowired - private PageableHandlerMethodArgumentResolver pageableArgumentResolver; - - @Autowired - private ExceptionTranslator exceptionTranslator; - - @Autowired - private EntityManager em; - - @Autowired - private Validator validator; - - private MockMvc restContactMockMvc; - - private Contact contact; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - final ContactResource contactResource = new ContactResource(contactService, contactQueryService); - this.restContactMockMvc = MockMvcBuilders.standaloneSetup(contactResource) - .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 Contact createEntity(EntityManager em) { - Contact contact = new Contact() - .firstName(DEFAULT_FIRST_NAME) - .lastName(DEFAULT_LAST_NAME) - .email(DEFAULT_EMAIL); - return contact; - } - - @Before - public void initTest() { - contact = createEntity(em); - } - - @Test - @Transactional - public void createContact() throws Exception { - int databaseSizeBeforeCreate = contactRepository.findAll().size(); - - // Create the Contact - ContactDTO contactDTO = contactMapper.toDto(contact); - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isCreated()); - - // Validate the Contact in the database - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeCreate + 1); - Contact testContact = contactList.get(contactList.size() - 1); - assertThat(testContact.getFirstName()).isEqualTo(DEFAULT_FIRST_NAME); - assertThat(testContact.getLastName()).isEqualTo(DEFAULT_LAST_NAME); - assertThat(testContact.getEmail()).isEqualTo(DEFAULT_EMAIL); - } - - @Test - @Transactional - public void createContactWithExistingId() throws Exception { - int databaseSizeBeforeCreate = contactRepository.findAll().size(); - - // Create the Contact with an existing ID - contact.setId(1L); - ContactDTO contactDTO = contactMapper.toDto(contact); - - // An entity with an existing ID cannot be created, so this API call must fail - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - // Validate the Contact in the database - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeCreate); - } - - @Test - @Transactional - public void checkFirstNameIsRequired() throws Exception { - int databaseSizeBeforeTest = contactRepository.findAll().size(); - // set the field null - contact.setFirstName(null); - - // Create the Contact, which fails. - ContactDTO contactDTO = contactMapper.toDto(contact); - - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeTest); - } - - @Test - @Transactional - public void checkLastNameIsRequired() throws Exception { - int databaseSizeBeforeTest = contactRepository.findAll().size(); - // set the field null - contact.setLastName(null); - - // Create the Contact, which fails. - ContactDTO contactDTO = contactMapper.toDto(contact); - - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeTest); - } - - @Test - @Transactional - public void checkEmailIsRequired() throws Exception { - int databaseSizeBeforeTest = contactRepository.findAll().size(); - // set the field null - contact.setEmail(null); - - // Create the Contact, which fails. - ContactDTO contactDTO = contactMapper.toDto(contact); - - restContactMockMvc.perform(post("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeTest); - } - - @Test - @Transactional - public void getAllContacts() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList - restContactMockMvc.perform(get("/api/contacts?sort=id,desc")) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.[*].id").value(hasItem(contact.getId().intValue()))) - .andExpect(jsonPath("$.[*].firstName").value(hasItem(DEFAULT_FIRST_NAME.toString()))) - .andExpect(jsonPath("$.[*].lastName").value(hasItem(DEFAULT_LAST_NAME.toString()))) - .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL.toString()))); - } - - @Test - @Transactional - public void getContact() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get the contact - restContactMockMvc.perform(get("/api/contacts/{id}", contact.getId())) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.id").value(contact.getId().intValue())) - .andExpect(jsonPath("$.firstName").value(DEFAULT_FIRST_NAME.toString())) - .andExpect(jsonPath("$.lastName").value(DEFAULT_LAST_NAME.toString())) - .andExpect(jsonPath("$.email").value(DEFAULT_EMAIL.toString())); - } - - @Test - @Transactional - public void getAllContactsByFirstNameIsEqualToSomething() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where firstName equals to DEFAULT_FIRST_NAME - defaultContactShouldBeFound("firstName.equals=" + DEFAULT_FIRST_NAME); - - // Get all the contactList where firstName equals to UPDATED_FIRST_NAME - defaultContactShouldNotBeFound("firstName.equals=" + UPDATED_FIRST_NAME); - } - - @Test - @Transactional - public void getAllContactsByFirstNameIsInShouldWork() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where firstName in DEFAULT_FIRST_NAME or UPDATED_FIRST_NAME - defaultContactShouldBeFound("firstName.in=" + DEFAULT_FIRST_NAME + "," + UPDATED_FIRST_NAME); - - // Get all the contactList where firstName equals to UPDATED_FIRST_NAME - defaultContactShouldNotBeFound("firstName.in=" + UPDATED_FIRST_NAME); - } - - @Test - @Transactional - public void getAllContactsByFirstNameIsNullOrNotNull() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where firstName is not null - defaultContactShouldBeFound("firstName.specified=true"); - - // Get all the contactList where firstName is null - defaultContactShouldNotBeFound("firstName.specified=false"); - } - - @Test - @Transactional - public void getAllContactsByLastNameIsEqualToSomething() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where lastName equals to DEFAULT_LAST_NAME - defaultContactShouldBeFound("lastName.equals=" + DEFAULT_LAST_NAME); - - // Get all the contactList where lastName equals to UPDATED_LAST_NAME - defaultContactShouldNotBeFound("lastName.equals=" + UPDATED_LAST_NAME); - } - - @Test - @Transactional - public void getAllContactsByLastNameIsInShouldWork() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where lastName in DEFAULT_LAST_NAME or UPDATED_LAST_NAME - defaultContactShouldBeFound("lastName.in=" + DEFAULT_LAST_NAME + "," + UPDATED_LAST_NAME); - - // Get all the contactList where lastName equals to UPDATED_LAST_NAME - defaultContactShouldNotBeFound("lastName.in=" + UPDATED_LAST_NAME); - } - - @Test - @Transactional - public void getAllContactsByLastNameIsNullOrNotNull() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where lastName is not null - defaultContactShouldBeFound("lastName.specified=true"); - - // Get all the contactList where lastName is null - defaultContactShouldNotBeFound("lastName.specified=false"); - } - - @Test - @Transactional - public void getAllContactsByEmailIsEqualToSomething() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where email equals to DEFAULT_EMAIL - defaultContactShouldBeFound("email.equals=" + DEFAULT_EMAIL); - - // Get all the contactList where email equals to UPDATED_EMAIL - defaultContactShouldNotBeFound("email.equals=" + UPDATED_EMAIL); - } - - @Test - @Transactional - public void getAllContactsByEmailIsInShouldWork() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where email in DEFAULT_EMAIL or UPDATED_EMAIL - defaultContactShouldBeFound("email.in=" + DEFAULT_EMAIL + "," + UPDATED_EMAIL); - - // Get all the contactList where email equals to UPDATED_EMAIL - defaultContactShouldNotBeFound("email.in=" + UPDATED_EMAIL); - } - - @Test - @Transactional - public void getAllContactsByEmailIsNullOrNotNull() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - // Get all the contactList where email is not null - defaultContactShouldBeFound("email.specified=true"); - - // Get all the contactList where email is null - defaultContactShouldNotBeFound("email.specified=false"); - } - - @Test - @Transactional - public void getAllContactsByRoleIsEqualToSomething() throws Exception { - // Initialize the database - CustomerContact role = CustomerContactResourceIntTest.createEntity(em); - em.persist(role); - em.flush(); - contact.addRole(role); - contactRepository.saveAndFlush(contact); - Long roleId = role.getId(); - - // Get all the contactList where role equals to roleId - defaultContactShouldBeFound("roleId.equals=" + roleId); - - // Get all the contactList where role equals to roleId + 1 - defaultContactShouldNotBeFound("roleId.equals=" + (roleId + 1)); - } - - /** - * Executes the search, and checks that the default entity is returned - */ - private void defaultContactShouldBeFound(String filter) throws Exception { - restContactMockMvc.perform(get("/api/contacts?sort=id,desc&" + filter)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.[*].id").value(hasItem(contact.getId().intValue()))) - .andExpect(jsonPath("$.[*].firstName").value(hasItem(DEFAULT_FIRST_NAME))) - .andExpect(jsonPath("$.[*].lastName").value(hasItem(DEFAULT_LAST_NAME))) - .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL))); - - // Check, that the count call also returns 1 - restContactMockMvc.perform(get("/api/contacts/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 defaultContactShouldNotBeFound(String filter) throws Exception { - restContactMockMvc.perform(get("/api/contacts?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 - restContactMockMvc.perform(get("/api/contacts/count?sort=id,desc&" + filter)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(content().string("0")); - } - - - @Test - @Transactional - public void getNonExistingContact() throws Exception { - // Get the contact - restContactMockMvc.perform(get("/api/contacts/{id}", Long.MAX_VALUE)) - .andExpect(status().isNotFound()); - } - - @Test - @Transactional - public void updateContact() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - int databaseSizeBeforeUpdate = contactRepository.findAll().size(); - - // Update the contact - Contact updatedContact = contactRepository.findById(contact.getId()).get(); - // Disconnect from session so that the updates on updatedContact are not directly saved in db - em.detach(updatedContact); - updatedContact - .firstName(UPDATED_FIRST_NAME) - .lastName(UPDATED_LAST_NAME) - .email(UPDATED_EMAIL); - ContactDTO contactDTO = contactMapper.toDto(updatedContact); - - restContactMockMvc.perform(put("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isOk()); - - // Validate the Contact in the database - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeUpdate); - Contact testContact = contactList.get(contactList.size() - 1); - assertThat(testContact.getFirstName()).isEqualTo(UPDATED_FIRST_NAME); - assertThat(testContact.getLastName()).isEqualTo(UPDATED_LAST_NAME); - assertThat(testContact.getEmail()).isEqualTo(UPDATED_EMAIL); - } - - @Test - @Transactional - public void updateNonExistingContact() throws Exception { - int databaseSizeBeforeUpdate = contactRepository.findAll().size(); - - // Create the Contact - ContactDTO contactDTO = contactMapper.toDto(contact); - - // If the entity doesn't have an ID, it will throw BadRequestAlertException - restContactMockMvc.perform(put("/api/contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(contactDTO))) - .andExpect(status().isBadRequest()); - - // Validate the Contact in the database - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeUpdate); - } - - @Test - @Transactional - public void deleteContact() throws Exception { - // Initialize the database - contactRepository.saveAndFlush(contact); - - int databaseSizeBeforeDelete = contactRepository.findAll().size(); - - // Delete the contact - restContactMockMvc.perform(delete("/api/contacts/{id}", contact.getId()) - .accept(TestUtil.APPLICATION_JSON_UTF8)) - .andExpect(status().isOk()); - - // Validate the database is empty - List contactList = contactRepository.findAll(); - assertThat(contactList).hasSize(databaseSizeBeforeDelete - 1); - } - - @Test - @Transactional - public void equalsVerifier() throws Exception { - TestUtil.equalsVerifier(Contact.class); - Contact contact1 = new Contact(); - contact1.setId(1L); - Contact contact2 = new Contact(); - contact2.setId(contact1.getId()); - assertThat(contact1).isEqualTo(contact2); - contact2.setId(2L); - assertThat(contact1).isNotEqualTo(contact2); - contact1.setId(null); - assertThat(contact1).isNotEqualTo(contact2); - } - - @Test - @Transactional - public void dtoEqualsVerifier() throws Exception { - TestUtil.equalsVerifier(ContactDTO.class); - ContactDTO contactDTO1 = new ContactDTO(); - contactDTO1.setId(1L); - ContactDTO contactDTO2 = new ContactDTO(); - assertThat(contactDTO1).isNotEqualTo(contactDTO2); - contactDTO2.setId(contactDTO1.getId()); - assertThat(contactDTO1).isEqualTo(contactDTO2); - contactDTO2.setId(2L); - assertThat(contactDTO1).isNotEqualTo(contactDTO2); - contactDTO1.setId(null); - assertThat(contactDTO1).isNotEqualTo(contactDTO2); - } - - @Test - @Transactional - public void testEntityFromId() { - assertThat(contactMapper.fromId(42L).getId()).isEqualTo(42); - assertThat(contactMapper.fromId(null)).isNull(); - } -} diff --git a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java deleted file mode 100644 index 04097ed1..00000000 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerContactResourceIntTest.java +++ /dev/null @@ -1,431 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; - -import org.hostsharing.hsadminng.HsadminNgApp; - -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.hostsharing.hsadminng.domain.Contact; -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.repository.CustomerContactRepository; -import org.hostsharing.hsadminng.service.CustomerContactService; -import org.hostsharing.hsadminng.service.dto.CustomerContactDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper; -import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria; -import org.hostsharing.hsadminng.service.CustomerContactQueryService; - -import org.junit.Before; -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.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.CustomerContactRole; -/** - * Test class for the CustomerContactResource REST controller. - * - * @see CustomerContactResource - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = HsadminNgApp.class) -public class CustomerContactResourceIntTest { - - private static final CustomerContactRole DEFAULT_ROLE = CustomerContactRole.CONTRACTUAL; - private static final CustomerContactRole UPDATED_ROLE = CustomerContactRole.TECHNICAL; - - @Autowired - private CustomerContactRepository customerContactRepository; - - @Autowired - private CustomerContactMapper customerContactMapper; - - @Autowired - private CustomerContactService customerContactService; - - @Autowired - private CustomerContactQueryService customerContactQueryService; - - @Autowired - private MappingJackson2HttpMessageConverter jacksonMessageConverter; - - @Autowired - private PageableHandlerMethodArgumentResolver pageableArgumentResolver; - - @Autowired - private ExceptionTranslator exceptionTranslator; - - @Autowired - private EntityManager em; - - @Autowired - private Validator validator; - - private MockMvc restCustomerContactMockMvc; - - private CustomerContact customerContact; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - final CustomerContactResource customerContactResource = new CustomerContactResource(customerContactService, customerContactQueryService); - this.restCustomerContactMockMvc = MockMvcBuilders.standaloneSetup(customerContactResource) - .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 CustomerContact createEntity(EntityManager em) { - CustomerContact customerContact = new CustomerContact() - .role(DEFAULT_ROLE); - // Add required entity - Contact contact = ContactResourceIntTest.createEntity(em); - em.persist(contact); - em.flush(); - customerContact.setContact(contact); - // Add required entity - Customer customer = CustomerResourceIntTest.createEntity(em); - em.persist(customer); - em.flush(); - customerContact.setCustomer(customer); - return customerContact; - } - - @Before - public void initTest() { - customerContact = createEntity(em); - } - - @Test - @Transactional - public void createCustomerContact() throws Exception { - int databaseSizeBeforeCreate = customerContactRepository.findAll().size(); - - // Create the CustomerContact - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact); - restCustomerContactMockMvc.perform(post("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isCreated()); - - // Validate the CustomerContact in the database - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeCreate + 1); - CustomerContact testCustomerContact = customerContactList.get(customerContactList.size() - 1); - assertThat(testCustomerContact.getRole()).isEqualTo(DEFAULT_ROLE); - } - - @Test - @Transactional - public void createCustomerContactWithExistingId() throws Exception { - int databaseSizeBeforeCreate = customerContactRepository.findAll().size(); - - // Create the CustomerContact with an existing ID - customerContact.setId(1L); - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact); - - // An entity with an existing ID cannot be created, so this API call must fail - restCustomerContactMockMvc.perform(post("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isBadRequest()); - - // Validate the CustomerContact in the database - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeCreate); - } - - @Test - @Transactional - public void checkRoleIsRequired() throws Exception { - int databaseSizeBeforeTest = customerContactRepository.findAll().size(); - // set the field null - customerContact.setRole(null); - - // Create the CustomerContact, which fails. - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact); - - restCustomerContactMockMvc.perform(post("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isBadRequest()); - - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeTest); - } - - @Test - @Transactional - public void getAllCustomerContacts() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get all the customerContactList - restCustomerContactMockMvc.perform(get("/api/customer-contacts?sort=id,desc")) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.[*].id").value(hasItem(customerContact.getId().intValue()))) - .andExpect(jsonPath("$.[*].role").value(hasItem(DEFAULT_ROLE.toString()))); - } - - @Test - @Transactional - public void getCustomerContact() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get the customerContact - restCustomerContactMockMvc.perform(get("/api/customer-contacts/{id}", customerContact.getId())) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.id").value(customerContact.getId().intValue())) - .andExpect(jsonPath("$.role").value(DEFAULT_ROLE.toString())); - } - - @Test - @Transactional - public void getAllCustomerContactsByRoleIsEqualToSomething() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get all the customerContactList where role equals to DEFAULT_ROLE - defaultCustomerContactShouldBeFound("role.equals=" + DEFAULT_ROLE); - - // Get all the customerContactList where role equals to UPDATED_ROLE - defaultCustomerContactShouldNotBeFound("role.equals=" + UPDATED_ROLE); - } - - @Test - @Transactional - public void getAllCustomerContactsByRoleIsInShouldWork() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get all the customerContactList where role in DEFAULT_ROLE or UPDATED_ROLE - defaultCustomerContactShouldBeFound("role.in=" + DEFAULT_ROLE + "," + UPDATED_ROLE); - - // Get all the customerContactList where role equals to UPDATED_ROLE - defaultCustomerContactShouldNotBeFound("role.in=" + UPDATED_ROLE); - } - - @Test - @Transactional - public void getAllCustomerContactsByRoleIsNullOrNotNull() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - // Get all the customerContactList where role is not null - defaultCustomerContactShouldBeFound("role.specified=true"); - - // Get all the customerContactList where role is null - defaultCustomerContactShouldNotBeFound("role.specified=false"); - } - - @Test - @Transactional - public void getAllCustomerContactsByContactIsEqualToSomething() throws Exception { - // Initialize the database - Contact contact = ContactResourceIntTest.createEntity(em); - em.persist(contact); - em.flush(); - customerContact.setContact(contact); - customerContactRepository.saveAndFlush(customerContact); - Long contactId = contact.getId(); - - // Get all the customerContactList where contact equals to contactId - defaultCustomerContactShouldBeFound("contactId.equals=" + contactId); - - // Get all the customerContactList where contact equals to contactId + 1 - defaultCustomerContactShouldNotBeFound("contactId.equals=" + (contactId + 1)); - } - - - @Test - @Transactional - public void getAllCustomerContactsByCustomerIsEqualToSomething() throws Exception { - // Initialize the database - Customer customer = CustomerResourceIntTest.createEntity(em); - em.persist(customer); - em.flush(); - customerContact.setCustomer(customer); - customerContactRepository.saveAndFlush(customerContact); - Long customerId = customer.getId(); - - // Get all the customerContactList where customer equals to customerId - defaultCustomerContactShouldBeFound("customerId.equals=" + customerId); - - // Get all the customerContactList where customer equals to customerId + 1 - defaultCustomerContactShouldNotBeFound("customerId.equals=" + (customerId + 1)); - } - - /** - * Executes the search, and checks that the default entity is returned - */ - private void defaultCustomerContactShouldBeFound(String filter) throws Exception { - restCustomerContactMockMvc.perform(get("/api/customer-contacts?sort=id,desc&" + filter)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.[*].id").value(hasItem(customerContact.getId().intValue()))) - .andExpect(jsonPath("$.[*].role").value(hasItem(DEFAULT_ROLE.toString()))); - - // Check, that the count call also returns 1 - restCustomerContactMockMvc.perform(get("/api/customer-contacts/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 defaultCustomerContactShouldNotBeFound(String filter) throws Exception { - restCustomerContactMockMvc.perform(get("/api/customer-contacts?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 - restCustomerContactMockMvc.perform(get("/api/customer-contacts/count?sort=id,desc&" + filter)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(content().string("0")); - } - - - @Test - @Transactional - public void getNonExistingCustomerContact() throws Exception { - // Get the customerContact - restCustomerContactMockMvc.perform(get("/api/customer-contacts/{id}", Long.MAX_VALUE)) - .andExpect(status().isNotFound()); - } - - @Test - @Transactional - public void updateCustomerContact() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - int databaseSizeBeforeUpdate = customerContactRepository.findAll().size(); - - // Update the customerContact - CustomerContact updatedCustomerContact = customerContactRepository.findById(customerContact.getId()).get(); - // Disconnect from session so that the updates on updatedCustomerContact are not directly saved in db - em.detach(updatedCustomerContact); - updatedCustomerContact - .role(UPDATED_ROLE); - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(updatedCustomerContact); - - restCustomerContactMockMvc.perform(put("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isOk()); - - // Validate the CustomerContact in the database - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeUpdate); - CustomerContact testCustomerContact = customerContactList.get(customerContactList.size() - 1); - assertThat(testCustomerContact.getRole()).isEqualTo(UPDATED_ROLE); - } - - @Test - @Transactional - public void updateNonExistingCustomerContact() throws Exception { - int databaseSizeBeforeUpdate = customerContactRepository.findAll().size(); - - // Create the CustomerContact - CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact); - - // If the entity doesn't have an ID, it will throw BadRequestAlertException - restCustomerContactMockMvc.perform(put("/api/customer-contacts") - .contentType(TestUtil.APPLICATION_JSON_UTF8) - .content(TestUtil.convertObjectToJsonBytes(customerContactDTO))) - .andExpect(status().isBadRequest()); - - // Validate the CustomerContact in the database - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeUpdate); - } - - @Test - @Transactional - public void deleteCustomerContact() throws Exception { - // Initialize the database - customerContactRepository.saveAndFlush(customerContact); - - int databaseSizeBeforeDelete = customerContactRepository.findAll().size(); - - // Delete the customerContact - restCustomerContactMockMvc.perform(delete("/api/customer-contacts/{id}", customerContact.getId()) - .accept(TestUtil.APPLICATION_JSON_UTF8)) - .andExpect(status().isOk()); - - // Validate the database is empty - List customerContactList = customerContactRepository.findAll(); - assertThat(customerContactList).hasSize(databaseSizeBeforeDelete - 1); - } - - @Test - @Transactional - public void equalsVerifier() throws Exception { - TestUtil.equalsVerifier(CustomerContact.class); - CustomerContact customerContact1 = new CustomerContact(); - customerContact1.setId(1L); - CustomerContact customerContact2 = new CustomerContact(); - customerContact2.setId(customerContact1.getId()); - assertThat(customerContact1).isEqualTo(customerContact2); - customerContact2.setId(2L); - assertThat(customerContact1).isNotEqualTo(customerContact2); - customerContact1.setId(null); - assertThat(customerContact1).isNotEqualTo(customerContact2); - } - - @Test - @Transactional - public void dtoEqualsVerifier() throws Exception { - TestUtil.equalsVerifier(CustomerContactDTO.class); - CustomerContactDTO customerContactDTO1 = new CustomerContactDTO(); - customerContactDTO1.setId(1L); - CustomerContactDTO customerContactDTO2 = new CustomerContactDTO(); - assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2); - customerContactDTO2.setId(customerContactDTO1.getId()); - assertThat(customerContactDTO1).isEqualTo(customerContactDTO2); - customerContactDTO2.setId(2L); - assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2); - customerContactDTO1.setId(null); - assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2); - } - - @Test - @Transactional - public void testEntityFromId() { - assertThat(customerContactMapper.fromId(42L).getId()).isEqualTo(42); - assertThat(customerContactMapper.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 deleted file mode 100644 index d22cad45..00000000 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java +++ /dev/null @@ -1,794 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; - -import org.hostsharing.hsadminng.HsadminNgApp; -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.CustomerContact; -import org.hostsharing.hsadminng.domain.Membership; -import org.hostsharing.hsadminng.repository.CustomerRepository; -import org.hostsharing.hsadminng.service.CustomerQueryService; -import org.hostsharing.hsadminng.service.CustomerService; -import org.hostsharing.hsadminng.service.dto.CustomerDTO; -import org.hostsharing.hsadminng.service.mapper.CustomerMapper; -import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.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.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -/** - * Test class for the CustomerResource REST controller. - * - * @see CustomerResource - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = HsadminNgApp.class) -public class CustomerResourceIntTest { - - private static final Integer DEFAULT_NUMBER = 10000; - private static final Integer UPDATED_NUMBER = 10001; - - private static final String DEFAULT_PREFIX = "lzv"; - private static final String UPDATED_PREFIX = "zf"; - - private static final String DEFAULT_NAME = "AAAAAAAAAA"; - private static final String UPDATED_NAME = "BBBBBBBBBB"; - - private static final String DEFAULT_CONTRACTUAL_ADDRESS = "AAAAAAAAAA"; - private static final String UPDATED_CONTRACTUAL_ADDRESS = "BBBBBBBBBB"; - - private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA"; - private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB"; - - private static final String DEFAULT_BILLING_ADDRESS = "AAAAAAAAAA"; - private static final String UPDATED_BILLING_ADDRESS = "BBBBBBBBBB"; - - private static final String DEFAULT_BILLING_SALUTATION = "AAAAAAAAAA"; - private static final String UPDATED_BILLING_SALUTATION = "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() - .number(DEFAULT_NUMBER) - .prefix(DEFAULT_PREFIX) - .name(DEFAULT_NAME) - .contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS) - .contractualSalutation(DEFAULT_CONTRACTUAL_SALUTATION) - .billingAddress(DEFAULT_BILLING_ADDRESS) - .billingSalutation(DEFAULT_BILLING_SALUTATION); - 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.getNumber()).isEqualTo(DEFAULT_NUMBER); - assertThat(testCustomer.getPrefix()).isEqualTo(DEFAULT_PREFIX); - assertThat(testCustomer.getName()).isEqualTo(DEFAULT_NAME); - assertThat(testCustomer.getContractualAddress()).isEqualTo(DEFAULT_CONTRACTUAL_ADDRESS); - assertThat(testCustomer.getContractualSalutation()).isEqualTo(DEFAULT_CONTRACTUAL_SALUTATION); - assertThat(testCustomer.getBillingAddress()).isEqualTo(DEFAULT_BILLING_ADDRESS); - assertThat(testCustomer.getBillingSalutation()).isEqualTo(DEFAULT_BILLING_SALUTATION); - } - - @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 checkNumberIsRequired() throws Exception { - int databaseSizeBeforeTest = customerRepository.findAll().size(); - // set the field null - customer.setNumber(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 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("$.[*].number").value(hasItem(DEFAULT_NUMBER))) - .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX.toString()))) - .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))) - .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS.toString()))) - .andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION.toString()))) - .andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS.toString()))) - .andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION.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("$.number").value(DEFAULT_NUMBER)) - .andExpect(jsonPath("$.prefix").value(DEFAULT_PREFIX.toString())) - .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())) - .andExpect(jsonPath("$.contractualAddress").value(DEFAULT_CONTRACTUAL_ADDRESS.toString())) - .andExpect(jsonPath("$.contractualSalutation").value(DEFAULT_CONTRACTUAL_SALUTATION.toString())) - .andExpect(jsonPath("$.billingAddress").value(DEFAULT_BILLING_ADDRESS.toString())) - .andExpect(jsonPath("$.billingSalutation").value(DEFAULT_BILLING_SALUTATION.toString())); - } - - @Test - @Transactional - public void getAllCustomersByNumberIsEqualToSomething() throws Exception { - // Initialize the database - customerRepository.saveAndFlush(customer); - - // Get all the customerList where number equals to DEFAULT_NUMBER - defaultCustomerShouldBeFound("number.equals=" + DEFAULT_NUMBER); - - // Get all the customerList where number equals to UPDATED_NUMBER - defaultCustomerShouldNotBeFound("number.equals=" + UPDATED_NUMBER); - } - - @Test - @Transactional - public void getAllCustomersByNumberIsInShouldWork() throws Exception { - // Initialize the database - customerRepository.saveAndFlush(customer); - - // Get all the customerList where number in DEFAULT_NUMBER or UPDATED_NUMBER - defaultCustomerShouldBeFound("number.in=" + DEFAULT_NUMBER + "," + UPDATED_NUMBER); - - // Get all the customerList where number equals to UPDATED_NUMBER - defaultCustomerShouldNotBeFound("number.in=" + UPDATED_NUMBER); - } - - @Test - @Transactional - public void getAllCustomersByNumberIsNullOrNotNull() throws Exception { - // Initialize the database - customerRepository.saveAndFlush(customer); - - // Get all the customerList where number is not null - defaultCustomerShouldBeFound("number.specified=true"); - - // Get all the customerList where number is null - defaultCustomerShouldNotBeFound("number.specified=false"); - } - - @Test - @Transactional - public void getAllCustomersByNumberIsGreaterThanOrEqualToSomething() throws Exception { - // Initialize the database - customerRepository.saveAndFlush(customer); - - // Get all the customerList where number greater than or equals to DEFAULT_NUMBER - defaultCustomerShouldBeFound("number.greaterOrEqualThan=" + DEFAULT_NUMBER); - - // Get all the customerList where number greater than or equals to (DEFAULT_NUMBER + 1) - defaultCustomerShouldNotBeFound("number.greaterOrEqualThan=" + (DEFAULT_NUMBER + 1)); - } - - @Test - @Transactional - public void getAllCustomersByNumberIsLessThanSomething() throws Exception { - // Initialize the database - customerRepository.saveAndFlush(customer); - - // Get all the customerList where number less than or equals to DEFAULT_NUMBER - defaultCustomerShouldNotBeFound("number.lessThan=" + DEFAULT_NUMBER); - - // Get all the customerList where number less than or equals to (DEFAULT_NUMBER + 1) - defaultCustomerShouldBeFound("number.lessThan=" + (DEFAULT_NUMBER + 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 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 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 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 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 getAllCustomersByRoleIsEqualToSomething() throws Exception { - // Initialize the database - CustomerContact role = CustomerContactResourceIntTest.createEntity(em); - em.persist(role); - em.flush(); - customer.addRole(role); - customerRepository.saveAndFlush(customer); - Long roleId = role.getId(); - - // Get all the customerList where role equals to roleId - defaultCustomerShouldBeFound("roleId.equals=" + roleId); - - // Get all the customerList where role equals to roleId + 1 - defaultCustomerShouldNotBeFound("roleId.equals=" + (roleId + 1)); - } - - - @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)); - } - - /** - * 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("$.[*].number").value(hasItem(DEFAULT_NUMBER))) - .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX))) - .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))) - .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS))) - .andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION))) - .andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS))) - .andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION))); - - // 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 - .number(UPDATED_NUMBER) - .prefix(UPDATED_PREFIX) - .name(UPDATED_NAME) - .contractualAddress(UPDATED_CONTRACTUAL_ADDRESS) - .contractualSalutation(UPDATED_CONTRACTUAL_SALUTATION) - .billingAddress(UPDATED_BILLING_ADDRESS) - .billingSalutation(UPDATED_BILLING_SALUTATION); - 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.getNumber()).isEqualTo(UPDATED_NUMBER); - assertThat(testCustomer.getPrefix()).isEqualTo(UPDATED_PREFIX); - assertThat(testCustomer.getName()).isEqualTo(UPDATED_NAME); - assertThat(testCustomer.getContractualAddress()).isEqualTo(UPDATED_CONTRACTUAL_ADDRESS); - assertThat(testCustomer.getContractualSalutation()).isEqualTo(UPDATED_CONTRACTUAL_SALUTATION); - assertThat(testCustomer.getBillingAddress()).isEqualTo(UPDATED_BILLING_ADDRESS); - assertThat(testCustomer.getBillingSalutation()).isEqualTo(UPDATED_BILLING_SALUTATION); - } - - @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 deleted file mode 100644 index 97b8eed0..00000000 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java +++ /dev/null @@ -1,546 +0,0 @@ -package org.hostsharing.hsadminng.web.rest; - -import org.hostsharing.hsadminng.HsadminNgApp; -import org.hostsharing.hsadminng.domain.Asset; -import org.hostsharing.hsadminng.domain.Customer; -import org.hostsharing.hsadminng.domain.Membership; -import org.hostsharing.hsadminng.domain.Share; -import org.hostsharing.hsadminng.repository.MembershipRepository; -import org.hostsharing.hsadminng.service.MembershipQueryService; -import org.hostsharing.hsadminng.service.MembershipService; -import org.hostsharing.hsadminng.service.dto.MembershipDTO; -import org.hostsharing.hsadminng.service.mapper.MembershipMapper; -import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.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.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -/** - * Test class for the MembershipResource REST controller. - * - * @see MembershipResource - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = HsadminNgApp.class) -public class MembershipResourceIntTest { - - private static final LocalDate DEFAULT_SINCE_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_SINCE_DATE = LocalDate.now(ZoneId.systemDefault()); - - private static final LocalDate DEFAULT_UNTIL_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault()); - - @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() - .sinceDate(DEFAULT_SINCE_DATE) - .untilDate(DEFAULT_UNTIL_DATE); - // 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.getSinceDate()).isEqualTo(DEFAULT_SINCE_DATE); - assertThat(testMembership.getUntilDate()).isEqualTo(DEFAULT_UNTIL_DATE); - } - - @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 checkSinceDateIsRequired() throws Exception { - int databaseSizeBeforeTest = membershipRepository.findAll().size(); - // set the field null - membership.setSinceDate(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("$.[*].sinceDate").value(hasItem(DEFAULT_SINCE_DATE.toString()))) - .andExpect(jsonPath("$.[*].untilDate").value(hasItem(DEFAULT_UNTIL_DATE.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("$.sinceDate").value(DEFAULT_SINCE_DATE.toString())) - .andExpect(jsonPath("$.untilDate").value(DEFAULT_UNTIL_DATE.toString())); - } - - @Test - @Transactional - public void getAllMembershipsBySinceDateIsEqualToSomething() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where sinceDate equals to DEFAULT_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.equals=" + DEFAULT_SINCE_DATE); - - // Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.equals=" + UPDATED_SINCE_DATE); - } - - @Test - @Transactional - public void getAllMembershipsBySinceDateIsInShouldWork() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where sinceDate in DEFAULT_SINCE_DATE or UPDATED_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.in=" + DEFAULT_SINCE_DATE + "," + UPDATED_SINCE_DATE); - - // Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.in=" + UPDATED_SINCE_DATE); - } - - @Test - @Transactional - public void getAllMembershipsBySinceDateIsNullOrNotNull() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where sinceDate is not null - defaultMembershipShouldBeFound("sinceDate.specified=true"); - - // Get all the membershipList where sinceDate is null - defaultMembershipShouldNotBeFound("sinceDate.specified=false"); - } - - @Test - @Transactional - public void getAllMembershipsBySinceDateIsGreaterThanOrEqualToSomething() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where sinceDate greater than or equals to DEFAULT_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.greaterOrEqualThan=" + DEFAULT_SINCE_DATE); - - // Get all the membershipList where sinceDate greater than or equals to UPDATED_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.greaterOrEqualThan=" + UPDATED_SINCE_DATE); - } - - @Test - @Transactional - public void getAllMembershipsBySinceDateIsLessThanSomething() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where sinceDate less than or equals to DEFAULT_SINCE_DATE - defaultMembershipShouldNotBeFound("sinceDate.lessThan=" + DEFAULT_SINCE_DATE); - - // Get all the membershipList where sinceDate less than or equals to UPDATED_SINCE_DATE - defaultMembershipShouldBeFound("sinceDate.lessThan=" + UPDATED_SINCE_DATE); - } - - - @Test - @Transactional - public void getAllMembershipsByUntilDateIsEqualToSomething() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where untilDate equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.equals=" + DEFAULT_UNTIL_DATE); - - // Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.equals=" + UPDATED_UNTIL_DATE); - } - - @Test - @Transactional - public void getAllMembershipsByUntilDateIsInShouldWork() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where untilDate in DEFAULT_UNTIL_DATE or UPDATED_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.in=" + DEFAULT_UNTIL_DATE + "," + UPDATED_UNTIL_DATE); - - // Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.in=" + UPDATED_UNTIL_DATE); - } - - @Test - @Transactional - public void getAllMembershipsByUntilDateIsNullOrNotNull() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where untilDate is not null - defaultMembershipShouldBeFound("untilDate.specified=true"); - - // Get all the membershipList where untilDate is null - defaultMembershipShouldNotBeFound("untilDate.specified=false"); - } - - @Test - @Transactional - public void getAllMembershipsByUntilDateIsGreaterThanOrEqualToSomething() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where untilDate greater than or equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.greaterOrEqualThan=" + DEFAULT_UNTIL_DATE); - - // Get all the membershipList where untilDate greater than or equals to UPDATED_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.greaterOrEqualThan=" + UPDATED_UNTIL_DATE); - } - - @Test - @Transactional - public void getAllMembershipsByUntilDateIsLessThanSomething() throws Exception { - // Initialize the database - membershipRepository.saveAndFlush(membership); - - // Get all the membershipList where untilDate less than or equals to DEFAULT_UNTIL_DATE - defaultMembershipShouldNotBeFound("untilDate.lessThan=" + DEFAULT_UNTIL_DATE); - - // Get all the membershipList where untilDate less than or equals to UPDATED_UNTIL_DATE - defaultMembershipShouldBeFound("untilDate.lessThan=" + UPDATED_UNTIL_DATE); - } - - - @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("$.[*].sinceDate").value(hasItem(DEFAULT_SINCE_DATE.toString()))) - .andExpect(jsonPath("$.[*].untilDate").value(hasItem(DEFAULT_UNTIL_DATE.toString()))); - - // 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 - .sinceDate(UPDATED_SINCE_DATE) - .untilDate(UPDATED_UNTIL_DATE); - 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.getSinceDate()).isEqualTo(UPDATED_SINCE_DATE); - assertThat(testMembership.getUntilDate()).isEqualTo(UPDATED_UNTIL_DATE); - } - - @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/ShareResourceIntTest.java b/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java deleted file mode 100644 index 44aa1dca..00000000 --- a/src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java +++ /dev/null @@ -1,642 +0,0 @@ -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.enumeration.ShareAction; -import org.hostsharing.hsadminng.repository.ShareRepository; -import org.hostsharing.hsadminng.service.ShareQueryService; -import org.hostsharing.hsadminng.service.ShareService; -import org.hostsharing.hsadminng.service.dto.ShareDTO; -import org.hostsharing.hsadminng.service.mapper.ShareMapper; -import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator; -import org.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.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.hasItem; -import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -/** - * Test class for the ShareResource REST controller. - * - * @see ShareResource - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = HsadminNgApp.class) -public class ShareResourceIntTest { - - private static final LocalDate DEFAULT_DATE = LocalDate.ofEpochDay(0L); - private static final LocalDate UPDATED_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_COMMENT = "AAAAAAAAAA"; - private static final String UPDATED_COMMENT = "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() - .date(DEFAULT_DATE) - .action(DEFAULT_ACTION) - .quantity(DEFAULT_QUANTITY) - .comment(DEFAULT_COMMENT); - // Add required entity - Membership membership = MembershipResourceIntTest.createEntity(em); - em.persist(membership); - em.flush(); - share.setMember(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.getDate()).isEqualTo(DEFAULT_DATE); - assertThat(testShare.getAction()).isEqualTo(DEFAULT_ACTION); - assertThat(testShare.getQuantity()).isEqualTo(DEFAULT_QUANTITY); - assertThat(testShare.getComment()).isEqualTo(DEFAULT_COMMENT); - } - - @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 checkDateIsRequired() throws Exception { - int databaseSizeBeforeTest = shareRepository.findAll().size(); - // set the field null - share.setDate(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("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) - .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString()))) - .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY))) - .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT.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("$.date").value(DEFAULT_DATE.toString())) - .andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString())) - .andExpect(jsonPath("$.quantity").value(DEFAULT_QUANTITY)) - .andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT.toString())); - } - - @Test - @Transactional - public void getAllSharesByDateIsEqualToSomething() throws Exception { - // Initialize the database - shareRepository.saveAndFlush(share); - - // Get all the shareList where date equals to DEFAULT_DATE - defaultShareShouldBeFound("date.equals=" + DEFAULT_DATE); - - // Get all the shareList where date equals to UPDATED_DATE - defaultShareShouldNotBeFound("date.equals=" + UPDATED_DATE); - } - - @Test - @Transactional - public void getAllSharesByDateIsInShouldWork() throws Exception { - // Initialize the database - shareRepository.saveAndFlush(share); - - // Get all the shareList where date in DEFAULT_DATE or UPDATED_DATE - defaultShareShouldBeFound("date.in=" + DEFAULT_DATE + "," + UPDATED_DATE); - - // Get all the shareList where date equals to UPDATED_DATE - defaultShareShouldNotBeFound("date.in=" + UPDATED_DATE); - } - - @Test - @Transactional - public void getAllSharesByDateIsNullOrNotNull() throws Exception { - // Initialize the database - shareRepository.saveAndFlush(share); - - // Get all the shareList where date is not null - defaultShareShouldBeFound("date.specified=true"); - - // Get all the shareList where date is null - defaultShareShouldNotBeFound("date.specified=false"); - } - - @Test - @Transactional - public void getAllSharesByDateIsGreaterThanOrEqualToSomething() throws Exception { - // Initialize the database - shareRepository.saveAndFlush(share); - - // Get all the shareList where date greater than or equals to DEFAULT_DATE - defaultShareShouldBeFound("date.greaterOrEqualThan=" + DEFAULT_DATE); - - // Get all the shareList where date greater than or equals to UPDATED_DATE - defaultShareShouldNotBeFound("date.greaterOrEqualThan=" + UPDATED_DATE); - } - - @Test - @Transactional - public void getAllSharesByDateIsLessThanSomething() throws Exception { - // Initialize the database - shareRepository.saveAndFlush(share); - - // Get all the shareList where date less than or equals to DEFAULT_DATE - defaultShareShouldNotBeFound("date.lessThan=" + DEFAULT_DATE); - - // Get all the shareList where date less than or equals to UPDATED_DATE - defaultShareShouldBeFound("date.lessThan=" + UPDATED_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 getAllSharesByCommentIsEqualToSomething() throws Exception { - // Initialize the database - shareRepository.saveAndFlush(share); - - // Get all the shareList where comment equals to DEFAULT_COMMENT - defaultShareShouldBeFound("comment.equals=" + DEFAULT_COMMENT); - - // Get all the shareList where comment equals to UPDATED_COMMENT - defaultShareShouldNotBeFound("comment.equals=" + UPDATED_COMMENT); - } - - @Test - @Transactional - public void getAllSharesByCommentIsInShouldWork() throws Exception { - // Initialize the database - shareRepository.saveAndFlush(share); - - // Get all the shareList where comment in DEFAULT_COMMENT or UPDATED_COMMENT - defaultShareShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT); - - // Get all the shareList where comment equals to UPDATED_COMMENT - defaultShareShouldNotBeFound("comment.in=" + UPDATED_COMMENT); - } - - @Test - @Transactional - public void getAllSharesByCommentIsNullOrNotNull() throws Exception { - // Initialize the database - shareRepository.saveAndFlush(share); - - // Get all the shareList where comment is not null - defaultShareShouldBeFound("comment.specified=true"); - - // Get all the shareList where comment is null - defaultShareShouldNotBeFound("comment.specified=false"); - } - - @Test - @Transactional - public void getAllSharesByMemberIsEqualToSomething() throws Exception { - // Initialize the database - Membership member = MembershipResourceIntTest.createEntity(em); - em.persist(member); - em.flush(); - share.setMember(member); - shareRepository.saveAndFlush(share); - Long memberId = member.getId(); - - // Get all the shareList where member equals to memberId - defaultShareShouldBeFound("memberId.equals=" + memberId); - - // Get all the shareList where member equals to memberId + 1 - defaultShareShouldNotBeFound("memberId.equals=" + (memberId + 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("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) - .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString()))) - .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY))) - .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT))); - - // 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 - .date(UPDATED_DATE) - .action(UPDATED_ACTION) - .quantity(UPDATED_QUANTITY) - .comment(UPDATED_COMMENT); - 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.getDate()).isEqualTo(UPDATED_DATE); - assertThat(testShare.getAction()).isEqualTo(UPDATED_ACTION); - assertThat(testShare.getQuantity()).isEqualTo(UPDATED_QUANTITY); - assertThat(testShare.getComment()).isEqualTo(UPDATED_COMMENT); - } - - @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 deleted file mode 100644 index 26ab4fb0..00000000 --- a/src/test/javascript/spec/app/entities/asset/asset-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 deleted file mode 100644 index 8d176985..00000000 --- a/src/test/javascript/spec/app/entities/asset/asset-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 deleted file mode 100644 index 0278f8ab..00000000 --- a/src/test/javascript/spec/app/entities/asset/asset-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { 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 deleted file mode 100644 index c8afd397..00000000 --- a/src/test/javascript/spec/app/entities/asset/asset.component.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 deleted file mode 100644 index 99eabace..00000000 --- a/src/test/javascript/spec/app/entities/asset/asset.service.spec.ts +++ /dev/null @@ -1,135 +0,0 @@ -/* 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, AssetAction.PAYMENT, 0, 'AAAAAAA'); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign( - { - date: 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, - date: currentDate.format(DATE_FORMAT) - }, - elemDefault - ); - const expected = Object.assign( - { - date: 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( - { - date: currentDate.format(DATE_FORMAT), - action: 'BBBBBB', - amount: 1, - comment: 'BBBBBB' - }, - elemDefault - ); - - const expected = Object.assign( - { - date: 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( - { - date: currentDate.format(DATE_FORMAT), - action: 'BBBBBB', - amount: 1, - comment: 'BBBBBB' - }, - elemDefault - ); - const expected = Object.assign( - { - date: 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/contact/contact-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/contact/contact-delete-dialog.component.spec.ts deleted file mode 100644 index 1c572ff0..00000000 --- a/src/test/javascript/spec/app/entities/contact/contact-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 { ContactDeleteDialogComponent } from 'app/entities/contact/contact-delete-dialog.component'; -import { ContactService } from 'app/entities/contact/contact.service'; - -describe('Component Tests', () => { - describe('Contact Management Delete Component', () => { - let comp: ContactDeleteDialogComponent; - let fixture: ComponentFixture; - let service: ContactService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [ContactDeleteDialogComponent] - }) - .overrideTemplate(ContactDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ContactDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ContactService); - 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/contact/contact-detail.component.spec.ts b/src/test/javascript/spec/app/entities/contact/contact-detail.component.spec.ts deleted file mode 100644 index f269a672..00000000 --- a/src/test/javascript/spec/app/entities/contact/contact-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 { ContactDetailComponent } from 'app/entities/contact/contact-detail.component'; -import { Contact } from 'app/shared/model/contact.model'; - -describe('Component Tests', () => { - describe('Contact Management Detail Component', () => { - let comp: ContactDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ contact: new Contact(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [ContactDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }] - }) - .overrideTemplate(ContactDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ContactDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.contact).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/contact/contact-update.component.spec.ts b/src/test/javascript/spec/app/entities/contact/contact-update.component.spec.ts deleted file mode 100644 index 3cd83c3d..00000000 --- a/src/test/javascript/spec/app/entities/contact/contact-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* 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 { ContactUpdateComponent } from 'app/entities/contact/contact-update.component'; -import { ContactService } from 'app/entities/contact/contact.service'; -import { Contact } from 'app/shared/model/contact.model'; - -describe('Component Tests', () => { - describe('Contact Management Update Component', () => { - let comp: ContactUpdateComponent; - let fixture: ComponentFixture; - let service: ContactService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [ContactUpdateComponent] - }) - .overrideTemplate(ContactUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ContactUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ContactService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new Contact(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.contact = 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 Contact(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.contact = 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/contact/contact.component.spec.ts b/src/test/javascript/spec/app/entities/contact/contact.component.spec.ts deleted file mode 100644 index 86c74058..00000000 --- a/src/test/javascript/spec/app/entities/contact/contact.component.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 { ContactComponent } from 'app/entities/contact/contact.component'; -import { ContactService } from 'app/entities/contact/contact.service'; -import { Contact } from 'app/shared/model/contact.model'; - -describe('Component Tests', () => { - describe('Contact Management Component', () => { - let comp: ContactComponent; - let fixture: ComponentFixture; - let service: ContactService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [ContactComponent], - providers: [ - { - provide: ActivatedRoute, - useValue: { - data: { - subscribe: (fn: (value: Data) => void) => - fn({ - pagingParams: { - predicate: 'id', - reverse: false, - page: 0 - } - }) - } - } - } - ] - }) - .overrideTemplate(ContactComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ContactComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ContactService); - }); - - 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 Contact(123)], - headers - }) - ) - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.contacts[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 Contact(123)], - headers - }) - ) - ); - - // WHEN - comp.loadPage(1); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.contacts[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 Contact(123)], - headers - }) - ) - ); - - // WHEN - comp.loadPage(1); - comp.reset(); - - // THEN - expect(comp.page).toEqual(0); - expect(service.query).toHaveBeenCalledTimes(2); - expect(comp.contacts[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/contact/contact.service.spec.ts b/src/test/javascript/spec/app/entities/contact/contact.service.spec.ts deleted file mode 100644 index 5e912840..00000000 --- a/src/test/javascript/spec/app/entities/contact/contact.service.spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* 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 { ContactService } from 'app/entities/contact/contact.service'; -import { IContact, Contact } from 'app/shared/model/contact.model'; - -describe('Service Tests', () => { - describe('Contact Service', () => { - let injector: TestBed; - let service: ContactService; - let httpMock: HttpTestingController; - let elemDefault: IContact; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] - }); - injector = getTestBed(); - service = injector.get(ContactService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new Contact(0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA'); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, 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 Contact', async () => { - const returnedFromService = Object.assign( - { - id: 0 - }, - elemDefault - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new Contact(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 Contact', async () => { - const returnedFromService = Object.assign( - { - firstName: 'BBBBBB', - lastName: 'BBBBBB', - email: 'BBBBBB' - }, - elemDefault - ); - - const expected = Object.assign({}, 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 Contact', async () => { - const returnedFromService = Object.assign( - { - firstName: 'BBBBBB', - lastName: 'BBBBBB', - email: 'BBBBBB' - }, - elemDefault - ); - const expected = Object.assign({}, 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 Contact', 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-contact/customer-contact-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact-delete-dialog.component.spec.ts deleted file mode 100644 index 57ab1ea5..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 { CustomerContactDeleteDialogComponent } from 'app/entities/customer-contact/customer-contact-delete-dialog.component'; -import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service'; - -describe('Component Tests', () => { - describe('CustomerContact Management Delete Component', () => { - let comp: CustomerContactDeleteDialogComponent; - let fixture: ComponentFixture; - let service: CustomerContactService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [CustomerContactDeleteDialogComponent] - }) - .overrideTemplate(CustomerContactDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(CustomerContactDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CustomerContactService); - 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-contact/customer-contact-detail.component.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact-detail.component.spec.ts deleted file mode 100644 index 54e11abc..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 { CustomerContactDetailComponent } from 'app/entities/customer-contact/customer-contact-detail.component'; -import { CustomerContact } from 'app/shared/model/customer-contact.model'; - -describe('Component Tests', () => { - describe('CustomerContact Management Detail Component', () => { - let comp: CustomerContactDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ customerContact: new CustomerContact(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [CustomerContactDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }] - }) - .overrideTemplate(CustomerContactDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(CustomerContactDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.customerContact).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/customer-contact/customer-contact-update.component.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact-update.component.spec.ts deleted file mode 100644 index 9c73dbb8..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* 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 { CustomerContactUpdateComponent } from 'app/entities/customer-contact/customer-contact-update.component'; -import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service'; -import { CustomerContact } from 'app/shared/model/customer-contact.model'; - -describe('Component Tests', () => { - describe('CustomerContact Management Update Component', () => { - let comp: CustomerContactUpdateComponent; - let fixture: ComponentFixture; - let service: CustomerContactService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [CustomerContactUpdateComponent] - }) - .overrideTemplate(CustomerContactUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(CustomerContactUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CustomerContactService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new CustomerContact(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.customerContact = 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 CustomerContact(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.customerContact = 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-contact/customer-contact.component.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact.component.spec.ts deleted file mode 100644 index 1d0649ef..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact.component.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 { CustomerContactComponent } from 'app/entities/customer-contact/customer-contact.component'; -import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service'; -import { CustomerContact } from 'app/shared/model/customer-contact.model'; - -describe('Component Tests', () => { - describe('CustomerContact Management Component', () => { - let comp: CustomerContactComponent; - let fixture: ComponentFixture; - let service: CustomerContactService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HsadminNgTestModule], - declarations: [CustomerContactComponent], - providers: [ - { - provide: ActivatedRoute, - useValue: { - data: { - subscribe: (fn: (value: Data) => void) => - fn({ - pagingParams: { - predicate: 'id', - reverse: false, - page: 0 - } - }) - } - } - } - ] - }) - .overrideTemplate(CustomerContactComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(CustomerContactComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CustomerContactService); - }); - - 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 CustomerContact(123)], - headers - }) - ) - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.customerContacts[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 CustomerContact(123)], - headers - }) - ) - ); - - // WHEN - comp.loadPage(1); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.customerContacts[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 CustomerContact(123)], - headers - }) - ) - ); - - // WHEN - comp.loadPage(1); - comp.reset(); - - // THEN - expect(comp.page).toEqual(0); - expect(service.query).toHaveBeenCalledTimes(2); - expect(comp.customerContacts[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-contact/customer-contact.service.spec.ts b/src/test/javascript/spec/app/entities/customer-contact/customer-contact.service.spec.ts deleted file mode 100644 index f31d85b9..00000000 --- a/src/test/javascript/spec/app/entities/customer-contact/customer-contact.service.spec.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* 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 { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service'; -import { ICustomerContact, CustomerContact, CustomerContactRole } from 'app/shared/model/customer-contact.model'; - -describe('Service Tests', () => { - describe('CustomerContact Service', () => { - let injector: TestBed; - let service: CustomerContactService; - let httpMock: HttpTestingController; - let elemDefault: ICustomerContact; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] - }); - injector = getTestBed(); - service = injector.get(CustomerContactService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new CustomerContact(0, CustomerContactRole.CONTRACTUAL); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, 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 CustomerContact', async () => { - const returnedFromService = Object.assign( - { - id: 0 - }, - elemDefault - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new CustomerContact(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 CustomerContact', async () => { - const returnedFromService = Object.assign( - { - role: 'BBBBBB' - }, - elemDefault - ); - - const expected = Object.assign({}, 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 CustomerContact', async () => { - const returnedFromService = Object.assign( - { - role: 'BBBBBB' - }, - elemDefault - ); - const expected = Object.assign({}, 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 CustomerContact', 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 deleted file mode 100644 index 7b4f83cc..00000000 --- a/src/test/javascript/spec/app/entities/customer/customer-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 deleted file mode 100644 index 1e4506ac..00000000 --- a/src/test/javascript/spec/app/entities/customer/customer-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 deleted file mode 100644 index 2249e64e..00000000 --- a/src/test/javascript/spec/app/entities/customer/customer-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { 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 deleted file mode 100644 index 414db92f..00000000 --- a/src/test/javascript/spec/app/entities/customer/customer.component.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 deleted file mode 100644 index 8cbf4977..00000000 --- a/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts +++ /dev/null @@ -1,114 +0,0 @@ -/* tslint:disable max-line-length */ -import { getTestBed, TestBed } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { map, take } from 'rxjs/operators'; -import { CustomerService } from 'app/entities/customer/customer.service'; -import { Customer, ICustomer } from 'app/shared/model/customer.model'; - -describe('Service Tests', () => { - describe('Customer Service', () => { - let injector: TestBed; - let service: CustomerService; - let httpMock: HttpTestingController; - let elemDefault: ICustomer; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule] - }); - injector = getTestBed(); - service = injector.get(CustomerService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new Customer(0, 0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA'); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, 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 - }, - elemDefault - ); - const expected = Object.assign({}, 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( - { - number: 1, - prefix: 'BBBBBB', - name: 'BBBBBB', - contractualAddress: 'BBBBBB', - contractualSalutation: 'BBBBBB', - billingAddress: 'BBBBBB', - billingSalutation: 'BBBBBB' - }, - elemDefault - ); - - const expected = Object.assign({}, 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( - { - number: 1, - prefix: 'BBBBBB', - name: 'BBBBBB', - contractualAddress: 'BBBBBB', - contractualSalutation: 'BBBBBB', - billingAddress: 'BBBBBB', - billingSalutation: 'BBBBBB' - }, - elemDefault - ); - const expected = Object.assign({}, 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 deleted file mode 100644 index 9b396b77..00000000 --- a/src/test/javascript/spec/app/entities/membership/membership-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 deleted file mode 100644 index a66f96f5..00000000 --- a/src/test/javascript/spec/app/entities/membership/membership-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 deleted file mode 100644 index 3fa8f65c..00000000 --- a/src/test/javascript/spec/app/entities/membership/membership-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { 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 deleted file mode 100644 index a43d6a1c..00000000 --- a/src/test/javascript/spec/app/entities/membership/membership.component.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 deleted file mode 100644 index d608d510..00000000 --- a/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts +++ /dev/null @@ -1,136 +0,0 @@ -/* 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); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign( - { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: 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, - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) - }, - elemDefault - ); - const expected = Object.assign( - { - sinceDate: currentDate, - untilDate: 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( - { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) - }, - elemDefault - ); - - const expected = Object.assign( - { - sinceDate: currentDate, - untilDate: 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( - { - sinceDate: currentDate.format(DATE_FORMAT), - untilDate: currentDate.format(DATE_FORMAT) - }, - elemDefault - ); - const expected = Object.assign( - { - sinceDate: currentDate, - untilDate: 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/share/share-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/share/share-delete-dialog.component.spec.ts deleted file mode 100644 index 7e1c8acb..00000000 --- a/src/test/javascript/spec/app/entities/share/share-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 deleted file mode 100644 index 69de2445..00000000 --- a/src/test/javascript/spec/app/entities/share/share-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 deleted file mode 100644 index f19de7be..00000000 --- a/src/test/javascript/spec/app/entities/share/share-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { 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 deleted file mode 100644 index ab0e60bb..00000000 --- a/src/test/javascript/spec/app/entities/share/share.component.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 deleted file mode 100644 index b3288c82..00000000 --- a/src/test/javascript/spec/app/entities/share/share.service.spec.ts +++ /dev/null @@ -1,135 +0,0 @@ -/* 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, ShareAction.SUBSCRIPTION, 0, 'AAAAAAA'); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign( - { - date: 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, - date: currentDate.format(DATE_FORMAT) - }, - elemDefault - ); - const expected = Object.assign( - { - date: 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( - { - date: currentDate.format(DATE_FORMAT), - action: 'BBBBBB', - quantity: 1, - comment: 'BBBBBB' - }, - elemDefault - ); - - const expected = Object.assign( - { - date: 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( - { - date: currentDate.format(DATE_FORMAT), - action: 'BBBBBB', - quantity: 1, - comment: 'BBBBBB' - }, - elemDefault - ); - const expected = Object.assign( - { - date: 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(); - }); - }); -}); From fa0ba61de36d6e4ca2df713d3edab5126a3d85a0 Mon Sep 17 00:00:00 2001 From: Michael Hierweck Date: Thu, 18 Apr 2019 16:31:39 +0200 Subject: [PATCH 4/5] Generated --- .jhipster/Asset.json | 61 ++ .jhipster/Customer.json | 102 ++ .jhipster/Membership.json | 62 ++ .jhipster/SepaMandate.json | 84 ++ .jhipster/Share.json | 61 ++ .../hostsharing/hsadminng/domain/Asset.java | 175 ++++ .../hsadminng/domain/Customer.java | 268 +++++ .../hsadminng/domain/Membership.java | 209 ++++ .../hsadminng/domain/SepaMandate.java | 241 +++++ .../hostsharing/hsadminng/domain/Share.java | 174 ++++ .../domain/enumeration/AssetAction.java | 8 + .../domain/enumeration/ShareAction.java | 8 + .../hsadminng/repository/AssetRepository.java | 15 + .../repository/CustomerRepository.java | 15 + .../repository/MembershipRepository.java | 15 + .../repository/SepaMandateRepository.java | 15 + .../hsadminng/repository/ShareRepository.java | 15 + .../hsadminng/service/AssetQueryService.java | 114 ++ .../hsadminng/service/AssetService.java | 84 ++ .../service/CustomerQueryService.java | 127 +++ .../hsadminng/service/CustomerService.java | 84 ++ .../service/MembershipQueryService.java | 119 +++ .../hsadminng/service/MembershipService.java | 84 ++ .../service/SepaMandateQueryService.java | 126 +++ .../hsadminng/service/SepaMandateService.java | 84 ++ .../hsadminng/service/ShareQueryService.java | 114 ++ .../hsadminng/service/ShareService.java | 84 ++ .../hsadminng/service/dto/AssetCriteria.java | 149 +++ .../hsadminng/service/dto/AssetDTO.java | 134 +++ .../service/dto/CustomerCriteria.java | 193 ++++ .../hsadminng/service/dto/CustomerDTO.java | 151 +++ .../service/dto/MembershipCriteria.java | 155 +++ .../hsadminng/service/dto/MembershipDTO.java | 119 +++ .../service/dto/SepaMandateCriteria.java | 194 ++++ .../hsadminng/service/dto/SepaMandateDTO.java | 178 ++++ .../hsadminng/service/dto/ShareCriteria.java | 148 +++ .../hsadminng/service/dto/ShareDTO.java | 133 +++ .../hsadminng/service/mapper/AssetMapper.java | 29 + .../service/mapper/CustomerMapper.java | 27 + .../service/mapper/EntityMapper.java | 21 + .../service/mapper/MembershipMapper.java | 31 + .../service/mapper/SepaMandateMapper.java | 29 + .../hsadminng/service/mapper/ShareMapper.java | 29 + .../hsadminng/web/rest/AssetResource.java | 138 +++ .../hsadminng/web/rest/CustomerResource.java | 138 +++ .../web/rest/MembershipResource.java | 138 +++ .../web/rest/SepaMandateResource.java | 138 +++ .../hsadminng/web/rest/ShareResource.java | 138 +++ .../20190418143050_added_entity_Customer.xml | 61 ++ ...20190418143051_added_entity_Membership.xml | 49 + ...51_added_entity_constraints_Membership.xml | 18 + .../20190418143052_added_entity_Share.xml | 53 + ...8143052_added_entity_constraints_Share.xml | 18 + .../20190418143053_added_entity_Asset.xml | 53 + ...8143053_added_entity_constraints_Asset.xml | 18 + ...0190418143054_added_entity_SepaMandate.xml | 69 ++ ...4_added_entity_constraints_SepaMandate.xml | 18 + .../resources/config/liquibase/master.xml | 9 + .../asset/asset-delete-dialog.component.html | 19 + .../asset/asset-delete-dialog.component.ts | 65 ++ .../asset/asset-detail.component.html | 49 + .../entities/asset/asset-detail.component.ts | 24 + .../asset/asset-update.component.html | 112 ++ .../entities/asset/asset-update.component.ts | 79 ++ .../app/entities/asset/asset.component.html | 68 ++ .../app/entities/asset/asset.component.ts | 108 ++ .../webapp/app/entities/asset/asset.module.ts | 34 + .../webapp/app/entities/asset/asset.route.ts | 93 ++ .../app/entities/asset/asset.service.ts | 77 ++ src/main/webapp/app/entities/asset/index.ts | 6 + .../customer-delete-dialog.component.html | 19 + .../customer-delete-dialog.component.ts | 65 ++ .../customer/customer-detail.component.html | 55 + .../customer/customer-detail.component.ts | 24 + .../customer/customer-update.component.html | 140 +++ .../customer/customer-update.component.ts | 51 + .../entities/customer/customer.component.html | 68 ++ .../entities/customer/customer.component.ts | 108 ++ .../app/entities/customer/customer.module.ts | 40 + .../app/entities/customer/customer.route.ts | 93 ++ .../app/entities/customer/customer.service.ts | 38 + .../webapp/app/entities/customer/index.ts | 6 + src/main/webapp/app/entities/entity.module.ts | 20 + .../webapp/app/entities/membership/index.ts | 6 + .../membership-delete-dialog.component.html | 19 + .../membership-delete-dialog.component.ts | 69 ++ .../membership-detail.component.html | 45 + .../membership/membership-detail.component.ts | 24 + .../membership-update.component.html | 90 ++ .../membership/membership-update.component.ts | 80 ++ .../membership/membership.component.html | 66 ++ .../membership/membership.component.ts | 108 ++ .../entities/membership/membership.module.ts | 40 + .../entities/membership/membership.route.ts | 93 ++ .../entities/membership/membership.service.ts | 82 ++ .../webapp/app/entities/sepa-mandate/index.ts | 6 + .../sepa-mandate-delete-dialog.component.html | 19 + .../sepa-mandate-delete-dialog.component.ts | 72 ++ .../sepa-mandate-detail.component.html | 65 ++ .../sepa-mandate-detail.component.ts | 24 + .../sepa-mandate-update.component.html | 147 +++ .../sepa-mandate-update.component.ts | 82 ++ .../sepa-mandate/sepa-mandate.component.html | 76 ++ .../sepa-mandate/sepa-mandate.component.ts | 108 ++ .../sepa-mandate/sepa-mandate.module.ts | 40 + .../sepa-mandate/sepa-mandate.route.ts | 93 ++ .../sepa-mandate/sepa-mandate.service.ts | 93 ++ src/main/webapp/app/entities/share/index.ts | 6 + .../share/share-delete-dialog.component.html | 19 + .../share/share-delete-dialog.component.ts | 65 ++ .../share/share-detail.component.html | 49 + .../entities/share/share-detail.component.ts | 24 + .../share/share-update.component.html | 108 ++ .../entities/share/share-update.component.ts | 79 ++ .../app/entities/share/share.component.html | 68 ++ .../app/entities/share/share.component.ts | 108 ++ .../webapp/app/entities/share/share.module.ts | 34 + .../webapp/app/entities/share/share.route.ts | 93 ++ .../app/entities/share/share.service.ts | 77 ++ .../app/layouts/navbar/navbar.component.html | 30 + .../webapp/app/shared/model/asset.model.ts | 34 + .../webapp/app/shared/model/customer.model.ts | 32 + .../app/shared/model/membership.model.ts | 29 + .../app/shared/model/sepa-mandate.model.ts | 33 + .../webapp/app/shared/model/share.model.ts | 30 + src/main/webapp/i18n/de/asset.json | 26 + src/main/webapp/i18n/de/assetAction.json | 13 + src/main/webapp/i18n/de/customer.json | 30 + src/main/webapp/i18n/de/global.json | 5 + src/main/webapp/i18n/de/membership.json | 27 + src/main/webapp/i18n/de/sepaMandate.json | 30 + src/main/webapp/i18n/de/share.json | 26 + src/main/webapp/i18n/de/shareAction.json | 9 + src/main/webapp/i18n/en/asset.json | 26 + src/main/webapp/i18n/en/assetAction.json | 13 + src/main/webapp/i18n/en/customer.json | 30 + src/main/webapp/i18n/en/global.json | 5 + src/main/webapp/i18n/en/membership.json | 27 + src/main/webapp/i18n/en/sepaMandate.json | 30 + src/main/webapp/i18n/en/share.json | 26 + src/main/webapp/i18n/en/shareAction.json | 9 + .../web/rest/AssetResourceIntTest.java | 716 +++++++++++++ .../web/rest/CustomerResourceIntTest.java | 847 +++++++++++++++ .../web/rest/MembershipResourceIntTest.java | 694 +++++++++++++ .../web/rest/SepaMandateResourceIntTest.java | 972 ++++++++++++++++++ .../web/rest/ShareResourceIntTest.java | 742 +++++++++++++ .../asset-delete-dialog.component.spec.ts | 52 + .../asset/asset-detail.component.spec.ts | 40 + .../asset/asset-update.component.spec.ts | 60 ++ .../entities/asset/asset.component.spec.ts | 128 +++ .../app/entities/asset/asset.service.spec.ts | 142 +++ .../customer-delete-dialog.component.spec.ts | 52 + .../customer-detail.component.spec.ts | 40 + .../customer-update.component.spec.ts | 60 ++ .../customer/customer.component.spec.ts | 128 +++ .../customer/customer.service.spec.ts | 118 +++ ...membership-delete-dialog.component.spec.ts | 52 + .../membership-detail.component.spec.ts | 40 + .../membership-update.component.spec.ts | 60 ++ .../membership/membership.component.spec.ts | 128 +++ .../membership/membership.service.spec.ts | 145 +++ ...pa-mandate-delete-dialog.component.spec.ts | 52 + .../sepa-mandate-detail.component.spec.ts | 40 + .../sepa-mandate-update.component.spec.ts | 60 ++ .../sepa-mandate.component.spec.ts | 128 +++ .../sepa-mandate/sepa-mandate.service.spec.ts | 176 ++++ .../share-delete-dialog.component.spec.ts | 52 + .../share/share-detail.component.spec.ts | 40 + .../share/share-update.component.spec.ts | 60 ++ .../entities/share/share.component.spec.ts | 128 +++ .../app/entities/share/share.service.spec.ts | 142 +++ 171 files changed, 15676 insertions(+) create mode 100644 .jhipster/Asset.json create mode 100644 .jhipster/Customer.json create mode 100644 .jhipster/Membership.json create mode 100644 .jhipster/SepaMandate.json create mode 100644 .jhipster/Share.json create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Asset.java create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Customer.java create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Membership.java create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/SepaMandate.java create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/Share.java create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/enumeration/AssetAction.java create mode 100644 src/main/java/org/hostsharing/hsadminng/domain/enumeration/ShareAction.java create mode 100644 src/main/java/org/hostsharing/hsadminng/repository/AssetRepository.java create mode 100644 src/main/java/org/hostsharing/hsadminng/repository/CustomerRepository.java create mode 100644 src/main/java/org/hostsharing/hsadminng/repository/MembershipRepository.java create mode 100644 src/main/java/org/hostsharing/hsadminng/repository/SepaMandateRepository.java create mode 100644 src/main/java/org/hostsharing/hsadminng/repository/ShareRepository.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/AssetQueryService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/AssetService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/CustomerService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/MembershipService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/SepaMandateQueryService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/SepaMandateService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/ShareQueryService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/ShareService.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/AssetCriteria.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/AssetDTO.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateCriteria.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/SepaMandateDTO.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/ShareCriteria.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/dto/ShareDTO.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/AssetMapper.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/CustomerMapper.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/EntityMapper.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/MembershipMapper.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/SepaMandateMapper.java create mode 100644 src/main/java/org/hostsharing/hsadminng/service/mapper/ShareMapper.java create mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/AssetResource.java create mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/CustomerResource.java create mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/MembershipResource.java create mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/SepaMandateResource.java create mode 100644 src/main/java/org/hostsharing/hsadminng/web/rest/ShareResource.java create mode 100644 src/main/resources/config/liquibase/changelog/20190418143050_added_entity_Customer.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418143051_added_entity_Membership.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418143051_added_entity_constraints_Membership.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418143052_added_entity_Share.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418143052_added_entity_constraints_Share.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418143053_added_entity_Asset.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418143053_added_entity_constraints_Asset.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418143054_added_entity_SepaMandate.xml create mode 100644 src/main/resources/config/liquibase/changelog/20190418143054_added_entity_constraints_SepaMandate.xml create mode 100644 src/main/webapp/app/entities/asset/asset-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/asset/asset-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/asset/asset-detail.component.html create mode 100644 src/main/webapp/app/entities/asset/asset-detail.component.ts create mode 100644 src/main/webapp/app/entities/asset/asset-update.component.html create mode 100644 src/main/webapp/app/entities/asset/asset-update.component.ts create mode 100644 src/main/webapp/app/entities/asset/asset.component.html create mode 100644 src/main/webapp/app/entities/asset/asset.component.ts create mode 100644 src/main/webapp/app/entities/asset/asset.module.ts create mode 100644 src/main/webapp/app/entities/asset/asset.route.ts create mode 100644 src/main/webapp/app/entities/asset/asset.service.ts create mode 100644 src/main/webapp/app/entities/asset/index.ts create mode 100644 src/main/webapp/app/entities/customer/customer-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/customer/customer-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/customer/customer-detail.component.html create mode 100644 src/main/webapp/app/entities/customer/customer-detail.component.ts create mode 100644 src/main/webapp/app/entities/customer/customer-update.component.html create mode 100644 src/main/webapp/app/entities/customer/customer-update.component.ts create mode 100644 src/main/webapp/app/entities/customer/customer.component.html create mode 100644 src/main/webapp/app/entities/customer/customer.component.ts create mode 100644 src/main/webapp/app/entities/customer/customer.module.ts create mode 100644 src/main/webapp/app/entities/customer/customer.route.ts create mode 100644 src/main/webapp/app/entities/customer/customer.service.ts create mode 100644 src/main/webapp/app/entities/customer/index.ts create mode 100644 src/main/webapp/app/entities/membership/index.ts create mode 100644 src/main/webapp/app/entities/membership/membership-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/membership/membership-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/membership/membership-detail.component.html create mode 100644 src/main/webapp/app/entities/membership/membership-detail.component.ts create mode 100644 src/main/webapp/app/entities/membership/membership-update.component.html create mode 100644 src/main/webapp/app/entities/membership/membership-update.component.ts create mode 100644 src/main/webapp/app/entities/membership/membership.component.html create mode 100644 src/main/webapp/app/entities/membership/membership.component.ts create mode 100644 src/main/webapp/app/entities/membership/membership.module.ts create mode 100644 src/main/webapp/app/entities/membership/membership.route.ts create mode 100644 src/main/webapp/app/entities/membership/membership.service.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/index.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-detail.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate-update.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.module.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.route.ts create mode 100644 src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts create mode 100644 src/main/webapp/app/entities/share/index.ts create mode 100644 src/main/webapp/app/entities/share/share-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/share/share-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/share/share-detail.component.html create mode 100644 src/main/webapp/app/entities/share/share-detail.component.ts create mode 100644 src/main/webapp/app/entities/share/share-update.component.html create mode 100644 src/main/webapp/app/entities/share/share-update.component.ts create mode 100644 src/main/webapp/app/entities/share/share.component.html create mode 100644 src/main/webapp/app/entities/share/share.component.ts create mode 100644 src/main/webapp/app/entities/share/share.module.ts create mode 100644 src/main/webapp/app/entities/share/share.route.ts create mode 100644 src/main/webapp/app/entities/share/share.service.ts create mode 100644 src/main/webapp/app/shared/model/asset.model.ts create mode 100644 src/main/webapp/app/shared/model/customer.model.ts create mode 100644 src/main/webapp/app/shared/model/membership.model.ts create mode 100644 src/main/webapp/app/shared/model/sepa-mandate.model.ts create mode 100644 src/main/webapp/app/shared/model/share.model.ts create mode 100644 src/main/webapp/i18n/de/asset.json create mode 100644 src/main/webapp/i18n/de/assetAction.json create mode 100644 src/main/webapp/i18n/de/customer.json create mode 100644 src/main/webapp/i18n/de/membership.json create mode 100644 src/main/webapp/i18n/de/sepaMandate.json create mode 100644 src/main/webapp/i18n/de/share.json create mode 100644 src/main/webapp/i18n/de/shareAction.json create mode 100644 src/main/webapp/i18n/en/asset.json create mode 100644 src/main/webapp/i18n/en/assetAction.json create mode 100644 src/main/webapp/i18n/en/customer.json create mode 100644 src/main/webapp/i18n/en/membership.json create mode 100644 src/main/webapp/i18n/en/sepaMandate.json create mode 100644 src/main/webapp/i18n/en/share.json create mode 100644 src/main/webapp/i18n/en/shareAction.json create mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/AssetResourceIntTest.java create mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java create mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java create mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/SepaMandateResourceIntTest.java create mode 100644 src/test/java/org/hostsharing/hsadminng/web/rest/ShareResourceIntTest.java create mode 100644 src/test/javascript/spec/app/entities/asset/asset-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/asset/asset-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/asset/asset-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/asset/asset.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/asset/asset.service.spec.ts create mode 100644 src/test/javascript/spec/app/entities/customer/customer-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/customer/customer-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/customer/customer-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/customer/customer.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/customer/customer.service.spec.ts create mode 100644 src/test/javascript/spec/app/entities/membership/membership-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/membership/membership-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/membership/membership-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/membership/membership.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/membership/membership.service.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/sepa-mandate/sepa-mandate.service.spec.ts create mode 100644 src/test/javascript/spec/app/entities/share/share-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/share/share-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/share/share-update.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/share/share.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/share/share.service.spec.ts diff --git a/.jhipster/Asset.json b/.jhipster/Asset.json new file mode 100644 index 00000000..cb941126 --- /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": "documentDate" + } + ], + "changelogDate": "20190418143053", + "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..dd33afe4 --- /dev/null +++ b/.jhipster/Customer.json @@ -0,0 +1,102 @@ +{ + "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": "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": "20190418143050", + "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..dff081ff --- /dev/null +++ b/.jhipster/Membership.json @@ -0,0 +1,62 @@ +{ + "name": "Membership", + "fields": [ + { + "fieldName": "documentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "memberFrom", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "memberUntil", + "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": "20190418143051", + "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..8e5c7fdf --- /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": "documentDate", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "validFrom", + "fieldType": "LocalDate", + "fieldValidateRules": [ + "required" + ] + }, + { + "fieldName": "validUntil", + "fieldType": "LocalDate" + }, + { + "fieldName": "lastUsed", + "fieldType": "LocalDate" + }, + { + "fieldName": "cancellationDate", + "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": "20190418143054", + "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..5ea62ab2 --- /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": "documentDate" + } + ], + "changelogDate": "20190418143052", + "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..c7cb1495 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/Customer.java @@ -0,0 +1,268 @@ +package org.hostsharing.hsadminng.domain; + + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +/** + * 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; + + @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 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() + "'" + + ", 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..e84834d8 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/domain/Membership.java @@ -0,0 +1,209 @@ +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 = "document_date", nullable = false) + private LocalDate documentDate; + + @NotNull + @Column(name = "member_from", nullable = false) + private LocalDate memberFrom; + + @Column(name = "member_until") + private LocalDate memberUntil; + + @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 getDocumentDate() { + return documentDate; + } + + public Membership documentDate(LocalDate documentDate) { + this.documentDate = documentDate; + return this; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getMemberFrom() { + return memberFrom; + } + + public Membership memberFrom(LocalDate memberFrom) { + this.memberFrom = memberFrom; + return this; + } + + public void setMemberFrom(LocalDate memberFrom) { + this.memberFrom = memberFrom; + } + + public LocalDate getMemberUntil() { + return memberUntil; + } + + public Membership memberUntil(LocalDate memberUntil) { + this.memberUntil = memberUntil; + return this; + } + + public void setMemberUntil(LocalDate memberUntil) { + this.memberUntil = memberUntil; + } + + 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() + + ", documentDate='" + getDocumentDate() + "'" + + ", memberFrom='" + getMemberFrom() + "'" + + ", memberUntil='" + getMemberUntil() + "'" + + ", 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..3c7741df --- /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 = "document_date", nullable = false) + private LocalDate documentDate; + + @NotNull + @Column(name = "valid_from", nullable = false) + private LocalDate validFrom; + + @Column(name = "valid_until") + private LocalDate validUntil; + + @Column(name = "last_used") + private LocalDate lastUsed; + + @Column(name = "cancellation_date") + private LocalDate cancellationDate; + + @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 getDocumentDate() { + return documentDate; + } + + public SepaMandate documentDate(LocalDate documentDate) { + this.documentDate = documentDate; + return this; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValidFrom() { + return validFrom; + } + + public SepaMandate validFrom(LocalDate validFrom) { + this.validFrom = validFrom; + return this; + } + + public void setValidFrom(LocalDate validFrom) { + this.validFrom = validFrom; + } + + public LocalDate getValidUntil() { + return validUntil; + } + + public SepaMandate validUntil(LocalDate validUntil) { + this.validUntil = validUntil; + return this; + } + + public void setValidUntil(LocalDate validUntil) { + this.validUntil = validUntil; + } + + public LocalDate getLastUsed() { + return lastUsed; + } + + public SepaMandate lastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + return this; + } + + public void setLastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDate getCancellationDate() { + return cancellationDate; + } + + public SepaMandate cancellationDate(LocalDate cancellationDate) { + this.cancellationDate = cancellationDate; + return this; + } + + public void setCancellationDate(LocalDate cancellationDate) { + this.cancellationDate = cancellationDate; + } + + 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() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", validFrom='" + getValidFrom() + "'" + + ", validUntil='" + getValidUntil() + "'" + + ", lastUsed='" + getLastUsed() + "'" + + ", cancellationDate='" + getCancellationDate() + "'" + + ", 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/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/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..937322d1 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/CustomerQueryService.java @@ -0,0 +1,127 @@ +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.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..8ab0bb2f --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/MembershipQueryService.java @@ -0,0 +1,119 @@ +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.getDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), Membership_.documentDate)); + } + if (criteria.getMemberFrom() != null) { + specification = specification.and(buildRangeSpecification(criteria.getMemberFrom(), Membership_.memberFrom)); + } + if (criteria.getMemberUntil() != null) { + specification = specification.and(buildRangeSpecification(criteria.getMemberUntil(), Membership_.memberUntil)); + } + 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..1e31c8b4 --- /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.getDocumentDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getDocumentDate(), SepaMandate_.documentDate)); + } + if (criteria.getValidFrom() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidFrom(), SepaMandate_.validFrom)); + } + if (criteria.getValidUntil() != null) { + specification = specification.and(buildRangeSpecification(criteria.getValidUntil(), SepaMandate_.validUntil)); + } + if (criteria.getLastUsed() != null) { + specification = specification.and(buildRangeSpecification(criteria.getLastUsed(), SepaMandate_.lastUsed)); + } + if (criteria.getCancellationDate() != null) { + specification = specification.and(buildRangeSpecification(criteria.getCancellationDate(), SepaMandate_.cancellationDate)); + } + 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..2ed0d828 --- /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 membershipDocumentDate; + + 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 getMembershipDocumentDate() { + return membershipDocumentDate; + } + + public void setMembershipDocumentDate(String membershipDocumentDate) { + this.membershipDocumentDate = membershipDocumentDate; + } + + @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='" + getMembershipDocumentDate() + "'" + + "}"; + } +} 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..60d82e58 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerCriteria.java @@ -0,0 +1,193 @@ +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; + +/** + * 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 { + + private static final long serialVersionUID = 1L; + + private LongFilter id; + + private IntegerFilter reference; + + private StringFilter prefix; + + private StringFilter name; + + 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 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(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, + 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 + ", " : "") + + (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..6dd5c845 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java @@ -0,0 +1,151 @@ +package org.hostsharing.hsadminng.service.dto; +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; + +/** + * 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; + + @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 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() + "'" + + ", 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..be8308bc --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipCriteria.java @@ -0,0 +1,155 @@ +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 documentDate; + + private LocalDateFilter memberFrom; + + private LocalDateFilter memberUntil; + + 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 getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDateFilter documentDate) { + this.documentDate = documentDate; + } + + public LocalDateFilter getMemberFrom() { + return memberFrom; + } + + public void setMemberFrom(LocalDateFilter memberFrom) { + this.memberFrom = memberFrom; + } + + public LocalDateFilter getMemberUntil() { + return memberUntil; + } + + public void setMemberUntil(LocalDateFilter memberUntil) { + this.memberUntil = memberUntil; + } + + 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(documentDate, that.documentDate) && + Objects.equals(memberFrom, that.memberFrom) && + Objects.equals(memberUntil, that.memberUntil) && + 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, + documentDate, + memberFrom, + memberUntil, + remark, + shareId, + assetId, + customerId + ); + } + + @Override + public String toString() { + return "MembershipCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (documentDate != null ? "documentDate=" + documentDate + ", " : "") + + (memberFrom != null ? "memberFrom=" + memberFrom + ", " : "") + + (memberUntil != null ? "memberUntil=" + memberUntil + ", " : "") + + (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..c21a0ed1 --- /dev/null +++ b/src/main/java/org/hostsharing/hsadminng/service/dto/MembershipDTO.java @@ -0,0 +1,119 @@ +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 documentDate; + + @NotNull + private LocalDate memberFrom; + + private LocalDate memberUntil; + + @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 getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getMemberFrom() { + return memberFrom; + } + + public void setMemberFrom(LocalDate memberFrom) { + this.memberFrom = memberFrom; + } + + public LocalDate getMemberUntil() { + return memberUntil; + } + + public void setMemberUntil(LocalDate memberUntil) { + this.memberUntil = memberUntil; + } + + 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() + + ", documentDate='" + getDocumentDate() + "'" + + ", memberFrom='" + getMemberFrom() + "'" + + ", memberUntil='" + getMemberUntil() + "'" + + ", 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..ce429df5 --- /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 documentDate; + + private LocalDateFilter validFrom; + + private LocalDateFilter validUntil; + + private LocalDateFilter lastUsed; + + private LocalDateFilter cancellationDate; + + 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 getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDateFilter documentDate) { + this.documentDate = documentDate; + } + + public LocalDateFilter getValidFrom() { + return validFrom; + } + + public void setValidFrom(LocalDateFilter validFrom) { + this.validFrom = validFrom; + } + + public LocalDateFilter getValidUntil() { + return validUntil; + } + + public void setValidUntil(LocalDateFilter validUntil) { + this.validUntil = validUntil; + } + + public LocalDateFilter getLastUsed() { + return lastUsed; + } + + public void setLastUsed(LocalDateFilter lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDateFilter getCancellationDate() { + return cancellationDate; + } + + public void setCancellationDate(LocalDateFilter cancellationDate) { + this.cancellationDate = cancellationDate; + } + + 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(documentDate, that.documentDate) && + Objects.equals(validFrom, that.validFrom) && + Objects.equals(validUntil, that.validUntil) && + Objects.equals(lastUsed, that.lastUsed) && + Objects.equals(cancellationDate, that.cancellationDate) && + Objects.equals(remark, that.remark) && + Objects.equals(customerId, that.customerId); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + reference, + iban, + bic, + documentDate, + validFrom, + validUntil, + lastUsed, + cancellationDate, + remark, + customerId + ); + } + + @Override + public String toString() { + return "SepaMandateCriteria{" + + (id != null ? "id=" + id + ", " : "") + + (reference != null ? "reference=" + reference + ", " : "") + + (iban != null ? "iban=" + iban + ", " : "") + + (bic != null ? "bic=" + bic + ", " : "") + + (documentDate != null ? "documentDate=" + documentDate + ", " : "") + + (validFrom != null ? "validFrom=" + validFrom + ", " : "") + + (validUntil != null ? "validUntil=" + validUntil + ", " : "") + + (lastUsed != null ? "lastUsed=" + lastUsed + ", " : "") + + (cancellationDate != null ? "cancellationDate=" + cancellationDate + ", " : "") + + (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..c763f352 --- /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 documentDate; + + @NotNull + private LocalDate validFrom; + + private LocalDate validUntil; + + private LocalDate lastUsed; + + private LocalDate cancellationDate; + + @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 getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(LocalDate documentDate) { + this.documentDate = documentDate; + } + + public LocalDate getValidFrom() { + return validFrom; + } + + public void setValidFrom(LocalDate validFrom) { + this.validFrom = validFrom; + } + + public LocalDate getValidUntil() { + return validUntil; + } + + public void setValidUntil(LocalDate validUntil) { + this.validUntil = validUntil; + } + + public LocalDate getLastUsed() { + return lastUsed; + } + + public void setLastUsed(LocalDate lastUsed) { + this.lastUsed = lastUsed; + } + + public LocalDate getCancellationDate() { + return cancellationDate; + } + + public void setCancellationDate(LocalDate cancellationDate) { + this.cancellationDate = cancellationDate; + } + + 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() + "'" + + ", documentDate='" + getDocumentDate() + "'" + + ", validFrom='" + getValidFrom() + "'" + + ", validUntil='" + getValidUntil() + "'" + + ", lastUsed='" + getLastUsed() + "'" + + ", cancellationDate='" + getCancellationDate() + "'" + + ", 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..e9f873fa --- /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 membershipDocumentDate; + + 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 getMembershipDocumentDate() { + return membershipDocumentDate; + } + + public void setMembershipDocumentDate(String membershipDocumentDate) { + this.membershipDocumentDate = membershipDocumentDate; + } + + @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='" + getMembershipDocumentDate() + "'" + + "}"; + } +} 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..d43fc5c0 --- /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.documentDate", target = "membershipDocumentDate") + 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..6867130d --- /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.documentDate", target = "membershipDocumentDate") + 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/resources/config/liquibase/changelog/20190418143050_added_entity_Customer.xml b/src/main/resources/config/liquibase/changelog/20190418143050_added_entity_Customer.xml new file mode 100644 index 00000000..fc201b01 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143050_added_entity_Customer.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418143051_added_entity_Membership.xml b/src/main/resources/config/liquibase/changelog/20190418143051_added_entity_Membership.xml new file mode 100644 index 00000000..db36e0aa --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143051_added_entity_Membership.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418143051_added_entity_constraints_Membership.xml b/src/main/resources/config/liquibase/changelog/20190418143051_added_entity_constraints_Membership.xml new file mode 100644 index 00000000..0f6b6866 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143051_added_entity_constraints_Membership.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418143052_added_entity_Share.xml b/src/main/resources/config/liquibase/changelog/20190418143052_added_entity_Share.xml new file mode 100644 index 00000000..6a08eebe --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143052_added_entity_Share.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418143052_added_entity_constraints_Share.xml b/src/main/resources/config/liquibase/changelog/20190418143052_added_entity_constraints_Share.xml new file mode 100644 index 00000000..c52cc369 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143052_added_entity_constraints_Share.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418143053_added_entity_Asset.xml b/src/main/resources/config/liquibase/changelog/20190418143053_added_entity_Asset.xml new file mode 100644 index 00000000..1f6c1582 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143053_added_entity_Asset.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418143053_added_entity_constraints_Asset.xml b/src/main/resources/config/liquibase/changelog/20190418143053_added_entity_constraints_Asset.xml new file mode 100644 index 00000000..dacb9c2b --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143053_added_entity_constraints_Asset.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418143054_added_entity_SepaMandate.xml b/src/main/resources/config/liquibase/changelog/20190418143054_added_entity_SepaMandate.xml new file mode 100644 index 00000000..31ff1156 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143054_added_entity_SepaMandate.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20190418143054_added_entity_constraints_SepaMandate.xml b/src/main/resources/config/liquibase/changelog/20190418143054_added_entity_constraints_SepaMandate.xml new file mode 100644 index 00000000..de60c224 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20190418143054_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..201616d6 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..c259a165 --- /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..cc48af42 --- /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..8fac5e46 --- /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..a3d1343c --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-detail.component.html @@ -0,0 +1,55 @@ +
    +
    +
    +

    Customer {{customer.id}}

    +
    + +
    +
    Reference
    +
    + {{customer.reference}} +
    +
    Prefix
    +
    + {{customer.prefix}} +
    +
    Name
    +
    + {{customer.name}} +
    +
    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..de0d7818 --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-update.component.html @@ -0,0 +1,140 @@ +
    +
    +
    +

    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 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..2afd9d0a --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer-update.component.ts @@ -0,0 +1,51 @@ +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 { 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; + + 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..38405029 --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer.component.html @@ -0,0 +1,68 @@ +
    +

    + Customers + +

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ID Reference Prefix Name Contractual Salutation Contractual Address Billing Salutation Billing Address Remark
    {{customer.id}}{{customer.reference}}{{customer.prefix}}{{customer.name}}{{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..20710286 --- /dev/null +++ b/src/main/webapp/app/entities/customer/customer.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +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 { + return this.http.post(this.resourceUrl, customer, { observe: 'response' }); + } + + update(customer: ICustomer): Observable { + return this.http.put(this.resourceUrl, customer, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} 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..8a0ce659 --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-detail.component.html @@ -0,0 +1,45 @@ +
    +
    +
    +

    Membership {{membership.id}}

    +
    + +
    +
    Document Date
    +
    + {{membership.documentDate}} +
    +
    Member From
    +
    + {{membership.memberFrom}} +
    +
    Member Until
    +
    + {{membership.memberUntil}} +
    +
    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..37274e9c --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-update.component.html @@ -0,0 +1,90 @@ +
    +
    +
    +

    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..1f68bfc2 --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership-update.component.ts @@ -0,0 +1,80 @@ +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[]; + documentDateDp: any; + memberFromDp: any; + memberUntilDp: 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..6852205f --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership.component.html @@ -0,0 +1,66 @@ +
    +

    + Memberships + +

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    ID Document Date Member From Member Until Remark Customer
    {{membership.id}}{{membership.documentDate | date:'mediumDate'}}{{membership.memberFrom | date:'mediumDate'}}{{membership.memberUntil | 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..c0fb3e77 --- /dev/null +++ b/src/main/webapp/app/entities/membership/membership.service.ts @@ -0,0 +1,82 @@ +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, { + documentDate: + membership.documentDate != null && membership.documentDate.isValid() ? membership.documentDate.format(DATE_FORMAT) : null, + memberFrom: membership.memberFrom != null && membership.memberFrom.isValid() ? membership.memberFrom.format(DATE_FORMAT) : null, + memberUntil: + membership.memberUntil != null && membership.memberUntil.isValid() ? membership.memberUntil.format(DATE_FORMAT) : null + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.documentDate = res.body.documentDate != null ? moment(res.body.documentDate) : null; + res.body.memberFrom = res.body.memberFrom != null ? moment(res.body.memberFrom) : null; + res.body.memberUntil = res.body.memberUntil != null ? moment(res.body.memberUntil) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((membership: IMembership) => { + membership.documentDate = membership.documentDate != null ? moment(membership.documentDate) : null; + membership.memberFrom = membership.memberFrom != null ? moment(membership.memberFrom) : null; + membership.memberUntil = membership.memberUntil != null ? moment(membership.memberUntil) : null; + }); + } + 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..5b87977f --- /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}} +
    +
    Document Date
    +
    + {{sepaMandate.documentDate}} +
    +
    Valid From
    +
    + {{sepaMandate.validFrom}} +
    +
    Valid Until
    +
    + {{sepaMandate.validUntil}} +
    +
    Last Used
    +
    + {{sepaMandate.lastUsed}} +
    +
    Cancellation Date
    +
    + {{sepaMandate.cancellationDate}} +
    +
    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..c4803427 --- /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..ba809340 --- /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[]; + documentDateDp: any; + validFromDp: any; + validUntilDp: any; + lastUsedDp: any; + cancellationDateDp: 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..21976ea7 --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.component.html @@ -0,0 +1,76 @@ +
    +

    + Sepa Mandates + +

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ID Reference Iban Bic Document Date Valid From Valid Until Last Used Cancellation Date Remark Customer
    {{sepaMandate.id}}{{sepaMandate.reference}}{{sepaMandate.iban}}{{sepaMandate.bic}}{{sepaMandate.documentDate | date:'mediumDate'}}{{sepaMandate.validFrom | date:'mediumDate'}}{{sepaMandate.validUntil | date:'mediumDate'}}{{sepaMandate.lastUsed | date:'mediumDate'}}{{sepaMandate.cancellationDate | date:'mediumDate'}}{{sepaMandate.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..17a9584a --- /dev/null +++ b/src/main/webapp/app/entities/sepa-mandate/sepa-mandate.service.ts @@ -0,0 +1,93 @@ +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, { + documentDate: + sepaMandate.documentDate != null && sepaMandate.documentDate.isValid() + ? sepaMandate.documentDate.format(DATE_FORMAT) + : null, + validFrom: sepaMandate.validFrom != null && sepaMandate.validFrom.isValid() ? sepaMandate.validFrom.format(DATE_FORMAT) : null, + validUntil: + sepaMandate.validUntil != null && sepaMandate.validUntil.isValid() ? sepaMandate.validUntil.format(DATE_FORMAT) : null, + lastUsed: sepaMandate.lastUsed != null && sepaMandate.lastUsed.isValid() ? sepaMandate.lastUsed.format(DATE_FORMAT) : null, + cancellationDate: + sepaMandate.cancellationDate != null && sepaMandate.cancellationDate.isValid() + ? sepaMandate.cancellationDate.format(DATE_FORMAT) + : null + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.documentDate = res.body.documentDate != null ? moment(res.body.documentDate) : null; + res.body.validFrom = res.body.validFrom != null ? moment(res.body.validFrom) : null; + res.body.validUntil = res.body.validUntil != null ? moment(res.body.validUntil) : null; + res.body.lastUsed = res.body.lastUsed != null ? moment(res.body.lastUsed) : null; + res.body.cancellationDate = res.body.cancellationDate != null ? moment(res.body.cancellationDate) : null; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((sepaMandate: ISepaMandate) => { + sepaMandate.documentDate = sepaMandate.documentDate != null ? moment(sepaMandate.documentDate) : null; + sepaMandate.validFrom = sepaMandate.validFrom != null ? moment(sepaMandate.validFrom) : null; + sepaMandate.validUntil = sepaMandate.validUntil != null ? moment(sepaMandate.validUntil) : null; + sepaMandate.lastUsed = sepaMandate.lastUsed != null ? moment(sepaMandate.lastUsed) : null; + sepaMandate.cancellationDate = sepaMandate.cancellationDate != null ? moment(sepaMandate.cancellationDate) : null; + }); + } + 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..505a8591 --- /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..34d6853c --- /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..81c23e25 --- /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..7964c1f7 --- /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; + membershipDocumentDate?: 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 membershipDocumentDate?: 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..1970b289 --- /dev/null +++ b/src/main/webapp/app/shared/model/customer.model.ts @@ -0,0 +1,32 @@ +import { IMembership } from 'app/shared/model/membership.model'; +import { ISepaMandate } from 'app/shared/model/sepa-mandate.model'; + +export interface ICustomer { + id?: number; + reference?: number; + prefix?: string; + name?: 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 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..57418782 --- /dev/null +++ b/src/main/webapp/app/shared/model/membership.model.ts @@ -0,0 +1,29 @@ +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; + documentDate?: Moment; + memberFrom?: Moment; + memberUntil?: Moment; + remark?: string; + shares?: IShare[]; + assets?: IAsset[]; + customerPrefix?: string; + customerId?: number; +} + +export class Membership implements IMembership { + constructor( + public id?: number, + public documentDate?: Moment, + public memberFrom?: Moment, + public memberUntil?: 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..feccc941 --- /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; + documentDate?: Moment; + validFrom?: Moment; + validUntil?: Moment; + lastUsed?: Moment; + cancellationDate?: 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 documentDate?: Moment, + public validFrom?: Moment, + public validUntil?: Moment, + public lastUsed?: Moment, + public cancellationDate?: 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..5338867a --- /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; + membershipDocumentDate?: 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 membershipDocumentDate?: 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..a699be5a --- /dev/null +++ b/src/main/webapp/i18n/de/customer.json @@ -0,0 +1,30 @@ +{ + "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", + "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/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..936c4fc9 --- /dev/null +++ b/src/main/webapp/i18n/de/membership.json @@ -0,0 +1,27 @@ +{ + "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" + }, + "documentDate": "Document Date", + "memberFrom": "Member From", + "memberUntil": "Member Until", + "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..c0d1347b --- /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", + "documentDate": "Document Date", + "validFrom": "Valid From", + "validUntil": "Valid Until", + "lastUsed": "Last Used", + "cancellationDate": "Cancellation 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/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..6f30090f --- /dev/null +++ b/src/main/webapp/i18n/en/customer.json @@ -0,0 +1,30 @@ +{ + "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", + "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/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..9bf9136c --- /dev/null +++ b/src/main/webapp/i18n/en/membership.json @@ -0,0 +1,27 @@ +{ + "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" + }, + "documentDate": "Document Date", + "memberFrom": "Member From", + "memberUntil": "Member Until", + "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..a403e016 --- /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", + "documentDate": "Document Date", + "validFrom": "Valid From", + "validUntil": "Valid Until", + "lastUsed": "Last Used", + "cancellationDate": "Cancellation 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/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..ce8721fc --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/CustomerResourceIntTest.java @@ -0,0 +1,847 @@ +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.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 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 = "hu"; + private static final String UPDATED_PREFIX = "umj"; + + private static final String DEFAULT_NAME = "AAAAAAAAAA"; + private static final String UPDATED_NAME = "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) + .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.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 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("$.[*].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("$.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 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("$.[*].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) + .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.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..a267711d --- /dev/null +++ b/src/test/java/org/hostsharing/hsadminng/web/rest/MembershipResourceIntTest.java @@ -0,0 +1,694 @@ +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_DOCUMENT_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_MEMBER_FROM = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_MEMBER_FROM = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_MEMBER_UNTIL = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_MEMBER_UNTIL = 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() + .documentDate(DEFAULT_DOCUMENT_DATE) + .memberFrom(DEFAULT_MEMBER_FROM) + .memberUntil(DEFAULT_MEMBER_UNTIL) + .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.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE); + assertThat(testMembership.getMemberFrom()).isEqualTo(DEFAULT_MEMBER_FROM); + assertThat(testMembership.getMemberUntil()).isEqualTo(DEFAULT_MEMBER_UNTIL); + 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 checkDocumentDateIsRequired() throws Exception { + int databaseSizeBeforeTest = membershipRepository.findAll().size(); + // set the field null + membership.setDocumentDate(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 checkMemberFromIsRequired() throws Exception { + int databaseSizeBeforeTest = membershipRepository.findAll().size(); + // set the field null + membership.setMemberFrom(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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString()))) + .andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].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("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.memberFrom").value(DEFAULT_MEMBER_FROM.toString())) + .andExpect(jsonPath("$.memberUntil").value(DEFAULT_MEMBER_UNTIL.toString())) + .andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString())); + } + + @Test + @Transactional + public void getAllMembershipsByDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where documentDate equals to DEFAULT_DOCUMENT_DATE + defaultMembershipShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); + + // Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE + defaultMembershipShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE); + + // Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where documentDate is not null + defaultMembershipShouldBeFound("documentDate.specified=true"); + + // Get all the membershipList where documentDate is null + defaultMembershipShouldNotBeFound("documentDate.specified=false"); + } + + @Test + @Transactional + public void getAllMembershipsByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE + defaultMembershipShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the membershipList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllMembershipsByDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE + defaultMembershipShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the membershipList where documentDate less than or equals to UPDATED_DOCUMENT_DATE + defaultMembershipShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllMembershipsByMemberFromIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberFrom equals to DEFAULT_MEMBER_FROM + defaultMembershipShouldBeFound("memberFrom.equals=" + DEFAULT_MEMBER_FROM); + + // Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM + defaultMembershipShouldNotBeFound("memberFrom.equals=" + UPDATED_MEMBER_FROM); + } + + @Test + @Transactional + public void getAllMembershipsByMemberFromIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberFrom in DEFAULT_MEMBER_FROM or UPDATED_MEMBER_FROM + defaultMembershipShouldBeFound("memberFrom.in=" + DEFAULT_MEMBER_FROM + "," + UPDATED_MEMBER_FROM); + + // Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM + defaultMembershipShouldNotBeFound("memberFrom.in=" + UPDATED_MEMBER_FROM); + } + + @Test + @Transactional + public void getAllMembershipsByMemberFromIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberFrom is not null + defaultMembershipShouldBeFound("memberFrom.specified=true"); + + // Get all the membershipList where memberFrom is null + defaultMembershipShouldNotBeFound("memberFrom.specified=false"); + } + + @Test + @Transactional + public void getAllMembershipsByMemberFromIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberFrom greater than or equals to DEFAULT_MEMBER_FROM + defaultMembershipShouldBeFound("memberFrom.greaterOrEqualThan=" + DEFAULT_MEMBER_FROM); + + // Get all the membershipList where memberFrom greater than or equals to UPDATED_MEMBER_FROM + defaultMembershipShouldNotBeFound("memberFrom.greaterOrEqualThan=" + UPDATED_MEMBER_FROM); + } + + @Test + @Transactional + public void getAllMembershipsByMemberFromIsLessThanSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberFrom less than or equals to DEFAULT_MEMBER_FROM + defaultMembershipShouldNotBeFound("memberFrom.lessThan=" + DEFAULT_MEMBER_FROM); + + // Get all the membershipList where memberFrom less than or equals to UPDATED_MEMBER_FROM + defaultMembershipShouldBeFound("memberFrom.lessThan=" + UPDATED_MEMBER_FROM); + } + + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil equals to DEFAULT_MEMBER_UNTIL + defaultMembershipShouldBeFound("memberUntil.equals=" + DEFAULT_MEMBER_UNTIL); + + // Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL + defaultMembershipShouldNotBeFound("memberUntil.equals=" + UPDATED_MEMBER_UNTIL); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsInShouldWork() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil in DEFAULT_MEMBER_UNTIL or UPDATED_MEMBER_UNTIL + defaultMembershipShouldBeFound("memberUntil.in=" + DEFAULT_MEMBER_UNTIL + "," + UPDATED_MEMBER_UNTIL); + + // Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL + defaultMembershipShouldNotBeFound("memberUntil.in=" + UPDATED_MEMBER_UNTIL); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsNullOrNotNull() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil is not null + defaultMembershipShouldBeFound("memberUntil.specified=true"); + + // Get all the membershipList where memberUntil is null + defaultMembershipShouldNotBeFound("memberUntil.specified=false"); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil greater than or equals to DEFAULT_MEMBER_UNTIL + defaultMembershipShouldBeFound("memberUntil.greaterOrEqualThan=" + DEFAULT_MEMBER_UNTIL); + + // Get all the membershipList where memberUntil greater than or equals to UPDATED_MEMBER_UNTIL + defaultMembershipShouldNotBeFound("memberUntil.greaterOrEqualThan=" + UPDATED_MEMBER_UNTIL); + } + + @Test + @Transactional + public void getAllMembershipsByMemberUntilIsLessThanSomething() throws Exception { + // Initialize the database + membershipRepository.saveAndFlush(membership); + + // Get all the membershipList where memberUntil less than or equals to DEFAULT_MEMBER_UNTIL + defaultMembershipShouldNotBeFound("memberUntil.lessThan=" + DEFAULT_MEMBER_UNTIL); + + // Get all the membershipList where memberUntil less than or equals to UPDATED_MEMBER_UNTIL + defaultMembershipShouldBeFound("memberUntil.lessThan=" + UPDATED_MEMBER_UNTIL); + } + + + @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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString()))) + .andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].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 + .documentDate(UPDATED_DOCUMENT_DATE) + .memberFrom(UPDATED_MEMBER_FROM) + .memberUntil(UPDATED_MEMBER_UNTIL) + .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.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE); + assertThat(testMembership.getMemberFrom()).isEqualTo(UPDATED_MEMBER_FROM); + assertThat(testMembership.getMemberUntil()).isEqualTo(UPDATED_MEMBER_UNTIL); + 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..78bf4160 --- /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_DOCUMENT_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_VALID_FROM = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_FROM = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_VALID_UNTIL = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_VALID_UNTIL = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_LAST_USED = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_LAST_USED = LocalDate.now(ZoneId.systemDefault()); + + private static final LocalDate DEFAULT_CANCELLATION_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_CANCELLATION_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final 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) + .documentDate(DEFAULT_DOCUMENT_DATE) + .validFrom(DEFAULT_VALID_FROM) + .validUntil(DEFAULT_VALID_UNTIL) + .lastUsed(DEFAULT_LAST_USED) + .cancellationDate(DEFAULT_CANCELLATION_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.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE); + assertThat(testSepaMandate.getValidFrom()).isEqualTo(DEFAULT_VALID_FROM); + assertThat(testSepaMandate.getValidUntil()).isEqualTo(DEFAULT_VALID_UNTIL); + assertThat(testSepaMandate.getLastUsed()).isEqualTo(DEFAULT_LAST_USED); + assertThat(testSepaMandate.getCancellationDate()).isEqualTo(DEFAULT_CANCELLATION_DATE); + assertThat(testSepaMandate.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 checkDocumentDateIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setDocumentDate(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 checkValidFromIsRequired() throws Exception { + int databaseSizeBeforeTest = sepaMandateRepository.findAll().size(); + // set the field null + sepaMandate.setValidFrom(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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString()))) + .andExpect(jsonPath("$.[*].validUntil").value(hasItem(DEFAULT_VALID_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString()))) + .andExpect(jsonPath("$.[*].cancellationDate").value(hasItem(DEFAULT_CANCELLATION_DATE.toString()))) + .andExpect(jsonPath("$.[*].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("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString())) + .andExpect(jsonPath("$.validFrom").value(DEFAULT_VALID_FROM.toString())) + .andExpect(jsonPath("$.validUntil").value(DEFAULT_VALID_UNTIL.toString())) + .andExpect(jsonPath("$.lastUsed").value(DEFAULT_LAST_USED.toString())) + .andExpect(jsonPath("$.cancellationDate").value(DEFAULT_CANCELLATION_DATE.toString())) + .andExpect(jsonPath("$.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 getAllSepaMandatesByDocumentDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate equals to DEFAULT_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE); + + // Get all the sepaMandateList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByDocumentDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE); + + // Get all the sepaMandateList where documentDate equals to UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByDocumentDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate is not null + defaultSepaMandateShouldBeFound("documentDate.specified=true"); + + // Get all the sepaMandateList where documentDate is null + defaultSepaMandateShouldNotBeFound("documentDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the sepaMandateList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByDocumentDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE + defaultSepaMandateShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE); + + // Get all the sepaMandateList where documentDate less than or equals to UPDATED_DOCUMENT_DATE + defaultSepaMandateShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE); + } + + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.equals=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.equals=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom in DEFAULT_VALID_FROM or UPDATED_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.in=" + DEFAULT_VALID_FROM + "," + UPDATED_VALID_FROM); + + // Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.in=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom is not null + defaultSepaMandateShouldBeFound("validFrom.specified=true"); + + // Get all the sepaMandateList where validFrom is null + defaultSepaMandateShouldNotBeFound("validFrom.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom greater than or equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.greaterOrEqualThan=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom greater than or equals to UPDATED_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.greaterOrEqualThan=" + UPDATED_VALID_FROM); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidFromIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validFrom less than or equals to DEFAULT_VALID_FROM + defaultSepaMandateShouldNotBeFound("validFrom.lessThan=" + DEFAULT_VALID_FROM); + + // Get all the sepaMandateList where validFrom less than or equals to UPDATED_VALID_FROM + defaultSepaMandateShouldBeFound("validFrom.lessThan=" + UPDATED_VALID_FROM); + } + + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil equals to DEFAULT_VALID_UNTIL + defaultSepaMandateShouldBeFound("validUntil.equals=" + DEFAULT_VALID_UNTIL); + + // Get all the sepaMandateList where validUntil equals to UPDATED_VALID_UNTIL + defaultSepaMandateShouldNotBeFound("validUntil.equals=" + UPDATED_VALID_UNTIL); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil in DEFAULT_VALID_UNTIL or UPDATED_VALID_UNTIL + defaultSepaMandateShouldBeFound("validUntil.in=" + DEFAULT_VALID_UNTIL + "," + UPDATED_VALID_UNTIL); + + // Get all the sepaMandateList where validUntil equals to UPDATED_VALID_UNTIL + defaultSepaMandateShouldNotBeFound("validUntil.in=" + UPDATED_VALID_UNTIL); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil is not null + defaultSepaMandateShouldBeFound("validUntil.specified=true"); + + // Get all the sepaMandateList where validUntil is null + defaultSepaMandateShouldNotBeFound("validUntil.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil greater than or equals to DEFAULT_VALID_UNTIL + defaultSepaMandateShouldBeFound("validUntil.greaterOrEqualThan=" + DEFAULT_VALID_UNTIL); + + // Get all the sepaMandateList where validUntil greater than or equals to UPDATED_VALID_UNTIL + defaultSepaMandateShouldNotBeFound("validUntil.greaterOrEqualThan=" + UPDATED_VALID_UNTIL); + } + + @Test + @Transactional + public void getAllSepaMandatesByValidUntilIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where validUntil less than or equals to DEFAULT_VALID_UNTIL + defaultSepaMandateShouldNotBeFound("validUntil.lessThan=" + DEFAULT_VALID_UNTIL); + + // Get all the sepaMandateList where validUntil less than or equals to UPDATED_VALID_UNTIL + defaultSepaMandateShouldBeFound("validUntil.lessThan=" + UPDATED_VALID_UNTIL); + } + + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed equals to DEFAULT_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.equals=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.equals=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed in DEFAULT_LAST_USED or UPDATED_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.in=" + DEFAULT_LAST_USED + "," + UPDATED_LAST_USED); + + // Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.in=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed is not null + defaultSepaMandateShouldBeFound("lastUsed.specified=true"); + + // Get all the sepaMandateList where lastUsed is null + defaultSepaMandateShouldNotBeFound("lastUsed.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed greater than or equals to DEFAULT_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.greaterOrEqualThan=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed greater than or equals to UPDATED_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.greaterOrEqualThan=" + UPDATED_LAST_USED); + } + + @Test + @Transactional + public void getAllSepaMandatesByLastUsedIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where lastUsed less than or equals to DEFAULT_LAST_USED + defaultSepaMandateShouldNotBeFound("lastUsed.lessThan=" + DEFAULT_LAST_USED); + + // Get all the sepaMandateList where lastUsed less than or equals to UPDATED_LAST_USED + defaultSepaMandateShouldBeFound("lastUsed.lessThan=" + UPDATED_LAST_USED); + } + + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate equals to DEFAULT_CANCELLATION_DATE + defaultSepaMandateShouldBeFound("cancellationDate.equals=" + DEFAULT_CANCELLATION_DATE); + + // Get all the sepaMandateList where cancellationDate equals to UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldNotBeFound("cancellationDate.equals=" + UPDATED_CANCELLATION_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsInShouldWork() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate in DEFAULT_CANCELLATION_DATE or UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldBeFound("cancellationDate.in=" + DEFAULT_CANCELLATION_DATE + "," + UPDATED_CANCELLATION_DATE); + + // Get all the sepaMandateList where cancellationDate equals to UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldNotBeFound("cancellationDate.in=" + UPDATED_CANCELLATION_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsNullOrNotNull() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate is not null + defaultSepaMandateShouldBeFound("cancellationDate.specified=true"); + + // Get all the sepaMandateList where cancellationDate is null + defaultSepaMandateShouldNotBeFound("cancellationDate.specified=false"); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsGreaterThanOrEqualToSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate greater than or equals to DEFAULT_CANCELLATION_DATE + defaultSepaMandateShouldBeFound("cancellationDate.greaterOrEqualThan=" + DEFAULT_CANCELLATION_DATE); + + // Get all the sepaMandateList where cancellationDate greater than or equals to UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldNotBeFound("cancellationDate.greaterOrEqualThan=" + UPDATED_CANCELLATION_DATE); + } + + @Test + @Transactional + public void getAllSepaMandatesByCancellationDateIsLessThanSomething() throws Exception { + // Initialize the database + sepaMandateRepository.saveAndFlush(sepaMandate); + + // Get all the sepaMandateList where cancellationDate less than or equals to DEFAULT_CANCELLATION_DATE + defaultSepaMandateShouldNotBeFound("cancellationDate.lessThan=" + DEFAULT_CANCELLATION_DATE); + + // Get all the sepaMandateList where cancellationDate less than or equals to UPDATED_CANCELLATION_DATE + defaultSepaMandateShouldBeFound("cancellationDate.lessThan=" + UPDATED_CANCELLATION_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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString()))) + .andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString()))) + .andExpect(jsonPath("$.[*].validUntil").value(hasItem(DEFAULT_VALID_UNTIL.toString()))) + .andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString()))) + .andExpect(jsonPath("$.[*].cancellationDate").value(hasItem(DEFAULT_CANCELLATION_DATE.toString()))) + .andExpect(jsonPath("$.[*].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) + .documentDate(UPDATED_DOCUMENT_DATE) + .validFrom(UPDATED_VALID_FROM) + .validUntil(UPDATED_VALID_UNTIL) + .lastUsed(UPDATED_LAST_USED) + .cancellationDate(UPDATED_CANCELLATION_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.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE); + assertThat(testSepaMandate.getValidFrom()).isEqualTo(UPDATED_VALID_FROM); + assertThat(testSepaMandate.getValidUntil()).isEqualTo(UPDATED_VALID_UNTIL); + assertThat(testSepaMandate.getLastUsed()).isEqualTo(UPDATED_LAST_USED); + assertThat(testSepaMandate.getCancellationDate()).isEqualTo(UPDATED_CANCELLATION_DATE); + assertThat(testSepaMandate.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..53f01f13 --- /dev/null +++ b/src/test/javascript/spec/app/entities/customer/customer.service.spec.ts @@ -0,0 +1,118 @@ +/* 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 { CustomerService } from 'app/entities/customer/customer.service'; +import { ICustomer, Customer } from 'app/shared/model/customer.model'; + +describe('Service Tests', () => { + describe('Customer Service', () => { + let injector: TestBed; + let service: CustomerService; + let httpMock: HttpTestingController; + let elemDefault: ICustomer; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + injector = getTestBed(); + service = injector.get(CustomerService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Customer(0, 0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, 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 + }, + elemDefault + ); + const expected = Object.assign({}, 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', + contractualSalutation: 'BBBBBB', + contractualAddress: 'BBBBBB', + billingSalutation: 'BBBBBB', + billingAddress: 'BBBBBB', + remark: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign({}, 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', + contractualSalutation: 'BBBBBB', + contractualAddress: 'BBBBBB', + billingSalutation: 'BBBBBB', + billingAddress: 'BBBBBB', + remark: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign({}, 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..765beeec --- /dev/null +++ b/src/test/javascript/spec/app/entities/membership/membership.service.spec.ts @@ -0,0 +1,145 @@ +/* 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, 'AAAAAAA'); + }); + + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + documentDate: currentDate.format(DATE_FORMAT), + memberFrom: currentDate.format(DATE_FORMAT), + memberUntil: currentDate.format(DATE_FORMAT) + }, + 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, + documentDate: currentDate.format(DATE_FORMAT), + memberFrom: currentDate.format(DATE_FORMAT), + memberUntil: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + memberFrom: currentDate, + memberUntil: 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( + { + documentDate: currentDate.format(DATE_FORMAT), + memberFrom: currentDate.format(DATE_FORMAT), + memberUntil: currentDate.format(DATE_FORMAT), + remark: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + documentDate: currentDate, + memberFrom: currentDate, + memberUntil: 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( + { + documentDate: currentDate.format(DATE_FORMAT), + memberFrom: currentDate.format(DATE_FORMAT), + memberUntil: currentDate.format(DATE_FORMAT), + remark: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + memberFrom: currentDate, + memberUntil: 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..0ff6222c --- /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( + { + documentDate: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validUntil: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancellationDate: currentDate.format(DATE_FORMAT) + }, + 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, + documentDate: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validUntil: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancellationDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + validFrom: currentDate, + validUntil: currentDate, + lastUsed: currentDate, + cancellationDate: 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', + documentDate: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validUntil: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancellationDate: currentDate.format(DATE_FORMAT), + remark: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + documentDate: currentDate, + validFrom: currentDate, + validUntil: currentDate, + lastUsed: currentDate, + cancellationDate: 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', + documentDate: currentDate.format(DATE_FORMAT), + validFrom: currentDate.format(DATE_FORMAT), + validUntil: currentDate.format(DATE_FORMAT), + lastUsed: currentDate.format(DATE_FORMAT), + cancellationDate: currentDate.format(DATE_FORMAT), + remark: 'BBBBBB' + }, + elemDefault + ); + const expected = Object.assign( + { + documentDate: currentDate, + validFrom: currentDate, + validUntil: currentDate, + lastUsed: currentDate, + cancellationDate: 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(); + }); + }); +}); From ce083e928a04f48ef15fd6d7eedda958cca43705 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 17 Apr 2019 16:45:16 +0200 Subject: [PATCH 5/5] comment access rights on CustomerDTO --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 542e5db4..7efa4725 100644 --- a/build.gradle +++ b/build.gradle @@ -208,7 +208,7 @@ task cucumberTestReport(type: TestReport) { pitest { targetClasses = ['org.hostsharing.hsadminng.*'] - threads = 4 + threads = 2 // Do not set these limit even lower, they are already pretty bad values! // 83%*78% means that only ~66% of the code is properly covered by automated tests.