improve toString in various entities and especially in HsOfficeDebitorEntity

This commit is contained in:
Michael Hoennig 2024-02-06 12:26:24 +01:00
parent c987cba53c
commit 528ad42fa6
10 changed files with 12 additions and 22 deletions

View File

@ -34,7 +34,6 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, HasUu
.withProp(HsOfficeCoopAssetsTransactionEntity::getAssetValue)
.withProp(HsOfficeCoopAssetsTransactionEntity::getReference)
.withProp(HsOfficeCoopAssetsTransactionEntity::getComment)
.withSeparator(", ")
.quotedValues(false);
@Id

View File

@ -31,7 +31,6 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUu
.withProp(HsOfficeCoopSharesTransactionEntity::getShareCount)
.withProp(HsOfficeCoopSharesTransactionEntity::getReference)
.withProp(HsOfficeCoopSharesTransactionEntity::getComment)
.withSeparator(", ")
.quotedValues(false);
@Id

View File

@ -28,15 +28,11 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
public static final String DEBITOR_NUMBER_TAG = "D-";
// TODO: I would rather like to generate something matching this example:
// debitor(1234500: Test AG, tes)
// maybe remove withSepararator (always use ', ') and add withBusinessIdProp (with ': ' afterwards)?
private static Stringify<HsOfficeDebitorEntity> stringify =
stringify(HsOfficeDebitorEntity.class, "debitor")
.withProp(e -> DEBITOR_NUMBER_TAG + e.getDebitorNumber())
.withIdProp(HsOfficeDebitorEntity::toShortString)
.withProp(HsOfficeDebitorEntity::getPartner)
.withProp(HsOfficeDebitorEntity::getDefaultPrefix)
.withSeparator(": ")
.quotedValues(false);
@Id

View File

@ -38,7 +38,6 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
.withProp(e -> e.getMainDebitor().toShortString())
.withProp(e -> e.getValidity().asString())
.withProp(HsOfficeMembershipEntity::getReasonForTermination)
.withSeparator(", ")
.quotedValues(false);
@Id

View File

@ -31,7 +31,6 @@ public class HsOfficePartnerDetailsEntity implements HasUuid, Stringifyable {
.withProp(HsOfficePartnerDetailsEntity::getBirthday)
.withProp(HsOfficePartnerDetailsEntity::getBirthName)
.withProp(HsOfficePartnerDetailsEntity::getDateOfDeath)
.withSeparator(", ")
.quotedValues(false);
@Id

View File

@ -39,7 +39,6 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
.map(HsOfficeRelationshipEntity::getContact)
.map(HsOfficeContactEntity::toShortString)
.orElse(null))
.withSeparator(", ")
.quotedValues(false);
@Id

View File

@ -33,7 +33,6 @@ public class HsOfficeSepaMandateEntity implements Stringifyable, HasUuid {
.withProp(HsOfficeSepaMandateEntity::getReference)
.withProp(HsOfficeSepaMandateEntity::getAgreement)
.withProp(e -> e.getValidity().asString())
.withSeparator(", ")
.quotedValues(false);
@Id

View File

@ -32,7 +32,7 @@ class HsOfficeDebitorEntityUnitTest {
final var result = given.toString();
assertThat(result).isEqualTo("debitor(D-1234567: LP some trade name: som)");
assertThat(result).isEqualTo("debitor(D-1234567: P-12345, som)");
}
@Test
@ -49,7 +49,7 @@ class HsOfficeDebitorEntityUnitTest {
final var result = given.toString();
assertThat(result).isEqualTo("debitor(D-1234567: <person=null>)");
assertThat(result).isEqualTo("debitor(D-1234567: P-12345)");
}
@Test

View File

@ -213,9 +213,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
// then
allTheseDebitorsAreReturned(
result,
"debitor(D-1000111: LP First GmbH: fir)",
"debitor(D-1000212: LP Second e.K.: sec)",
"debitor(D-1000313: IF Third OHG: thi)");
"debitor(D-1000111: P-10001, fir)",
"debitor(D-1000212: P-10002, sec)",
"debitor(D-1000313: P-10003, thi)");
}
@ParameterizedTest
@ -234,8 +234,8 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
// then:
exactlyTheseDebitorsAreReturned(result,
"debitor(D-1000111: LP First GmbH: fir)",
"debitor(D-1000120: LP First GmbH: fif)");
"debitor(D-1000111: P-10001, fir)",
"debitor(D-1000120: P-10001, fif)");
}
@Test
@ -263,7 +263,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
final var result = debitorRepo.findDebitorByDebitorNumber(1000313);
// then
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: IF Third OHG: thi)");
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: P-10003, thi)");
}
}
@ -279,7 +279,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
final var result = debitorRepo.findDebitorByOptionalNameLike("third contact");
// then
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: IF Third OHG: thi)");
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: P-10003, thi)");
}
}

View File

@ -370,7 +370,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
context.define("superuser-alex@hostsharing.net");
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
.matches(mandate -> {
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: LP First GmbH: fir)");
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: P-10001, fir)");
assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH");
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z - patched");
assertThat(mandate.getValidFrom()).isEqualTo("2020-06-05");
@ -411,7 +411,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
// finally, the sepaMandate is actually updated
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
.matches(mandate -> {
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: LP First GmbH: fir)");
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: P-10001, fir)");
assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH");
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z");
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-01-01)");