aboutsummaryrefslogtreecommitdiffstats
path: root/service
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-09-06 10:36:54 +0300
committerKostya <mail@sartin.in>2026-09-06 10:36:54 +0300
commit508898f52c16cc737bc7d08b8ee4c29fab8d1146 (patch)
treeea2516796c7dc959a0009e70569e0d2d2b718c1f /service
parentda82f3b492c3cd36f2e8723632a63a6cc1f4e39b (diff)
downloadguess-market-508898f52c16cc737bc7d08b8ee4c29fab8d1146.tar.gz
guess-market-508898f52c16cc737bc7d08b8ee4c29fab8d1146.tar.xz
guess-market-508898f52c16cc737bc7d08b8ee4c29fab8d1146.zip
ex-2: add invalid-input fixtures and wire ui-desktop to the service
The ex-2 loader has to reject documents that are schema-valid but logically broken, and so far only error-2.xml and error-3.xml exercised that path. Add one fixture per validation rule under test-data/ex-2/invalid, each a copy of small.xml with a single defect described in a leading comment: a non-.xml extension, a duplicate event id, commission outside 0..90 on either side, a duplicate user name, zero or negative initial cash, a market maker referencing an unknown event, and an event with no market maker or with two. Teach LedgerMapper to map individual LedgerEntry records to LedgerEntryDTO, renaming id to seq and time to at and rendering the timestamp through InstantOptions.humanize, so callers can show a ledger history rather than only the account summary. Make ui-desktop depend on api and service in the build tooling and in its Eclipse classpath, since the desktop UI now talks to the service layer directly, and put lib/openjfx on java.library.path for the test run so tests touching JavaFX can load its native libraries.
Diffstat (limited to 'service')
-rw-r--r--service/src/main/java/market/guess/service/catalog/infrastructure/adapter/LedgerMapper.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/adapter/LedgerMapper.java b/service/src/main/java/market/guess/service/catalog/infrastructure/adapter/LedgerMapper.java
index 5a46540..9744925 100644
--- a/service/src/main/java/market/guess/service/catalog/infrastructure/adapter/LedgerMapper.java
+++ b/service/src/main/java/market/guess/service/catalog/infrastructure/adapter/LedgerMapper.java
@@ -1,10 +1,23 @@
1package market.guess.service.catalog.infrastructure.adapter; 1package market.guess.service.catalog.infrastructure.adapter;
2 2
3import java.time.Instant;
3import market.guess.model.ledger.LedgerDTO; 4import market.guess.model.ledger.LedgerDTO;
5import market.guess.model.ledger.LedgerEntryDTO;
6import market.guess.service.helpers.InstantOptions;
4import market.guess.service.ledger.Ledger; 7import market.guess.service.ledger.Ledger;
8import market.guess.service.ledger.LedgerEntry;
5import org.mapstruct.Mapper; 9import org.mapstruct.Mapper;
10import org.mapstruct.Mapping;
6 11
7@Mapper 12@Mapper
8public interface LedgerMapper { 13public interface LedgerMapper {
9 LedgerDTO ledgerToLedgerDTO(Ledger ledger); 14 LedgerDTO ledgerToLedgerDTO(Ledger ledger);
15
16 @Mapping(target = "seq", source = "id")
17 @Mapping(target = "at", source = "time")
18 LedgerEntryDTO ledgerEntryToLedgerEntryDTO(LedgerEntry entry);
19
20 default String instantToDisplay(Instant time) {
21 return time == null ? null : InstantOptions.humanize(time);
22 }
10} 23}