From 3c5133ffbc71613836e0f1a3b3b73a3007d11fd4 Mon Sep 17 00:00:00 2001 From: Steinar Bang Date: Sun, 15 Sep 2024 19:21:14 +0200 Subject: [PATCH 1/2] Upgrade parent to get junit jupiter 5.11.0, mockito 5.13.0 and all maven plugins as current latest stable version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0e754a16..6b5bcc13 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ no.priv.bang.pom bang-authservice-client-pom - 2.0.4 + 2.0.5 no.priv.bang.ukelonn ukelonn From f9d89e042dbf4cf6978bd1a44b18ce285ac8203a Mon Sep 17 00:00:00 2001 From: Steinar Bang Date: Sun, 29 Sep 2024 20:03:07 +0200 Subject: [PATCH 2/2] Re-add the Transaction.name property to the Transaction record type The property was lost when transforming Transaction from bean to record. --- .../src/main/java/no/priv/bang/ukelonn/beans/Transaction.java | 4 ++++ .../test/java/no/priv/bang/ukelonn/beans/TransactionTest.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/Transaction.java b/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/Transaction.java index cf984096..34f50752 100644 --- a/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/Transaction.java +++ b/ukelonn.services/src/main/java/no/priv/bang/ukelonn/beans/Transaction.java @@ -16,6 +16,7 @@ package no.priv.bang.ukelonn.beans; import java.util.Date; +import static java.util.Optional.*; public record Transaction( int id, @@ -24,6 +25,9 @@ public record Transaction( double transactionAmount, boolean paidOut) { + public String getName() { + return ofNullable(transactionType).map(TransactionType::transactionTypeName).orElse(null); + } public static Builder with(Transaction transaction) { Builder builder = new Builder(); diff --git a/ukelonn.services/src/test/java/no/priv/bang/ukelonn/beans/TransactionTest.java b/ukelonn.services/src/test/java/no/priv/bang/ukelonn/beans/TransactionTest.java index 5e51a959..a152828d 100644 --- a/ukelonn.services/src/test/java/no/priv/bang/ukelonn/beans/TransactionTest.java +++ b/ukelonn.services/src/test/java/no/priv/bang/ukelonn/beans/TransactionTest.java @@ -26,6 +26,7 @@ void testNoArgConstructor() { var bean = Transaction.with().build(); assertEquals(-1, bean.id()); assertNull(bean.transactionType()); + assertNull(bean.getName()); assertNull(bean.transactionTime()); assertEquals(0.0, bean.transactionAmount(), 0.0); assertFalse(bean.paidOut()); @@ -34,7 +35,7 @@ void testNoArgConstructor() { @Test void testConstructorWithArgs() { var id = 5; - var transactionType = TransactionType.with().build(); + var transactionType = TransactionType.with().transactionTypeName("Paid to account").build(); var transactionTime = new Date(); var transactionAmount = 100.0; var paidOut = true; @@ -46,6 +47,7 @@ void testConstructorWithArgs() { .paidOut(paidOut) .build(); assertEquals(id, bean.id()); + assertEquals(transactionType.transactionTypeName(), bean.getName()); assertEquals(transactionType, bean.transactionType()); assertEquals(transactionTime, bean.transactionTime()); assertEquals(transactionAmount, bean.transactionAmount(), 0.0);