diff options
| author | Kostya <mail@sartin.in> | 2026-08-23 14:05:29 +0000 |
|---|---|---|
| committer | Kostya <mail@sartin.in> | 2026-08-23 14:05:29 +0000 |
| commit | 843820ea9f357220d69f3795f3289ee41eed355c (patch) | |
| tree | 57323a2e1cd4d4c0addd57eadc31d0f36c612e96 /service/src/test | |
| parent | fbfd2e275e9d645e4ec8a1874bc57d98b1c38300 (diff) | |
| download | guess-market-843820ea9f357220d69f3795f3289ee41eed355c.tar.gz guess-market-843820ea9f357220d69f3795f3289ee41eed355c.tar.xz guess-market-843820ea9f357220d69f3795f3289ee41eed355c.zip | |
model: relocate market DTOs out of the flat api package
Move AccountDTO/MarketDTO/MarketStateDTO/PurchaseReceiptDTO/TradeRowDTO
out of the catch-all api package into model.market (and LedgerDTO into
model.ledger), matching the existing model.event convention so DTOs
live next to the domain they describe rather than in the interface
package. Relocate LedgerMapper from mapper.v2 to infrastructure.adapter
to match the module's established package layout, and update all call
sites and imports accordingly.
Also register the ui-desktop module in the build tooling: add it to
MODULES, add openjfx to the shipped runtime libs, and generalize
package.sh so each executable module (ui-console, ui-desktop) gets its
own Main-Class/Class-Path manifest and run script instead of
special-casing ui-console. Fold long Class-Path manifest lines at 72
bytes per the JAR spec, since adding ui-desktop's dependencies pushed
the line past the limit.
Diffstat (limited to 'service/src/test')
| -rw-r--r-- | service/src/test/java/market/guess/service/catalog/infrastructure/adapter/LedgerMapperTest.java (renamed from service/src/test/java/market/guess/service/catalog/infrastructure/mapper/v2/LedgerMapperTest.java) | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/service/src/test/java/market/guess/service/catalog/infrastructure/mapper/v2/LedgerMapperTest.java b/service/src/test/java/market/guess/service/catalog/infrastructure/adapter/LedgerMapperTest.java index 9e00411..976442c 100644 --- a/service/src/test/java/market/guess/service/catalog/infrastructure/mapper/v2/LedgerMapperTest.java +++ b/service/src/test/java/market/guess/service/catalog/infrastructure/adapter/LedgerMapperTest.java | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | package market.guess.service.catalog.infrastructure.mapper.v2; | 1 | package market.guess.service.catalog.infrastructure.adapter; |
| 2 | 2 | ||
| 3 | import static org.junit.Assert.assertEquals; | 3 | import static org.junit.Assert.assertEquals; |
| 4 | import static org.junit.Assert.assertFalse; | 4 | import static org.junit.Assert.assertFalse; |
| @@ -8,7 +8,7 @@ import static org.junit.Assert.assertTrue; | |||
| 8 | import java.math.BigDecimal; | 8 | import java.math.BigDecimal; |
| 9 | import java.time.Instant; | 9 | import java.time.Instant; |
| 10 | import java.util.List; | 10 | import java.util.List; |
| 11 | import market.guess.api.AccountDTO; | 11 | import market.guess.model.ledger.LedgerDTO; |
| 12 | import market.guess.model.ledger.LedgerEntryDTO; | 12 | import market.guess.model.ledger.LedgerEntryDTO; |
| 13 | import market.guess.model.ledger.LedgerType; | 13 | import market.guess.model.ledger.LedgerType; |
| 14 | import market.guess.service.ledger.Ledger; | 14 | import market.guess.service.ledger.Ledger; |
| @@ -29,7 +29,7 @@ public class LedgerMapperTest { | |||
| 29 | public void mapsOwnerAndBalanceAsStrings() { | 29 | public void mapsOwnerAndBalanceAsStrings() { |
| 30 | Ledger ledger = new Ledger("alice", new BigDecimal("100")); | 30 | Ledger ledger = new Ledger("alice", new BigDecimal("100")); |
| 31 | 31 | ||
| 32 | AccountDTO dto = mapper.ledgerToLedgerDTO(ledger); | 32 | LedgerDTO dto = mapper.ledgerToLedgerDTO(ledger); |
| 33 | 33 | ||
| 34 | assertEquals("alice", dto.owner()); | 34 | assertEquals("alice", dto.owner()); |
| 35 | assertEquals("100.00", dto.balance()); | 35 | assertEquals("100.00", dto.balance()); |
| @@ -39,7 +39,7 @@ public class LedgerMapperTest { | |||
| 39 | public void emptyEntriesMapToEmptyList() { | 39 | public void emptyEntriesMapToEmptyList() { |
| 40 | Ledger ledger = new Ledger("alice", new BigDecimal("0")); | 40 | Ledger ledger = new Ledger("alice", new BigDecimal("0")); |
| 41 | 41 | ||
| 42 | AccountDTO dto = mapper.ledgerToLedgerDTO(ledger); | 42 | LedgerDTO dto = mapper.ledgerToLedgerDTO(ledger); |
| 43 | 43 | ||
| 44 | assertTrue(dto.entries().isEmpty()); | 44 | assertTrue(dto.entries().isEmpty()); |
| 45 | } | 45 | } |
| @@ -49,12 +49,20 @@ public class LedgerMapperTest { | |||
| 49 | Ledger ledger = new Ledger("bob", new BigDecimal("0")); | 49 | Ledger ledger = new Ledger("bob", new BigDecimal("0")); |
| 50 | ledger.record( | 50 | ledger.record( |
| 51 | new LedgerEntry( | 51 | new LedgerEntry( |
| 52 | 1, Instant.parse("2026-01-01T00:00:00Z"), LedgerType.DEPOSIT, | 52 | 1, |
| 53 | new BigDecimal("50.00"), new BigDecimal("50.00"), "first")); | 53 | Instant.parse("2026-01-01T00:00:00Z"), |
| 54 | LedgerType.DEPOSIT, | ||
| 55 | new BigDecimal("50.00"), | ||
| 56 | new BigDecimal("50.00"), | ||
| 57 | "first")); | ||
| 54 | ledger.record( | 58 | ledger.record( |
| 55 | new LedgerEntry( | 59 | new LedgerEntry( |
| 56 | 2, Instant.parse("2026-01-02T00:00:00Z"), LedgerType.PURCHASE, | 60 | 2, |
| 57 | new BigDecimal("-20.00"), new BigDecimal("30.00"), "second")); | 61 | Instant.parse("2026-01-02T00:00:00Z"), |
| 62 | LedgerType.PURCHASE, | ||
| 63 | new BigDecimal("-20.00"), | ||
| 64 | new BigDecimal("30.00"), | ||
| 65 | "second")); | ||
| 58 | 66 | ||
| 59 | List<LedgerEntryDTO> entries = mapper.ledgerToLedgerDTO(ledger).entries(); | 67 | List<LedgerEntryDTO> entries = mapper.ledgerToLedgerDTO(ledger).entries(); |
| 60 | 68 | ||
| @@ -84,16 +92,18 @@ public class LedgerMapperTest { | |||
| 84 | 92 | ||
| 85 | /** | 93 | /** |
| 86 | * LedgerEntry.id/time and Ledger's account-blocked state have no matching AccountDTO/ | 94 | * LedgerEntry.id/time and Ledger's account-blocked state have no matching AccountDTO/ |
| 87 | * LedgerEntryDTO source property, so MapStruct leaves them at their Java defaults. This | 95 | * LedgerEntryDTO source property, so MapStruct leaves them at their Java defaults. This pins that |
| 88 | * pins that known gap; once the mapper is taught to fill seq/at/blocked, update these | 96 | * known gap; once the mapper is taught to fill seq/at/blocked, update these assertions instead of |
| 89 | * assertions instead of deleting them. | 97 | * deleting them. |
| 90 | */ | 98 | */ |
| 91 | @Test | 99 | @Test |
| 92 | public void unmappedTargetPropertiesFallBackToDefaults() { | 100 | public void unmappedTargetPropertiesFallBackToDefaults() { |
| 93 | Ledger ledger = new Ledger("dave", new BigDecimal("0")); | 101 | Ledger ledger = new Ledger("dave", new BigDecimal("0")); |
| 94 | ledger.record(new LedgerEntry(7, Instant.now(), LedgerType.COMMISSION, BigDecimal.ONE, BigDecimal.ONE, "n")); | 102 | ledger.record( |
| 103 | new LedgerEntry( | ||
| 104 | 7, Instant.now(), LedgerType.COMMISSION, BigDecimal.ONE, BigDecimal.ONE, "n")); | ||
| 95 | 105 | ||
| 96 | AccountDTO dto = mapper.ledgerToLedgerDTO(ledger); | 106 | LedgerDTO dto = mapper.ledgerToLedgerDTO(ledger); |
| 97 | 107 | ||
| 98 | assertFalse(dto.blocked()); | 108 | assertFalse(dto.blocked()); |
| 99 | LedgerEntryDTO entry = dto.entries().get(0); | 109 | LedgerEntryDTO entry = dto.entries().get(0); |