WIP: add advanced scenario-tests for coop-assets #123

Draft
hsh-michaelhoennig wants to merge 22 commits from feature/add-advanced-scenario-tests-for-coop-assets into master
2 changed files with 9 additions and 12 deletions
Showing only changes of commit e89833b233 - Show all commits

View File

@ -50,11 +50,10 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, BaseE
.withProp(HsOfficeCoopAssetsTransactionEntity::getAssetValue) .withProp(HsOfficeCoopAssetsTransactionEntity::getAssetValue)
.withProp(HsOfficeCoopAssetsTransactionEntity::getReference) .withProp(HsOfficeCoopAssetsTransactionEntity::getReference)
.withProp(HsOfficeCoopAssetsTransactionEntity::getComment) .withProp(HsOfficeCoopAssetsTransactionEntity::getComment)
// FIXME: try short form with just method reference .withProp(HsOfficeCoopAssetsTransactionEntity::getRevertedAssetTx)
.withProp(at -> ofNullable(at.getRevertedAssetTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null)) .withProp(HsOfficeCoopAssetsTransactionEntity::getAssetReversalTx)
.withProp(at -> ofNullable(at.getAssetReversalTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null)) .withProp(HsOfficeCoopAssetsTransactionEntity::getAssetAdoptionAssetTx)
.withProp(at -> ofNullable(at.getAssetAdoptionAssetTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null)) .withProp(HsOfficeCoopAssetsTransactionEntity::getAssetTransferTx)
.withProp(at -> ofNullable(at.getAssetTransferTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null))
.quotedValues(false); .quotedValues(false);
@Id @Id

View File

@ -80,12 +80,6 @@ public final class Stringify<B> {
.map(prop -> PropertyValue.of(prop, prop.getter.apply(object))) .map(prop -> PropertyValue.of(prop, prop.getter.apply(object)))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.filter(PropertyValue::nonEmpty) .filter(PropertyValue::nonEmpty)
.map(propVal -> {
if (propVal.rawValue instanceof Stringifyable stringifyable) {
return new PropertyValue<>(propVal.prop, propVal.rawValue, stringifyable.toShortString());
}
return propVal;
})
.map(propVal -> propName(propVal, "=") + optionallyQuoted(propVal)) .map(propVal -> propName(propVal, "=") + optionallyQuoted(propVal))
.collect(Collectors.joining(separator)); .collect(Collectors.joining(separator));
return idProp != null return idProp != null
@ -131,7 +125,11 @@ public final class Stringify<B> {
private record PropertyValue<B>(Property<B> prop, Object rawValue, String value) { private record PropertyValue<B>(Property<B> prop, Object rawValue, String value) {
static <B> PropertyValue<B> of(Property<B> prop, Object rawValue) { static <B> PropertyValue<B> of(Property<B> prop, Object rawValue) {
return rawValue != null ? new PropertyValue<>(prop, rawValue, rawValue.toString()) : null; return rawValue != null ? new PropertyValue<>(prop, rawValue, toStringOrShortString(rawValue)) : null;
}
private static String toStringOrShortString(final Object rawValue) {
return rawValue instanceof Stringifyable stringifyable ? stringifyable.toShortString() : rawValue.toString();
} }
boolean nonEmpty() { boolean nonEmpty() {