rename contact.label to contact.caption

This commit is contained in:
Michael Hoennig 2024-05-06 09:22:21 +02:00
parent a93c097f64
commit 85376d51af
35 changed files with 191 additions and 191 deletions

View File

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

View File

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

View File

@ -17,7 +17,7 @@ class HsOfficeContactEntityPatcher implements EntityPatcher<HsOfficeContactPatch
@Override
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);
Optional.ofNullable(resource.getEmailAddresses())
.ifPresent(r -> entity.getEmailAddresses().patch(KeyValueMap.from(resource.getEmailAddresses())));

View File

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

View File

@ -20,7 +20,7 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
JOIN HsOfficePersonEntity person ON person.uuid = rel.holder.uuid
WHERE :name is null
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.givenName 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(
final String currentUser,
final String assumedRoles,
final String label) {
final String caption) {
context.define(currentUser, assumedRoles);
final var entities = personRepo.findPersonByOptionalNameLike(label);
final var entities = personRepo.findPersonByOptionalNameLike(caption);
final var resources = mapper.mapList(entities, HsOfficePersonResource.class);
return ResponseEntity.ok(resources);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ create or replace procedure createHsOfficeRelationTestData(
holderPersonName varchar,
relationType HsOfficeRelationType,
anchorPersonName varchar,
contactLabel varchar,
contactCaption varchar,
mark varchar default null)
language plpgsql as $$
declare
@ -44,9 +44,9 @@ begin
raise exception 'holderPerson "%" not found', holderPersonName;
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
raise exception 'contact "%" not found', contactLabel;
raise exception 'contact "%" not found', contactCaption;
end if;
raise notice 'creating test relation: %', idName;
@ -74,7 +74,7 @@ begin
for t in startCount..endCount
loop
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');
commit;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,10 +6,10 @@ public class TestHsOfficeContact {
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()
.label(label)
.postalAddress("address of " + label)
.caption(caption)
.postalAddress("address of " + caption)
.emailAddresses(Map.of("main", emailAddr))
.build();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,14 +23,14 @@ class HsOfficePartnerEntityUnitTest {
.personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name")
.build())
.contact(HsOfficeContactEntity.builder().label("some label").build())
.contact(HsOfficeContactEntity.builder().caption("some caption").build())
.build())
.build();
@Test
void toStringContainsPartnerNumberPersonAndContact() {
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

View File

@ -109,7 +109,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
// when
attempt(em, () -> {
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 newRelation = HsOfficeRelationEntity.builder()
@ -465,7 +465,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
private HsOfficeRelationEntity givenSomeTemporaryHostsharingPartnerRel(final String person, final String contact) {
final var givenMandantorPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").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()
.holder(givenPartnerPerson)

View File

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

View File

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

View File

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

View File

@ -17,14 +17,14 @@ class HsOfficeSepaMandateEntityUnitTest {
.debitor(TEST_DEBITOR)
.reference("some-ref")
.validity(toPostgresDateRange(GIVEN_VALID_FROM, GIVEN_VALID_TO))
.bankAccount(HsOfficeBankAccountEntity.builder().iban("some label").build())
.bankAccount(HsOfficeBankAccountEntity.builder().iban("some caption").build())
.build();
@Test
void toStringContainsReferenceAndBankAccount() {
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

View File

@ -21,7 +21,7 @@ class StringifyUnitTest {
public static class TestBean implements Stringifyable {
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.contentB, TestBean::getContentB)
.withProp(TestBean.Fields.value, TestBean::getValue)
@ -29,7 +29,7 @@ class StringifyUnitTest {
private UUID uuid;
private String label;
private String caption;
private SubBeanWithUnquotedValues contentA;
@ -45,7 +45,7 @@ class StringifyUnitTest {
@Override
public String toShortString() {
return label;
return caption;
}
}
@ -103,14 +103,14 @@ class StringifyUnitTest {
@Test
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 SubBeanWithQuotedValues("some key", 1234),
42,
false);
final var result = given.toString();
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