rename contact.label to contact.caption #55

Merged
hsh-michaelhoennig merged 1 commits from rename-contact-label-to-caption into master 2024-05-06 10:09:07 +02:00
35 changed files with 191 additions and 191 deletions
Showing only changes of commit 85376d51af - Show all commits

View File

@ -36,10 +36,10 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
public ResponseEntity<List<HsOfficeContactResource>> listContacts( public ResponseEntity<List<HsOfficeContactResource>> listContacts(
final String currentUser, final String currentUser,
final String assumedRoles, final String assumedRoles,
final String label) { final String caption) {
context.define(currentUser, assumedRoles); context.define(currentUser, assumedRoles);
final var entities = contactRepo.findContactByOptionalLabelLike(label); final var entities = contactRepo.findContactByOptionalCaptionLike(caption);
final var resources = mapper.mapList(entities, HsOfficeContactResource.class); final var resources = mapper.mapList(entities, HsOfficeContactResource.class);
return ResponseEntity.ok(resources); return ResponseEntity.ok(resources);

View File

@ -38,7 +38,7 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
public class HsOfficeContactEntity implements Stringifyable, RbacObject { public class HsOfficeContactEntity implements Stringifyable, RbacObject {
private static Stringify<HsOfficeContactEntity> toString = stringify(HsOfficeContactEntity.class, "contact") private static Stringify<HsOfficeContactEntity> toString = stringify(HsOfficeContactEntity.class, "contact")
.withProp(Fields.label, HsOfficeContactEntity::getLabel) .withProp(Fields.caption, HsOfficeContactEntity::getCaption)
.withProp(Fields.emailAddresses, HsOfficeContactEntity::getEmailAddresses); .withProp(Fields.emailAddresses, HsOfficeContactEntity::getEmailAddresses);
@Id @Id
@ -49,8 +49,8 @@ public class HsOfficeContactEntity implements Stringifyable, RbacObject {
@Version @Version
private int version; private int version;
@Column(name = "label") // TODO.impl: rename to caption @Column(name = "caption")
private String label; private String caption;
@Column(name = "postaladdress") @Column(name = "postaladdress")
private String postalAddress; // multiline free-format text private String postalAddress; // multiline free-format text
@ -96,13 +96,13 @@ public class HsOfficeContactEntity implements Stringifyable, RbacObject {
@Override @Override
public String toShortString() { public String toShortString() {
return label; return caption;
} }
public static RbacView rbac() { public static RbacView rbac() {
return rbacViewFor("contact", HsOfficeContactEntity.class) return rbacViewFor("contact", HsOfficeContactEntity.class)
.withIdentityView(SQL.projection("label")) .withIdentityView(SQL.projection("caption"))
.withUpdatableColumns("label", "postalAddress", "emailAddresses", "phoneNumbers") .withUpdatableColumns("caption", "postalAddress", "emailAddresses", "phoneNumbers")
.createRole(OWNER, (with) -> { .createRole(OWNER, (with) -> {
with.owningUser(CREATOR); with.owningUser(CREATOR);
with.incomingSuperRole(GLOBAL, ADMIN); with.incomingSuperRole(GLOBAL, ADMIN);

View File

@ -17,7 +17,7 @@ class HsOfficeContactEntityPatcher implements EntityPatcher<HsOfficeContactPatch
@Override @Override
public void apply(final HsOfficeContactPatchResource resource) { public void apply(final HsOfficeContactPatchResource resource) {
OptionalFromJson.of(resource.getLabel()).ifPresent(entity::setLabel); OptionalFromJson.of(resource.getCaption()).ifPresent(entity::setCaption);
OptionalFromJson.of(resource.getPostalAddress()).ifPresent(entity::setPostalAddress); OptionalFromJson.of(resource.getPostalAddress()).ifPresent(entity::setPostalAddress);
Optional.ofNullable(resource.getEmailAddresses()) Optional.ofNullable(resource.getEmailAddresses())
.ifPresent(r -> entity.getEmailAddresses().patch(KeyValueMap.from(resource.getEmailAddresses()))); .ifPresent(r -> entity.getEmailAddresses().patch(KeyValueMap.from(resource.getEmailAddresses())));

View File

@ -13,10 +13,10 @@ public interface HsOfficeContactRepository extends Repository<HsOfficeContactEnt
@Query(""" @Query("""
SELECT c FROM HsOfficeContactEntity c SELECT c FROM HsOfficeContactEntity c
WHERE :label is null WHERE :caption is null
OR c.label like concat(cast(:label as text), '%') OR c.caption like concat(cast(:caption as text), '%')
""") """)
List<HsOfficeContactEntity> findContactByOptionalLabelLike(String label); List<HsOfficeContactEntity> findContactByOptionalCaptionLike(String caption);
HsOfficeContactEntity save(final HsOfficeContactEntity entity); HsOfficeContactEntity save(final HsOfficeContactEntity entity);

View File

@ -41,7 +41,7 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
OR person.tradeName like concat(cast(:name as text), '%') OR person.tradeName like concat(cast(:name as text), '%')
OR person.familyName like concat(cast(:name as text), '%') OR person.familyName like concat(cast(:name as text), '%')
OR person.givenName like concat(cast(:name as text), '%') OR person.givenName like concat(cast(:name as text), '%')
OR contact.label like concat(cast(:name as text), '%') OR contact.caption like concat(cast(:name as text), '%')
""") """)
List<HsOfficeDebitorEntity> findDebitorByOptionalNameLike(String name); List<HsOfficeDebitorEntity> findDebitorByOptionalNameLike(String name);

View File

@ -20,7 +20,7 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
JOIN HsOfficePersonEntity person ON person.uuid = rel.holder.uuid JOIN HsOfficePersonEntity person ON person.uuid = rel.holder.uuid
WHERE :name is null WHERE :name is null
OR partner.details.birthName like concat(cast(:name as text), '%') OR partner.details.birthName like concat(cast(:name as text), '%')
OR contact.label like concat(cast(:name as text), '%') OR contact.caption like concat(cast(:name as text), '%')
OR person.tradeName like concat(cast(:name as text), '%') OR person.tradeName like concat(cast(:name as text), '%')
OR person.givenName like concat(cast(:name as text), '%') OR person.givenName like concat(cast(:name as text), '%')
OR person.familyName like concat(cast(:name as text), '%') OR person.familyName like concat(cast(:name as text), '%')

View File

@ -33,10 +33,10 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
public ResponseEntity<List<HsOfficePersonResource>> listPersons( public ResponseEntity<List<HsOfficePersonResource>> listPersons(
final String currentUser, final String currentUser,
final String assumedRoles, final String assumedRoles,
final String label) { final String caption) {
context.define(currentUser, assumedRoles); context.define(currentUser, assumedRoles);
final var entities = personRepo.findPersonByOptionalNameLike(label); final var entities = personRepo.findPersonByOptionalNameLike(caption);
final var resources = mapper.mapList(entities, HsOfficePersonResource.class); final var resources = mapper.mapList(entities, HsOfficePersonResource.class);
return ResponseEntity.ok(resources); return ResponseEntity.ok(resources);

View File

@ -9,7 +9,7 @@ components:
uuid: uuid:
type: string type: string
format: uuid format: uuid
label: caption:
type: string type: string
postalAddress: postalAddress:
type: string type: string
@ -21,7 +21,7 @@ components:
HsOfficeContactInsert: HsOfficeContactInsert:
type: object type: object
properties: properties:
label: caption:
type: string type: string
postalAddress: postalAddress:
type: string type: string
@ -30,12 +30,12 @@ components:
phoneNumbers: phoneNumbers:
$ref: '#/components/schemas/HsOfficeContactPhoneNumbers' $ref: '#/components/schemas/HsOfficeContactPhoneNumbers'
required: required:
- label - caption
HsOfficeContactPatch: HsOfficeContactPatch:
type: object type: object
properties: properties:
label: caption:
type: string type: string
nullable: true nullable: true
postalAddress: postalAddress:

View File

@ -12,7 +12,7 @@ get:
required: false required: false
schema: schema:
type: string type: string
description: Prefix of label to filter the results. description: Prefix of caption to filter the results.
responses: responses:
"200": "200":
description: OK description: OK

View File

@ -12,7 +12,7 @@ get:
required: false required: false
schema: schema:
type: string type: string
description: Prefix of label to filter the results. description: Prefix of caption to filter the results.
responses: responses:
"200": "200":
description: OK description: OK

View File

@ -8,7 +8,7 @@ create table if not exists hs_office_contact
( (
uuid uuid unique references RbacObject (uuid) initially deferred, uuid uuid unique references RbacObject (uuid) initially deferred,
version int not null default 0, version int not null default 0,
label varchar(128) not null, caption varchar(128) not null,
postalAddress text, postalAddress text,
emailAddresses jsonb not null, emailAddresses jsonb not null,
phoneNumbers jsonb not null phoneNumbers jsonb not null

View File

@ -82,7 +82,7 @@ execute procedure insertTriggerForHsOfficeContact_tf();
call generateRbacIdentityViewFromProjection('hs_office_contact', call generateRbacIdentityViewFromProjection('hs_office_contact',
$idName$ $idName$
label caption
$idName$); $idName$);
--// --//
@ -92,10 +92,10 @@ call generateRbacIdentityViewFromProjection('hs_office_contact',
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
call generateRbacRestrictedView('hs_office_contact', call generateRbacRestrictedView('hs_office_contact',
$orderBy$ $orderBy$
label caption
$orderBy$, $orderBy$,
$updates$ $updates$
label = new.label, caption = new.caption,
postalAddress = new.postalAddress, postalAddress = new.postalAddress,
emailAddresses = new.emailAddresses, emailAddresses = new.emailAddresses,
phoneNumbers = new.phoneNumbers phoneNumbers = new.phoneNumbers

View File

@ -8,28 +8,28 @@
/* /*
Creates a single contact test record. Creates a single contact test record.
*/ */
create or replace procedure createHsOfficeContactTestData(contLabel varchar) create or replace procedure createHsOfficeContactTestData(contCaption varchar)
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar; currentTask varchar;
postalAddr varchar; postalAddr varchar;
emailAddr varchar; emailAddr varchar;
begin begin
currentTask = 'creating contact test-data ' || contLabel; currentTask = 'creating contact test-data ' || contCaption;
execute format('set local hsadminng.currentTask to %L', currentTask); execute format('set local hsadminng.currentTask to %L', currentTask);
emailAddr = 'contact-admin@' || cleanIdentifier(contLabel) || '.example.com'; emailAddr = 'contact-admin@' || cleanIdentifier(contCaption) || '.example.com';
call defineContext(currentTask); call defineContext(currentTask);
perform createRbacUser(emailAddr); perform createRbacUser(emailAddr);
call defineContext(currentTask, null, emailAddr); call defineContext(currentTask, null, emailAddr);
postalAddr := E'Vorname Nachname\nStraße Hnr\nPLZ Stadt'; postalAddr := E'Vorname Nachname\nStraße Hnr\nPLZ Stadt';
raise notice 'creating test contact: %', contLabel; raise notice 'creating test contact: %', contCaption;
insert insert
into hs_office_contact (label, postaladdress, emailaddresses, phonenumbers) into hs_office_contact (caption, postaladdress, emailaddresses, phonenumbers)
values ( values (
contLabel, contCaption,
postalAddr, postalAddr,
('{ "main": "' || emailAddr || '" }')::jsonb, ('{ "main": "' || emailAddr || '" }')::jsonb,
('{ "phone_office": "+49 123 1234567" }')::jsonb ('{ "phone_office": "+49 123 1234567" }')::jsonb

View File

@ -12,7 +12,7 @@ create or replace procedure createHsOfficeRelationTestData(
holderPersonName varchar, holderPersonName varchar,
relationType HsOfficeRelationType, relationType HsOfficeRelationType,
anchorPersonName varchar, anchorPersonName varchar,
contactLabel varchar, contactCaption varchar,
mark varchar default null) mark varchar default null)
language plpgsql as $$ language plpgsql as $$
declare declare
@ -44,9 +44,9 @@ begin
raise exception 'holderPerson "%" not found', holderPersonName; raise exception 'holderPerson "%" not found', holderPersonName;
end if; end if;
select c.* into contact from hs_office_contact c where c.label = contactLabel; select c.* into contact from hs_office_contact c where c.caption = contactCaption;
if contact is null then if contact is null then
raise exception 'contact "%" not found', contactLabel; raise exception 'contact "%" not found', contactCaption;
end if; end if;
raise notice 'creating test relation: %', idName; raise notice 'creating test relation: %', idName;
@ -74,7 +74,7 @@ begin
for t in startCount..endCount for t in startCount..endCount
loop loop
select p.* from hs_office_person p where tradeName = intToVarChar(t, 4) into person; select p.* from hs_office_person p where tradeName = intToVarChar(t, 4) into person;
select c.* from hs_office_contact c where c.label = intToVarChar(t, 4) || '#' || t into contact; select c.* from hs_office_contact c where c.caption = intToVarChar(t, 4) || '#' || t into contact;
call createHsOfficeRelationTestData(person.uuid, contact.uuid, 'REPRESENTATIVE'); call createHsOfficeRelationTestData(person.uuid, contact.uuid, 'REPRESENTATIVE');
commit; commit;

View File

@ -12,7 +12,7 @@ create or replace procedure createHsOfficePartnerTestData(
mandantTradeName varchar, mandantTradeName varchar,
newPartnerNumber numeric(5), newPartnerNumber numeric(5),
partnerPersonName varchar, partnerPersonName varchar,
contactLabel varchar ) contactCaption varchar )
language plpgsql as $$ language plpgsql as $$
declare declare
currentTask varchar; currentTask varchar;
@ -22,7 +22,7 @@ declare
relatedPerson hs_office_person; relatedPerson hs_office_person;
relatedDetailsUuid uuid; relatedDetailsUuid uuid;
begin begin
idName := cleanIdentifier( partnerPersonName|| '-' || contactLabel); idName := cleanIdentifier( partnerPersonName|| '-' || contactCaption);
currentTask := 'creating partner test-data ' || idName; currentTask := 'creating partner test-data ' || idName;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN'); call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask); execute format('set local hsadminng.currentTask to %L', currentTask);

View File

@ -11,7 +11,7 @@
create or replace procedure createHsOfficeDebitorTestData( create or replace procedure createHsOfficeDebitorTestData(
withDebitorNumberSuffix numeric(5), withDebitorNumberSuffix numeric(5),
forPartnerPersonName varchar, forPartnerPersonName varchar,
forBillingContactLabel varchar, forBillingContactCaption varchar,
withDefaultPrefix varchar withDefaultPrefix varchar
) )
language plpgsql as $$ language plpgsql as $$
@ -21,7 +21,7 @@ declare
relatedDebitorRelUuid uuid; relatedDebitorRelUuid uuid;
relatedBankAccountUuid uuid; relatedBankAccountUuid uuid;
begin begin
idName := cleanIdentifier( forPartnerPersonName|| '-' || forBillingContactLabel); idName := cleanIdentifier( forPartnerPersonName|| '-' || forBillingContactCaption);
currentTask := 'creating debitor test-data ' || idName; currentTask := 'creating debitor test-data ' || idName;
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN'); call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global:ADMIN');
execute format('set local hsadminng.currentTask to %L', currentTask); execute format('set local hsadminng.currentTask to %L', currentTask);

View File

@ -297,17 +297,17 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC
void exactlyTheseBankAccountsAreReturned( void exactlyTheseBankAccountsAreReturned(
final List<HsOfficeBankAccountEntity> actualResult, final List<HsOfficeBankAccountEntity> actualResult,
final String... bankaccountLabels) { final String... bankaccountCaptions) {
assertThat(actualResult) assertThat(actualResult)
.extracting(HsOfficeBankAccountEntity::getHolder) .extracting(HsOfficeBankAccountEntity::getHolder)
.containsExactlyInAnyOrder(bankaccountLabels); .containsExactlyInAnyOrder(bankaccountCaptions);
} }
void allTheseBankAccountsAreReturned( void allTheseBankAccountsAreReturned(
final List<HsOfficeBankAccountEntity> actualResult, final List<HsOfficeBankAccountEntity> actualResult,
final String... bankaccountLabels) { final String... bankaccountCaptions) {
assertThat(actualResult) assertThat(actualResult)
.extracting(HsOfficeBankAccountEntity::getHolder) .extracting(HsOfficeBankAccountEntity::getHolder)
.contains(bankaccountLabels); .contains(bankaccountCaptions);
} }
} }

View File

@ -70,18 +70,18 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.contentType("application/json") .contentType("application/json")
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
[ [
{ "label": "first contact" }, { "caption": "first contact" },
{ "label": "second contact" }, { "caption": "second contact" },
{ "label": "third contact" }, { "caption": "third contact" },
{ "label": "fourth contact" }, { "caption": "fourth contact" },
{ "label": "fifth contact" }, { "caption": "fifth contact" },
{ "label": "sixth contact" }, { "caption": "sixth contact" },
{ "label": "seventh contact" }, { "caption": "seventh contact" },
{ "label": "eighth contact" }, { "caption": "eighth contact" },
{ "label": "ninth contact" }, { "caption": "ninth contact" },
{ "label": "tenth contact" }, { "caption": "tenth contact" },
{ "label": "eleventh contact" }, { "caption": "eleventh contact" },
{ "label": "twelfth contact" } { "caption": "twelfth contact" }
] ]
""" """
)); ));
@ -103,7 +103,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body(""" .body("""
{ {
"label": "Temp Contact", "caption": "Temp Contact",
"emailAddresses": { "emailAddresses": {
"main": "test@example.org" "main": "test@example.org"
} }
@ -116,7 +116,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.statusCode(201) .statusCode(201)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("label", is("Temp Contact")) .body("caption", is("Temp Contact"))
.body("emailAddresses", is(Map.of("main", "test@example.org"))) .body("emailAddresses", is(Map.of("main", "test@example.org")))
.header("Location", startsWith("http://localhost")) .header("Location", startsWith("http://localhost"))
.extract().header("Location"); // @formatter:on .extract().header("Location"); // @formatter:on
@ -134,7 +134,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
@Test @Test
void globalAdmin_withoutAssumedRole_canGetArbitraryContact() { void globalAdmin_withoutAssumedRole_canGetArbitraryContact() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenContactUuid = contactRepo.findContactByOptionalLabelLike("first").get(0).getUuid(); final var givenContactUuid = contactRepo.findContactByOptionalCaptionLike("first").get(0).getUuid();
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -147,7 +147,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.contentType("application/json") .contentType("application/json")
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
{ {
"label": "first contact" "caption": "first contact"
} }
""")); // @formatter:on """)); // @formatter:on
} }
@ -155,7 +155,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
@Test @Test
void normalUser_canNotGetUnrelatedContact() { void normalUser_canNotGetUnrelatedContact() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenContactUuid = contactRepo.findContactByOptionalLabelLike("first").get(0).getUuid(); final var givenContactUuid = contactRepo.findContactByOptionalCaptionLike("first").get(0).getUuid();
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -170,7 +170,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
@Test @Test
void contactAdminUser_canGetRelatedContact() { void contactAdminUser_canGetRelatedContact() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenContactUuid = contactRepo.findContactByOptionalLabelLike("first").get(0).getUuid(); final var givenContactUuid = contactRepo.findContactByOptionalCaptionLike("first").get(0).getUuid();
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -183,7 +183,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.contentType("application/json") .contentType("application/json")
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
{ {
"label": "first contact", "caption": "first contact",
"emailAddresses": { "emailAddresses": {
"main": "contact-admin@firstcontact.example.com" "main": "contact-admin@firstcontact.example.com"
}, },
@ -210,7 +210,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body(""" .body("""
{ {
"label": "Temp patched contact", "caption": "Temp patched contact",
"emailAddresses": { "emailAddresses": {
"main": "patched@example.org" "main": "patched@example.org"
}, },
@ -227,7 +227,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.statusCode(200) .statusCode(200)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("label", is("Temp patched contact")) .body("caption", is("Temp patched contact"))
.body("emailAddresses", is(Map.of("main", "patched@example.org"))) .body("emailAddresses", is(Map.of("main", "patched@example.org")))
.body("postalAddress", is("Patched Address")) .body("postalAddress", is("Patched Address"))
.body("phoneNumbers", is(Map.of("phone_office", "+01 100 123456"))); .body("phoneNumbers", is(Map.of("phone_office", "+01 100 123456")));
@ -237,7 +237,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
assertThat(contactRepo.findByUuid(givenContact.getUuid())).isPresent().get() assertThat(contactRepo.findByUuid(givenContact.getUuid())).isPresent().get()
.matches(person -> { .matches(person -> {
assertThat(person.getLabel()).isEqualTo("Temp patched contact"); assertThat(person.getCaption()).isEqualTo("Temp patched contact");
assertThat(person.getEmailAddresses()).containsExactlyEntriesOf(Map.of("main", "patched@example.org")); assertThat(person.getEmailAddresses()).containsExactlyEntriesOf(Map.of("main", "patched@example.org"));
assertThat(person.getPostalAddress()).isEqualTo("Patched Address"); assertThat(person.getPostalAddress()).isEqualTo("Patched Address");
assertThat(person.getPhoneNumbers()).containsExactlyEntriesOf(Map.of("phone_office", "+01 100 123456")); assertThat(person.getPhoneNumbers()).containsExactlyEntriesOf(Map.of("phone_office", "+01 100 123456"));
@ -272,7 +272,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.statusCode(200) .statusCode(200)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("label", is(givenContact.getLabel())) .body("caption", is(givenContact.getCaption()))
.body("emailAddresses", is(Map.of("main", "patched@example.org"))) .body("emailAddresses", is(Map.of("main", "patched@example.org")))
.body("postalAddress", is(givenContact.getPostalAddress())) .body("postalAddress", is(givenContact.getPostalAddress()))
.body("phoneNumbers", is(Map.of("phone_office", "+01 100 123456"))); .body("phoneNumbers", is(Map.of("phone_office", "+01 100 123456")));
@ -281,7 +281,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
// finally, the contact is actually updated // finally, the contact is actually updated
assertThat(contactRepo.findByUuid(givenContact.getUuid())).isPresent().get() assertThat(contactRepo.findByUuid(givenContact.getUuid())).isPresent().get()
.matches(person -> { .matches(person -> {
assertThat(person.getLabel()).isEqualTo(givenContact.getLabel()); assertThat(person.getCaption()).isEqualTo(givenContact.getCaption());
assertThat(person.getEmailAddresses()).containsExactlyEntriesOf(Map.of("main", "patched@example.org")); assertThat(person.getEmailAddresses()).containsExactlyEntriesOf(Map.of("main", "patched@example.org"));
assertThat(person.getPostalAddress()).isEqualTo(givenContact.getPostalAddress()); assertThat(person.getPostalAddress()).isEqualTo(givenContact.getPostalAddress());
assertThat(person.getPhoneNumbers()).containsExactlyEntriesOf(Map.of("phone_office", "+01 100 123456")); assertThat(person.getPhoneNumbers()).containsExactlyEntriesOf(Map.of("phone_office", "+01 100 123456"));
@ -354,7 +354,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define(creatingUser); context.define(creatingUser);
final var newContact = HsOfficeContactEntity.builder() final var newContact = HsOfficeContactEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.label("Temp from " + Context.getCallerMethodNameFromStackFrame(1) ) .caption("Temp from " + Context.getCallerMethodNameFromStackFrame(1) )
.emailAddresses(Map.of("main", RandomStringUtils.randomAlphabetic(10) + "@example.org")) .emailAddresses(Map.of("main", RandomStringUtils.randomAlphabetic(10) + "@example.org"))
.postalAddress("Postal Address " + RandomStringUtils.randomAlphabetic(10)) .postalAddress("Postal Address " + RandomStringUtils.randomAlphabetic(10))
.phoneNumbers(Map.of("phone_office", "+01 200 " + RandomStringUtils.randomNumeric(8))) .phoneNumbers(Map.of("phone_office", "+01 200 " + RandomStringUtils.randomNumeric(8)))
@ -369,7 +369,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
void cleanup() { void cleanup() {
jpaAttempt.transacted(() -> { jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net", null); context.define("superuser-alex@hostsharing.net", null);
em.createQuery("DELETE FROM HsOfficeContactEntity c WHERE c.label LIKE 'Temp %'").executeUpdate(); em.createQuery("DELETE FROM HsOfficeContactEntity c WHERE c.caption LIKE 'Temp %'").executeUpdate();
}).assertSuccessful(); }).assertSuccessful();
} }
} }

View File

@ -45,7 +45,7 @@ class HsOfficeContactEntityPatcherUnitTest extends PatchUnitTestBase<
protected HsOfficeContactEntity newInitialEntity() { protected HsOfficeContactEntity newInitialEntity() {
final var entity = new HsOfficeContactEntity(); final var entity = new HsOfficeContactEntity();
entity.setUuid(INITIAL_CONTACT_UUID); entity.setUuid(INITIAL_CONTACT_UUID);
entity.setLabel("initial label"); entity.setCaption("initial caption");
entity.putEmailAddresses(Map.ofEntries( entity.putEmailAddresses(Map.ofEntries(
entry("main", "initial@example.org"), entry("main", "initial@example.org"),
entry("paul", "paul@example.com"), entry("paul", "paul@example.com"),
@ -72,10 +72,10 @@ class HsOfficeContactEntityPatcherUnitTest extends PatchUnitTestBase<
protected Stream<Property> propertyTestDescriptors() { protected Stream<Property> propertyTestDescriptors() {
return Stream.of( return Stream.of(
new JsonNullableProperty<>( new JsonNullableProperty<>(
"label", "caption",
HsOfficeContactPatchResource::setLabel, HsOfficeContactPatchResource::setCaption,
"patched label", "patched caption",
HsOfficeContactEntity::setLabel), HsOfficeContactEntity::setCaption),
new SimpleProperty<>( new SimpleProperty<>(
"resources", "resources",
HsOfficeContactPatchResource::setEmailAddresses, HsOfficeContactPatchResource::setEmailAddresses,

View File

@ -13,9 +13,9 @@ class HsOfficeContactEntityUnitTest {
} }
@Test @Test
void toStringReturnsLabel() { void toStringReturnsCaption() {
final var givenContact = HsOfficeContactEntity.builder().label("given label").build(); final var givenContact = HsOfficeContactEntity.builder().caption("given caption").build();
assertThat("" + givenContact).isEqualTo("contact(label='given label')"); assertThat("" + givenContact).isEqualTo("contact(caption='given caption')");
} }
} }

View File

@ -135,7 +135,7 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTestWithClean
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
// when // when
final var result = contactRepo.findContactByOptionalLabelLike(null); final var result = contactRepo.findContactByOptionalCaptionLike(null);
// then // then
allTheseContactsAreReturned(result, "first contact", "second contact", "third contact"); allTheseContactsAreReturned(result, "first contact", "second contact", "third contact");
@ -148,15 +148,15 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTestWithClean
// when: // when:
context("selfregistered-user-drew@hostsharing.org"); context("selfregistered-user-drew@hostsharing.org");
final var result = contactRepo.findContactByOptionalLabelLike(null); final var result = contactRepo.findContactByOptionalCaptionLike(null);
// then: // then:
exactlyTheseContactsAreReturned(result, givenContact.getLabel()); exactlyTheseContactsAreReturned(result, givenContact.getCaption());
} }
} }
@Nested @Nested
class FindByLabelLike { class FindByCaptionLike {
@Test @Test
public void globalAdmin_withoutAssumedRole_canViewAllContacts() { public void globalAdmin_withoutAssumedRole_canViewAllContacts() {
@ -164,7 +164,7 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTestWithClean
context("superuser-alex@hostsharing.net", null); context("superuser-alex@hostsharing.net", null);
// when // when
final var result = contactRepo.findContactByOptionalLabelLike("second"); final var result = contactRepo.findContactByOptionalCaptionLike("second");
// then // then
exactlyTheseContactsAreReturned(result, "second contact"); exactlyTheseContactsAreReturned(result, "second contact");
@ -177,10 +177,10 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTestWithClean
// when: // when:
context("selfregistered-user-drew@hostsharing.org"); context("selfregistered-user-drew@hostsharing.org");
final var result = contactRepo.findContactByOptionalLabelLike(givenContact.getLabel()); final var result = contactRepo.findContactByOptionalCaptionLike(givenContact.getCaption());
// then: // then:
exactlyTheseContactsAreReturned(result, givenContact.getLabel()); exactlyTheseContactsAreReturned(result, givenContact.getCaption());
} }
} }
@ -203,7 +203,7 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTestWithClean
result.assertSuccessful(); result.assertSuccessful();
assertThat(jpaAttempt.transacted(() -> { assertThat(jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net", null); context("superuser-alex@hostsharing.net", null);
return contactRepo.findContactByOptionalLabelLike(givenContact.getLabel()); return contactRepo.findContactByOptionalCaptionLike(givenContact.getCaption());
}).assertSuccessful().returnedValue()).hasSize(0); }).assertSuccessful().returnedValue()).hasSize(0);
} }
@ -222,7 +222,7 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTestWithClean
result.assertSuccessful(); result.assertSuccessful();
assertThat(jpaAttempt.transacted(() -> { assertThat(jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net", null); context("superuser-alex@hostsharing.net", null);
return contactRepo.findContactByOptionalLabelLike(givenContact.getLabel()); return contactRepo.findContactByOptionalCaptionLike(givenContact.getCaption());
}).assertSuccessful().returnedValue()).hasSize(0); }).assertSuccessful().returnedValue()).hasSize(0);
} }
@ -287,15 +287,15 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTestWithClean
"some-temporary-contact" + random + "@example.com")); "some-temporary-contact" + random + "@example.com"));
} }
void exactlyTheseContactsAreReturned(final List<HsOfficeContactEntity> actualResult, final String... contactLabels) { void exactlyTheseContactsAreReturned(final List<HsOfficeContactEntity> actualResult, final String... contactCaptions) {
assertThat(actualResult) assertThat(actualResult)
.extracting(HsOfficeContactEntity::getLabel) .extracting(HsOfficeContactEntity::getCaption)
.containsExactlyInAnyOrder(contactLabels); .containsExactlyInAnyOrder(contactCaptions);
} }
void allTheseContactsAreReturned(final List<HsOfficeContactEntity> actualResult, final String... contactLabels) { void allTheseContactsAreReturned(final List<HsOfficeContactEntity> actualResult, final String... contactCaptions) {
assertThat(actualResult) assertThat(actualResult)
.extracting(HsOfficeContactEntity::getLabel) .extracting(HsOfficeContactEntity::getCaption)
.contains(contactLabels); .contains(contactCaptions);
} }
} }

View File

@ -6,10 +6,10 @@ public class TestHsOfficeContact {
public static final HsOfficeContactEntity TEST_CONTACT = hsOfficeContact("some contact", "some-contact@example.com"); public static final HsOfficeContactEntity TEST_CONTACT = hsOfficeContact("some contact", "some-contact@example.com");
static public HsOfficeContactEntity hsOfficeContact(final String label, final String emailAddr) { static public HsOfficeContactEntity hsOfficeContact(final String caption, final String emailAddr) {
return HsOfficeContactEntity.builder() return HsOfficeContactEntity.builder()
.label(label) .caption(caption)
.postalAddress("address of " + label) .postalAddress("address of " + caption)
.emailAddresses(Map.of("main", emailAddr)) .emailAddresses(Map.of("main", emailAddr))
.build(); .build();
} }

View File

@ -106,7 +106,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"type": "DEBITOR", "type": "DEBITOR",
"mark": null, "mark": null,
"contact": { "contact": {
"label": "first contact", "caption": "first contact",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" }, "emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "phone_office": "+49 123 1234567" } "phoneNumbers": { "phone_office": "+49 123 1234567" }
} }
@ -131,7 +131,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"type": "PARTNER", "type": "PARTNER",
"mark": null, "mark": null,
"contact": { "contact": {
"label": "first contact", "caption": "first contact",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" }, "emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "phone_office": "+49 123 1234567" } "phoneNumbers": { "phone_office": "+49 123 1234567" }
} }
@ -248,7 +248,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"debitorNumber": 1000212, "debitorNumber": 1000212,
"partner": { "partnerNumber": 10002 }, "partner": { "partnerNumber": 10002 },
"debitorRel": { "debitorRel": {
"contact": { "label": "second contact" } "contact": { "caption": "second contact" }
}, },
"vatId": null, "vatId": null,
"vatCountryCode": null, "vatCountryCode": null,
@ -268,7 +268,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").get(0);
final var givenBankAccount = bankAccountRepo.findByOptionalHolderLike("Fourth").get(0); final var givenBankAccount = bankAccountRepo.findByOptionalHolderLike("Fourth").get(0);
final var givenBillingPerson = personRepo.findPersonByOptionalNameLike("Fourth").get(0); final var givenBillingPerson = personRepo.findPersonByOptionalNameLike("Fourth").get(0);
@ -308,7 +308,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("vatId", is("VAT123456")) .body("vatId", is("VAT123456"))
.body("defaultPrefix", is("for")) .body("defaultPrefix", is("for"))
.body("debitorRel.contact.label", is(givenContact.getLabel())) .body("debitorRel.contact.caption", is(givenContact.getCaption()))
.body("debitorRel.holder.tradeName", is(givenBillingPerson.getTradeName())) .body("debitorRel.holder.tradeName", is(givenBillingPerson.getTradeName()))
.body("refundBankAccount.holder", is(givenBankAccount.getHolder())) .body("refundBankAccount.holder", is(givenBankAccount.getHolder()))
.header("Location", startsWith("http://localhost")) .header("Location", startsWith("http://localhost"))
@ -325,7 +325,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -356,7 +356,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
.statusCode(201) .statusCode(201)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("debitorRel.contact.label", is(givenContact.getLabel())) .body("debitorRel.contact.caption", is(givenContact.getCaption()))
.body("partner.partnerRel.holder.tradeName", is(givenPartner.getPartnerRel().getHolder().getTradeName())) .body("partner.partnerRel.holder.tradeName", is(givenPartner.getPartnerRel().getHolder().getTradeName()))
.body("vatId", equalTo(null)) .body("vatId", equalTo(null))
.body("vatCountryCode", equalTo(null)) .body("vatCountryCode", equalTo(null))
@ -414,7 +414,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitorRelUuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); final var givenDebitorRelUuid = UUID.fromString("00000000-0000-0000-0000-000000000000");
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -463,7 +463,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"holder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"}, "holder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"},
"type": "DEBITOR", "type": "DEBITOR",
"contact": { "contact": {
"label": "first contact", "caption": "first contact",
"postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt", "postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" }, "emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "phone_office": "+49 123 1234567" } "phoneNumbers": { "phone_office": "+49 123 1234567" }
@ -479,7 +479,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"type": "PARTNER", "type": "PARTNER",
"mark": null, "mark": null,
"contact": { "contact": {
"label": "first contact", "caption": "first contact",
"postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt", "postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" }, "emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "phone_office": "+49 123 1234567" } "phoneNumbers": { "phone_office": "+49 123 1234567" }
@ -536,7 +536,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
{ {
"debitorNumber": 1000111, "debitorNumber": 1000111,
"partner": { "partnerNumber": 10001 }, "partner": { "partnerNumber": 10001 },
"debitorRel": { "contact": { "label": "first contact" } }, "debitorRel": { "contact": { "caption": "first contact" } },
"refundBankAccount": null "refundBankAccount": null
} }
""")); // @formatter:on """)); // @formatter:on
@ -551,7 +551,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = givenSomeTemporaryDebitor(); final var givenDebitor = givenSomeTemporaryDebitor();
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -579,7 +579,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"holder": { "tradeName": "Fourth eG" }, "holder": { "tradeName": "Fourth eG" },
"type": "DEBITOR", "type": "DEBITOR",
"mark": null, "mark": null,
"contact": { "label": "fourth contact" } "contact": { "caption": "fourth contact" }
}, },
"debitorNumber": 10004${debitorNumberSuffix}, "debitorNumber": 10004${debitorNumberSuffix},
"debitorNumberSuffix": ${debitorNumberSuffix}, "debitorNumberSuffix": ${debitorNumberSuffix},
@ -590,7 +590,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"holder": { "tradeName": "Fourth eG" }, "holder": { "tradeName": "Fourth eG" },
"type": "PARTNER", "type": "PARTNER",
"mark": null, "mark": null,
"contact": { "label": "fourth contact" } "contact": { "caption": "fourth contact" }
}, },
"details": { "details": {
"registrationOffice": "Hamburg", "registrationOffice": "Hamburg",
@ -619,7 +619,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
.matches(debitor -> { .matches(debitor -> {
assertThat(debitor.getDebitorRel().getHolder().getTradeName()) assertThat(debitor.getDebitorRel().getHolder().getTradeName())
.isEqualTo(givenDebitor.getDebitorRel().getHolder().getTradeName()); .isEqualTo(givenDebitor.getDebitorRel().getHolder().getTradeName());
assertThat(debitor.getDebitorRel().getContact().getLabel()).isEqualTo("fourth contact"); assertThat(debitor.getDebitorRel().getContact().getCaption()).isEqualTo("fourth contact");
assertThat(debitor.getVatId()).isEqualTo("VAT222222"); assertThat(debitor.getVatId()).isEqualTo("VAT222222");
assertThat(debitor.getVatCountryCode()).isEqualTo("AA"); assertThat(debitor.getVatCountryCode()).isEqualTo("AA");
assertThat(debitor.isVatBusiness()).isEqualTo(true); assertThat(debitor.isVatBusiness()).isEqualTo(true);
@ -680,7 +680,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
void contactAdminUser_canNotDeleteRelatedDebitor() { void contactAdminUser_canNotDeleteRelatedDebitor() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = givenSomeTemporaryDebitor(); final var givenDebitor = givenSomeTemporaryDebitor();
assertThat(givenDebitor.getDebitorRel().getContact().getLabel()).isEqualTo("fourth contact"); assertThat(givenDebitor.getDebitorRel().getContact().getCaption()).isEqualTo("fourth contact");
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -699,7 +699,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
void normalUser_canNotDeleteUnrelatedDebitor() { void normalUser_canNotDeleteUnrelatedDebitor() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = givenSomeTemporaryDebitor(); final var givenDebitor = givenSomeTemporaryDebitor();
assertThat(givenDebitor.getDebitorRel().getContact().getLabel()).isEqualTo("fourth contact"); assertThat(givenDebitor.getDebitorRel().getContact().getCaption()).isEqualTo("fourth contact");
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -719,7 +719,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
return jpaAttempt.transacted(() -> { return jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
final var newDebitor = HsOfficeDebitorEntity.builder() final var newDebitor = HsOfficeDebitorEntity.builder()
.debitorNumberSuffix(nextDebitorSuffix()) .debitorNumberSuffix(nextDebitorSuffix())
.billable(true) .billable(true)

View File

@ -20,7 +20,7 @@ class HsOfficeDebitorEntityUnitTest {
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some billing trade name") .tradeName("some billing trade name")
.build()) .build())
.contact(HsOfficeContactEntity.builder().label("some label").build()) .contact(HsOfficeContactEntity.builder().caption("some caption").build())
.build(); .build();
@Test @Test

View File

@ -84,7 +84,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
final var count = debitorRepo.count(); final var count = debitorRepo.count();
final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First GmbH")); final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First GmbH"));
final var givenContact = one(contactRepo.findContactByOptionalLabelLike("first contact")); final var givenContact = one(contactRepo.findContactByOptionalCaptionLike("first contact"));
// when // when
final var result = attempt(em, () -> { final var result = attempt(em, () -> {
@ -116,7 +116,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
// given // given
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First GmbH")); final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First GmbH"));
final var givenContact = one(contactRepo.findContactByOptionalLabelLike("first contact")); final var givenContact = one(contactRepo.findContactByOptionalCaptionLike("first contact"));
// when // when
final var result = attempt(em, () -> { final var result = attempt(em, () -> {
@ -154,7 +154,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
attempt(em, () -> { attempt(em, () -> {
final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First GmbH")); final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First GmbH"));
final var givenDebitorPerson = one(personRepo.findPersonByOptionalNameLike("Fourth eG")); final var givenDebitorPerson = one(personRepo.findPersonByOptionalNameLike("Fourth eG"));
final var givenContact = one(contactRepo.findContactByOptionalLabelLike("fourth contact")); final var givenContact = one(contactRepo.findContactByOptionalCaptionLike("fourth contact"));
final var newDebitor = HsOfficeDebitorEntity.builder() final var newDebitor = HsOfficeDebitorEntity.builder()
.debitorNumberSuffix("22") .debitorNumberSuffix("22")
.debitorRel(HsOfficeRelationEntity.builder() .debitorRel(HsOfficeRelationEntity.builder()
@ -320,7 +320,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
"hs_office_relation#FourtheG-with-DEBITOR-FourtheG:ADMIN", true); "hs_office_relation#FourtheG-with-DEBITOR-FourtheG:ADMIN", true);
final var givenNewPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First")); final var givenNewPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First"));
final var givenNewBillingPerson = one(personRepo.findPersonByOptionalNameLike("Firby")); final var givenNewBillingPerson = one(personRepo.findPersonByOptionalNameLike("Firby"));
final var givenNewContact = one(contactRepo.findContactByOptionalLabelLike("sixth contact")); final var givenNewContact = one(contactRepo.findContactByOptionalCaptionLike("sixth contact"));
final var givenNewBankAccount = one(bankAccountRepo.findByOptionalHolderLike("first")); final var givenNewBankAccount = one(bankAccountRepo.findByOptionalHolderLike("first"));
final String givenNewVatId = "NEW-VAT-ID"; final String givenNewVatId = "NEW-VAT-ID";
final String givenNewVatCountryCode = "NC"; final String givenNewVatCountryCode = "NC";
@ -603,13 +603,13 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
private HsOfficeDebitorEntity givenSomeTemporaryDebitor( private HsOfficeDebitorEntity givenSomeTemporaryDebitor(
final String partnerName, final String partnerName,
final String contactLabel, final String contactCaption,
final String bankAccountHolder, final String bankAccountHolder,
final String defaultPrefix) { final String defaultPrefix) {
return jpaAttempt.transacted(() -> { return jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike(partnerName)); final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike(partnerName));
final var givenContact = one(contactRepo.findContactByOptionalLabelLike(contactLabel)); final var givenContact = one(contactRepo.findContactByOptionalCaptionLike(contactCaption));
final var givenBankAccount = final var givenBankAccount =
bankAccountHolder != null ? one(bankAccountRepo.findByOptionalHolderLike(bankAccountHolder)) : null; bankAccountHolder != null ? one(bankAccountRepo.findByOptionalHolderLike(bankAccountHolder)) : null;
final var newDebitor = HsOfficeDebitorEntity.builder() final var newDebitor = HsOfficeDebitorEntity.builder()

View File

@ -241,15 +241,15 @@ public class ImportOfficeData extends ContextBasedTest {
"""); """);
assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace("""
{ {
1101=contact(label='Herr Michael Mellies ', emailAddresses='{ main: mih@example.org }'), 1101=contact(caption='Herr Michael Mellies ', emailAddresses='{ main: mih@example.org }'),
1200=contact(label='JM e.K.', emailAddresses='{ main: jm-ex-partner@example.org }'), 1200=contact(caption='JM e.K.', emailAddresses='{ main: jm-ex-partner@example.org }'),
1201=contact(label='Frau Dr. Jenny Meyer-Billing , JM GmbH', emailAddresses='{ main: jm-billing@example.org }'), 1201=contact(caption='Frau Dr. Jenny Meyer-Billing , JM GmbH', emailAddresses='{ main: jm-billing@example.org }'),
1202=contact(label='Herr Andrew Meyer-Operation , JM GmbH', emailAddresses='{ main: am-operation@example.org }'), 1202=contact(caption='Herr Andrew Meyer-Operation , JM GmbH', emailAddresses='{ main: am-operation@example.org }'),
1203=contact(label='Herr Philip Meyer-Contract , JM GmbH', emailAddresses='{ main: pm-partner@example.org }'), 1203=contact(caption='Herr Philip Meyer-Contract , JM GmbH', emailAddresses='{ main: pm-partner@example.org }'),
1204=contact(label='Frau Tammy Meyer-VIP , JM GmbH', emailAddresses='{ main: tm-vip@example.org }'), 1204=contact(caption='Frau Tammy Meyer-VIP , JM GmbH', emailAddresses='{ main: tm-vip@example.org }'),
1301=contact(label='Petra Schmidt , Test PS', emailAddresses='{ main: ps@example.com }'), 1301=contact(caption='Petra Schmidt , Test PS', emailAddresses='{ main: ps@example.com }'),
1401=contact(label='Frau Frauke Fanninga ', emailAddresses='{ main: ff@example.org }'), 1401=contact(caption='Frau Frauke Fanninga ', emailAddresses='{ main: ff@example.org }'),
1501=contact(label='Frau Cecilia Camus ', emailAddresses='{ main: cc@example.org }') 1501=contact(caption='Frau Cecilia Camus ', emailAddresses='{ main: cc@example.org }')
} }
"""); """);
assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace("""
@ -427,7 +427,7 @@ public class ImportOfficeData extends ContextBasedTest {
assertThat(partnerRel).describedAs("partner " + id + " without partnerRel").isNotNull(); assertThat(partnerRel).describedAs("partner " + id + " without partnerRel").isNotNull();
if ( id != 99 ) { if ( id != 99 ) {
assertThat(partnerRel.getContact()).describedAs("partner " + id + " without partnerRel.contact").isNotNull(); assertThat(partnerRel.getContact()).describedAs("partner " + id + " without partnerRel.contact").isNotNull();
assertThat(partnerRel.getContact().getLabel()).describedAs("partner " + id + " without valid partnerRel.contact").isNotNull(); assertThat(partnerRel.getContact().getCaption()).describedAs("partner " + id + " without valid partnerRel.contact").isNotNull();
assertThat(partnerRel.getHolder()).describedAs("partner " + id + " without partnerRel.relHolder").isNotNull(); assertThat(partnerRel.getHolder()).describedAs("partner " + id + " without partnerRel.relHolder").isNotNull();
assertThat(partnerRel.getHolder().getPersonType()).describedAs("partner " + id + " without valid partnerRel.relHolder").isNotNull(); assertThat(partnerRel.getHolder().getPersonType()).describedAs("partner " + id + " without valid partnerRel.relHolder").isNotNull();
} }
@ -460,7 +460,7 @@ public class ImportOfficeData extends ContextBasedTest {
// avoid a error when persisting the deliberately invalid partner entry #99 // avoid a error when persisting the deliberately invalid partner entry #99
final var idsToRemove = new HashSet<Integer>(); final var idsToRemove = new HashSet<Integer>();
relations.forEach( (id, r) -> { relations.forEach( (id, r) -> {
if (r.getContact() == null || r.getContact().getLabel() == null || if (r.getContact() == null || r.getContact().getCaption() == null ||
r.getHolder() == null || r.getHolder().getPersonType() == null ) { r.getHolder() == null || r.getHolder().getPersonType() == null ) {
idsToRemove.add(id); idsToRemove.add(id);
} }
@ -483,7 +483,7 @@ public class ImportOfficeData extends ContextBasedTest {
final var partnerRole = r.getPartnerRel(); final var partnerRole = r.getPartnerRel();
// such a record is in test data to test error messages // such a record is in test data to test error messages
if (partnerRole.getContact() == null || partnerRole.getContact().getLabel() == null || if (partnerRole.getContact() == null || partnerRole.getContact().getCaption() == null ||
partnerRole.getHolder() == null | partnerRole.getHolder().getPersonType() == null ) { partnerRole.getHolder() == null | partnerRole.getHolder().getPersonType() == null ) {
idsToRemove.add(id); idsToRemove.add(id);
} }
@ -504,7 +504,7 @@ public class ImportOfficeData extends ContextBasedTest {
final var idsToRemove = new HashSet<Integer>(); final var idsToRemove = new HashSet<Integer>();
debitors.forEach( (id, d) -> { debitors.forEach( (id, d) -> {
final var debitorRel = d.getDebitorRel(); final var debitorRel = d.getDebitorRel();
if (debitorRel.getContact() == null || debitorRel.getContact().getLabel() == null || if (debitorRel.getContact() == null || debitorRel.getContact().getCaption() == null ||
debitorRel.getAnchor() == null || debitorRel.getAnchor().getPersonType() == null || debitorRel.getAnchor() == null || debitorRel.getAnchor().getPersonType() == null ||
debitorRel.getHolder() == null || debitorRel.getHolder().getPersonType() == null ) { debitorRel.getHolder() == null || debitorRel.getHolder().getPersonType() == null ) {
idsToRemove.add(id); idsToRemove.add(id);
@ -1087,7 +1087,7 @@ public class ImportOfficeData extends ContextBasedTest {
private HsOfficeContactEntity initContact(final HsOfficeContactEntity contact, final Record contactRecord) { private HsOfficeContactEntity initContact(final HsOfficeContactEntity contact, final Record contactRecord) {
contact.setLabel(toLabel( contact.setCaption(toCaption(
contactRecord.getString("salut"), contactRecord.getString("salut"),
contactRecord.getString("title"), contactRecord.getString("title"),
contactRecord.getString("first_name"), contactRecord.getString("first_name"),
@ -1166,7 +1166,7 @@ public class ImportOfficeData extends ContextBasedTest {
return result.toString(); return result.toString();
} }
private String toLabel( private String toCaption(
final String salut, final String salut,
final String title, final String title,
final String firstname, final String firstname,
@ -1188,7 +1188,7 @@ public class ImportOfficeData extends ContextBasedTest {
} }
private String toName(final String salut, final String title, final String firstname, final String lastname) { private String toName(final String salut, final String title, final String firstname, final String lastname) {
return toLabel(salut, title, firstname, lastname, null); return toCaption(salut, title, firstname, lastname, null);
} }
private Reader resourceReader(@NotNull final String resourcePath) { private Reader resourceReader(@NotNull final String resourcePath) {

View File

@ -91,7 +91,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow();
final var givenPerson = personRepo.findPersonByOptionalNameLike("Third").stream().findFirst().orElseThrow(); final var givenPerson = personRepo.findPersonByOptionalNameLike("Third").stream().findFirst().orElseThrow();
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").stream().findFirst().orElseThrow(); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").stream().findFirst().orElseThrow();
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -128,7 +128,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
"holder": { "tradeName": "Third OHG" }, "holder": { "tradeName": "Third OHG" },
"type": "PARTNER", "type": "PARTNER",
"mark": null, "mark": null,
"contact": { "label": "fourth contact" } "contact": { "caption": "fourth contact" }
}, },
"details": { "details": {
"registrationOffice": "Temp Registergericht Aurich", "registrationOffice": "Temp Registergericht Aurich",
@ -188,7 +188,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var mandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); final var mandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -248,7 +248,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
"anchor": { "tradeName": "Hostsharing eG" }, "anchor": { "tradeName": "Hostsharing eG" },
"holder": { "tradeName": "First GmbH" }, "holder": { "tradeName": "First GmbH" },
"type": "PARTNER", "type": "PARTNER",
"contact": { "label": "first contact" } "contact": { "caption": "first contact" }
}, },
"details": { "details": {
"registrationOffice": "Hamburg", "registrationOffice": "Hamburg",
@ -292,7 +292,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
{ {
"partnerRel": { "partnerRel": {
"holder": { "tradeName": "First GmbH" }, "holder": { "tradeName": "First GmbH" },
"contact": { "label": "first contact" } "contact": { "caption": "first contact" }
} }
} }
""")); // @formatter:on """)); // @formatter:on
@ -340,7 +340,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
"anchor": { "tradeName": "Hostsharing eG" }, "anchor": { "tradeName": "Hostsharing eG" },
"holder": { "tradeName": "Third OHG" }, "holder": { "tradeName": "Third OHG" },
"type": "PARTNER", "type": "PARTNER",
"contact": { "label": "third contact" } "contact": { "caption": "third contact" }
}, },
"details": { "details": {
"registrationOffice": "Temp Registergericht Aurich", "registrationOffice": "Temp Registergericht Aurich",
@ -360,7 +360,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
.matches(partner -> { .matches(partner -> {
assertThat(partner.getPartnerNumber()).isEqualTo(givenPartner.getPartnerNumber()); assertThat(partner.getPartnerNumber()).isEqualTo(givenPartner.getPartnerNumber());
assertThat(partner.getPartnerRel().getHolder().getTradeName()).isEqualTo("Third OHG"); assertThat(partner.getPartnerRel().getHolder().getTradeName()).isEqualTo("Third OHG");
assertThat(partner.getPartnerRel().getContact().getLabel()).isEqualTo("third contact"); assertThat(partner.getPartnerRel().getContact().getCaption()).isEqualTo("third contact");
assertThat(partner.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Aurich"); assertThat(partner.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Aurich");
assertThat(partner.getDetails().getRegistrationNumber()).isEqualTo("222222"); assertThat(partner.getDetails().getRegistrationNumber()).isEqualTo("222222");
assertThat(partner.getDetails().getBirthName()).isEqualTo("Maja Schmidt"); assertThat(partner.getDetails().getBirthName()).isEqualTo("Maja Schmidt");
@ -398,7 +398,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get() assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get()
.matches(partner -> { .matches(partner -> {
assertThat(partner.getPartnerRel().getHolder().getTradeName()).isEqualTo("Third OHG"); assertThat(partner.getPartnerRel().getHolder().getTradeName()).isEqualTo("Third OHG");
assertThat(partner.getPartnerRel().getContact().getLabel()).isEqualTo("third contact"); assertThat(partner.getPartnerRel().getContact().getCaption()).isEqualTo("third contact");
return true; return true;
}); });
@ -436,13 +436,13 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("details.birthName", is("Maja Schmidt")) .body("details.birthName", is("Maja Schmidt"))
.body("partnerRel.contact.label", is(givenPartner.getPartnerRel().getContact().getLabel())); .body("partnerRel.contact.caption", is(givenPartner.getPartnerRel().getContact().getCaption()));
// @formatter:on // @formatter:on
// finally, the partner details and only the partner details are actually updated // finally, the partner details and only the partner details are actually updated
assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get() assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get()
.matches(partner -> { .matches(partner -> {
assertThat(partner.getPartnerRel().getContact().getLabel()).isEqualTo(givenPartner.getPartnerRel().getContact().getLabel()); assertThat(partner.getPartnerRel().getContact().getCaption()).isEqualTo(givenPartner.getPartnerRel().getContact().getCaption());
assertThat(partner.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Leer"); assertThat(partner.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Leer");
assertThat(partner.getDetails().getRegistrationNumber()).isEqualTo("333333"); assertThat(partner.getDetails().getRegistrationNumber()).isEqualTo("333333");
assertThat(partner.getDetails().getBirthName()).isEqualTo("Maja Schmidt"); assertThat(partner.getDetails().getBirthName()).isEqualTo("Maja Schmidt");
@ -481,7 +481,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
void contactAdminUser_canNotDeleteRelatedPartner() { void contactAdminUser_canNotDeleteRelatedPartner() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = givenSomeTemporaryPartnerBessler(20014); final var givenPartner = givenSomeTemporaryPartnerBessler(20014);
assertThat(givenPartner.getPartnerRel().getContact().getLabel()).isEqualTo("fourth contact"); assertThat(givenPartner.getPartnerRel().getContact().getCaption()).isEqualTo("fourth contact");
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -500,7 +500,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
void normalUser_canNotDeleteUnrelatedPartner() { void normalUser_canNotDeleteUnrelatedPartner() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = givenSomeTemporaryPartnerBessler(20015); final var givenPartner = givenSomeTemporaryPartnerBessler(20015);
assertThat(givenPartner.getPartnerRel().getContact().getLabel()).isEqualTo("fourth contact"); assertThat(givenPartner.getPartnerRel().getContact().getCaption()).isEqualTo("fourth contact");
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -523,7 +523,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow();
final var givenPerson = personRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow(); final var givenPerson = personRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow();
final var givenContact = contactRepo.findContactByOptionalLabelLike(contactName).stream().findFirst().orElseThrow(); final var givenContact = contactRepo.findContactByOptionalCaptionLike(contactName).stream().findFirst().orElseThrow();
final var partnerRel = new HsOfficeRelationEntity(); final var partnerRel = new HsOfficeRelationEntity();
partnerRel.setType(HsOfficeRelationType.PARTNER); partnerRel.setType(HsOfficeRelationType.PARTNER);

View File

@ -23,14 +23,14 @@ class HsOfficePartnerEntityUnitTest {
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.build()) .build())
.contact(HsOfficeContactEntity.builder().label("some label").build()) .contact(HsOfficeContactEntity.builder().caption("some caption").build())
.build()) .build())
.build(); .build();
@Test @Test
void toStringContainsPartnerNumberPersonAndContact() { void toStringContainsPartnerNumberPersonAndContact() {
final var result = givenPartner.toString(); final var result = givenPartner.toString();
assertThat(result).isEqualTo("partner(P-12345: LP some trade name, some label)"); assertThat(result).isEqualTo("partner(P-12345: LP some trade name, some caption)");
} }
@Test @Test

View File

@ -109,7 +109,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
// when // when
attempt(em, () -> { attempt(em, () -> {
final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0); final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
final var newRelation = HsOfficeRelationEntity.builder() final var newRelation = HsOfficeRelationEntity.builder()
@ -465,7 +465,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
private HsOfficeRelationEntity givenSomeTemporaryHostsharingPartnerRel(final String person, final String contact) { private HsOfficeRelationEntity givenSomeTemporaryHostsharingPartnerRel(final String person, final String contact) {
final var givenMandantorPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); final var givenMandantorPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike(person).get(0); final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike(person).get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike(contact).get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike(contact).get(0);
final var partnerRel = HsOfficeRelationEntity.builder() final var partnerRel = HsOfficeRelationEntity.builder()
.holder(givenPartnerPerson) .holder(givenPartnerPerson)

View File

@ -26,7 +26,7 @@ public class TestHsOfficePartner {
.tradeName(tradeName) .tradeName(tradeName)
.build()) .build())
.contact(HsOfficeContactEntity.builder() .contact(HsOfficeContactEntity.builder()
.label(tradeName) .caption(tradeName)
.build()) .build())
.build() .build()
) )

View File

@ -163,7 +163,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
} }
@Nested @Nested
class FindByLabelLike { class FindByCaptionLike {
@Test @Test
public void globalAdmin_withoutAssumedRole_canViewAllPersons() { public void globalAdmin_withoutAssumedRole_canViewAllPersons() {
@ -288,15 +288,15 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
hsOfficePerson("some temporary person #" + RandomStringUtils.random(12))); hsOfficePerson("some temporary person #" + RandomStringUtils.random(12)));
} }
void exactlyThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personLabels) { void exactlyThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personCaptions) {
assertThat(actualResult) assertThat(actualResult)
.extracting(HsOfficePersonEntity::getTradeName) .extracting(HsOfficePersonEntity::getTradeName)
.containsExactlyInAnyOrder(personLabels); .containsExactlyInAnyOrder(personCaptions);
} }
void allThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personLabels) { void allThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personCaptions) {
assertThat(actualResult) assertThat(actualResult)
.extracting(hsOfficePersonEntity -> hsOfficePersonEntity.toShortString()) .extracting(hsOfficePersonEntity -> hsOfficePersonEntity.toShortString())
.contains(personLabels); .contains(personCaptions);
} }
} }

View File

@ -81,34 +81,34 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
"holder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH" }, "holder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH" },
"type": "PARTNER", "type": "PARTNER",
"mark": null, "mark": null,
"contact": { "label": "first contact" } "contact": { "caption": "first contact" }
}, },
{ {
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" }, "anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
"holder": { "personType": "LEGAL_PERSON", "tradeName": "Fourth eG" }, "holder": { "personType": "LEGAL_PERSON", "tradeName": "Fourth eG" },
"type": "PARTNER", "type": "PARTNER",
"contact": { "label": "fourth contact" } "contact": { "caption": "fourth contact" }
}, },
{ {
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" }, "anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
"holder": { "personType": "LEGAL_PERSON", "tradeName": "Second e.K.", "givenName": "Peter", "familyName": "Smith" }, "holder": { "personType": "LEGAL_PERSON", "tradeName": "Second e.K.", "givenName": "Peter", "familyName": "Smith" },
"type": "PARTNER", "type": "PARTNER",
"mark": null, "mark": null,
"contact": { "label": "second contact" } "contact": { "caption": "second contact" }
}, },
{ {
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" }, "anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
"holder": { "personType": "NATURAL_PERSON", "givenName": "Peter", "familyName": "Smith" }, "holder": { "personType": "NATURAL_PERSON", "givenName": "Peter", "familyName": "Smith" },
"type": "PARTNER", "type": "PARTNER",
"mark": null, "mark": null,
"contact": { "label": "sixth contact" } "contact": { "caption": "sixth contact" }
}, },
{ {
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" }, "anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
"holder": { "personType": "INCORPORATED_FIRM", "tradeName": "Third OHG" }, "holder": { "personType": "INCORPORATED_FIRM", "tradeName": "Third OHG" },
"type": "PARTNER", "type": "PARTNER",
"mark": null, "mark": null,
"contact": { "label": "third contact" } "contact": { "caption": "third contact" }
} }
] ]
""")); """));
@ -125,7 +125,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0); final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Paul").get(0); final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Paul").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("second").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("second").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -156,7 +156,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
.body("mark", is("operations-discuss")) .body("mark", is("operations-discuss"))
.body("anchor.tradeName", is("Third OHG")) .body("anchor.tradeName", is("Third OHG"))
.body("holder.givenName", is("Paul")) .body("holder.givenName", is("Paul"))
.body("contact.label", is("second contact")) .body("contact.caption", is("second contact"))
.header("Location", startsWith("http://localhost")) .header("Location", startsWith("http://localhost"))
.extract().header("Location"); // @formatter:on .extract().header("Location"); // @formatter:on
@ -172,7 +172,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenAnchorPersonUuid = GIVEN_NON_EXISTING_HOLDER_PERSON_UUID; final var givenAnchorPersonUuid = GIVEN_NON_EXISTING_HOLDER_PERSON_UUID;
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Smith").get(0); final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Smith").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -204,7 +204,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0); final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -286,7 +286,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
{ {
"anchor": { "tradeName": "First GmbH" }, "anchor": { "tradeName": "First GmbH" },
"holder": { "familyName": "Firby" }, "holder": { "familyName": "Firby" },
"contact": { "label": "first contact" } "contact": { "caption": "first contact" }
} }
""")); // @formatter:on """)); // @formatter:on
} }
@ -310,7 +310,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
void contactAdminUser_canGetRelatedRelation() { void contactAdminUser_canGetRelatedRelation() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenRelation = findRelation("First", "Firby"); final var givenRelation = findRelation("First", "Firby");
assertThat(givenRelation.getContact().getLabel()).isEqualTo("first contact"); assertThat(givenRelation.getContact().getCaption()).isEqualTo("first contact");
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -325,7 +325,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
{ {
"anchor": { "tradeName": "First GmbH" }, "anchor": { "tradeName": "First GmbH" },
"holder": { "familyName": "Firby" }, "holder": { "familyName": "Firby" },
"contact": { "label": "first contact" } "contact": { "caption": "first contact" }
} }
""")); // @formatter:on """)); // @formatter:on
} }
@ -352,8 +352,8 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenRelation = givenSomeTemporaryRelationBessler(); final var givenRelation = givenSomeTemporaryRelationBessler();
assertThat(givenRelation.getContact().getLabel()).isEqualTo("seventh contact"); assertThat(givenRelation.getContact().getCaption()).isEqualTo("seventh contact");
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth").get(0);
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -374,7 +374,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
.body("type", is("REPRESENTATIVE")) .body("type", is("REPRESENTATIVE"))
.body("anchor.tradeName", is("Erben Bessler")) .body("anchor.tradeName", is("Erben Bessler"))
.body("holder.familyName", is("Winkler")) .body("holder.familyName", is("Winkler"))
.body("contact.label", is("fourth contact")); .body("contact.caption", is("fourth contact"));
// @formatter:on // @formatter:on
// finally, the relation is actually updated // finally, the relation is actually updated
@ -383,7 +383,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
.matches(rel -> { .matches(rel -> {
assertThat(rel.getAnchor().getTradeName()).contains("Bessler"); assertThat(rel.getAnchor().getTradeName()).contains("Bessler");
assertThat(rel.getHolder().getFamilyName()).contains("Winkler"); assertThat(rel.getHolder().getFamilyName()).contains("Winkler");
assertThat(rel.getContact().getLabel()).isEqualTo("fourth contact"); assertThat(rel.getContact().getCaption()).isEqualTo("fourth contact");
assertThat(rel.getType()).isEqualTo(HsOfficeRelationType.REPRESENTATIVE); assertThat(rel.getType()).isEqualTo(HsOfficeRelationType.REPRESENTATIVE);
return true; return true;
}); });
@ -415,7 +415,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
void contactAdminUser_canNotDeleteRelatedRelation() { void contactAdminUser_canNotDeleteRelatedRelation() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenRelation = givenSomeTemporaryRelationBessler(); final var givenRelation = givenSomeTemporaryRelationBessler();
assertThat(givenRelation.getContact().getLabel()).isEqualTo("seventh contact"); assertThat(givenRelation.getContact().getCaption()).isEqualTo("seventh contact");
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -434,7 +434,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
void normalUser_canNotDeleteUnrelatedRelation() { void normalUser_canNotDeleteUnrelatedRelation() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenRelation = givenSomeTemporaryRelationBessler(); final var givenRelation = givenSomeTemporaryRelationBessler();
assertThat(givenRelation.getContact().getLabel()).isEqualTo("seventh contact"); assertThat(givenRelation.getContact().getCaption()).isEqualTo("seventh contact");
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -455,7 +455,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0); final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Winkler").get(0); final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Winkler").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("seventh contact").get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike("seventh contact").get(0);
final var newRelation = HsOfficeRelationEntity.builder() final var newRelation = HsOfficeRelationEntity.builder()
.type(HsOfficeRelationType.REPRESENTATIVE) .type(HsOfficeRelationType.REPRESENTATIVE)
.anchor(givenAnchorPerson) .anchor(givenAnchorPerson)

View File

@ -71,7 +71,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Paul").stream() final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Paul").stream()
.filter(p -> p.getPersonType() == NATURAL_PERSON) .filter(p -> p.getPersonType() == NATURAL_PERSON)
.findFirst().orElseThrow(); .findFirst().orElseThrow();
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").stream() final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").stream()
.findFirst().orElseThrow(); .findFirst().orElseThrow();
// when // when
@ -111,7 +111,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Bert").stream() final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Bert").stream()
.filter(p -> p.getPersonType() == NATURAL_PERSON) .filter(p -> p.getPersonType() == NATURAL_PERSON)
.findFirst().orElseThrow(); .findFirst().orElseThrow();
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").stream() final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").stream()
.findFirst().orElseThrow(); .findFirst().orElseThrow();
final var newRelation = HsOfficeRelationEntity.builder() final var newRelation = HsOfficeRelationEntity.builder()
.anchor(givenAnchorPerson) .anchor(givenAnchorPerson)
@ -219,7 +219,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
givenRelation, givenRelation,
"hs_office_person#ErbenBesslerMelBessler:ADMIN"); "hs_office_person#ErbenBesslerMelBessler:ADMIN");
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
final var givenContact = contactRepo.findContactByOptionalLabelLike("sixth contact").stream().findFirst().orElseThrow(); final var givenContact = contactRepo.findContactByOptionalCaptionLike("sixth contact").stream().findFirst().orElseThrow();
// when // when
final var result = jpaAttempt.transacted(() -> { final var result = jpaAttempt.transacted(() -> {
@ -230,7 +230,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
// then // then
result.assertSuccessful(); result.assertSuccessful();
assertThat(result.returnedValue().getContact().getLabel()).isEqualTo("sixth contact"); assertThat(result.returnedValue().getContact().getCaption()).isEqualTo("sixth contact");
assertThatRelationIsVisibleForUserWithRole( assertThatRelationIsVisibleForUserWithRole(
result.returnedValue(), result.returnedValue(),
"global#global:ADMIN"); "global#global:ADMIN");
@ -412,7 +412,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0); final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike(holderPerson).get(0); final var givenHolderPerson = personRepo.findPersonByOptionalNameLike(holderPerson).get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike(contact).get(0); final var givenContact = contactRepo.findContactByOptionalCaptionLike(contact).get(0);
final var newRelation = HsOfficeRelationEntity.builder() final var newRelation = HsOfficeRelationEntity.builder()
.type(HsOfficeRelationType.REPRESENTATIVE) .type(HsOfficeRelationType.REPRESENTATIVE)
.anchor(givenAnchorPerson) .anchor(givenAnchorPerson)

View File

@ -17,14 +17,14 @@ class HsOfficeSepaMandateEntityUnitTest {
.debitor(TEST_DEBITOR) .debitor(TEST_DEBITOR)
.reference("some-ref") .reference("some-ref")
.validity(toPostgresDateRange(GIVEN_VALID_FROM, GIVEN_VALID_TO)) .validity(toPostgresDateRange(GIVEN_VALID_FROM, GIVEN_VALID_TO))
.bankAccount(HsOfficeBankAccountEntity.builder().iban("some label").build()) .bankAccount(HsOfficeBankAccountEntity.builder().iban("some caption").build())
.build(); .build();
@Test @Test
void toStringContainsReferenceAndBankAccount() { void toStringContainsReferenceAndBankAccount() {
final var result = givenSepaMandate.toString(); final var result = givenSepaMandate.toString();
assertThat(result).isEqualTo("SEPA-Mandate(some label, some-ref, [2020-01-01,2031-01-01))"); assertThat(result).isEqualTo("SEPA-Mandate(some caption, some-ref, [2020-01-01,2031-01-01))");
} }
@Test @Test

View File

@ -21,7 +21,7 @@ class StringifyUnitTest {
public static class TestBean implements Stringifyable { public static class TestBean implements Stringifyable {
private static Stringify<TestBean> toString = stringify(TestBean.class, "bean") private static Stringify<TestBean> toString = stringify(TestBean.class, "bean")
.withProp(TestBean.Fields.label, TestBean::getLabel) .withProp(TestBean.Fields.caption, TestBean::getCaption)
.withProp(TestBean.Fields.contentA, TestBean::getContentA) .withProp(TestBean.Fields.contentA, TestBean::getContentA)
.withProp(TestBean.Fields.contentB, TestBean::getContentB) .withProp(TestBean.Fields.contentB, TestBean::getContentB)
.withProp(TestBean.Fields.value, TestBean::getValue) .withProp(TestBean.Fields.value, TestBean::getValue)
@ -29,7 +29,7 @@ class StringifyUnitTest {
private UUID uuid; private UUID uuid;
private String label; private String caption;
private SubBeanWithUnquotedValues contentA; private SubBeanWithUnquotedValues contentA;
@ -45,7 +45,7 @@ class StringifyUnitTest {
@Override @Override
public String toShortString() { public String toShortString() {
return label; return caption;
} }
} }
@ -103,14 +103,14 @@ class StringifyUnitTest {
@Test @Test
void stringifyWhenAllPropsHaveValues() { void stringifyWhenAllPropsHaveValues() {
final var given = new TestBean(UUID.randomUUID(), "some label", final var given = new TestBean(UUID.randomUUID(), "some caption",
new SubBeanWithUnquotedValues("some key", "some value"), new SubBeanWithUnquotedValues("some key", "some value"),
new SubBeanWithQuotedValues("some key", 1234), new SubBeanWithQuotedValues("some key", 1234),
42, 42,
false); false);
final var result = given.toString(); final var result = given.toString();
assertThat(result).isEqualTo( assertThat(result).isEqualTo(
"bean(label='some label', contentA='some key:some value', contentB='some key:1234', value=42, active=false)"); "bean(caption='some caption', contentA='some key:some value', contentB='some key:1234', value=42, active=false)");
} }
@Test @Test