Commit 4dafa44
authored
refactor(infra): enforce remaining coding standards across platform (STA-249) (#270)
* chore(infra): @slf4j, drop block comments, prefer var (STA-249)
Three small style-rule cleanups across the platform:
- Replace LoggerFactory.getLogger with @slf4j in ExternalApiLoggingInterceptor.
- Drop 5 leftover block comments from switch-default and no-op lambda bodies
in webhook validators, OFAC parser, and the nonce manager.
- Use var for ~20 obvious local declarations across ledger, compliance,
custody, fiat-on-ramp, merchant-iam, merchant-onboarding, payment-orchestrator,
and a few test files (PermissionTest, JournalCommandHandlerTest,
DevCustodyAdapterTest).
No behavior change. Verified with compileJava + compileTestJava on every
touched module.
* chore(infra): drop narration comments across services (STA-249)
Remove ~135 step-by-step narration and section-divider comments
across 29 production files. Code now stands on its own; the remaining
47 comments document non-obvious WHY (Temporal saga authority,
JPA orphanRemoval ordering, advisory-lock semantics, PII masking
rationale, dev-mode keypair notes, etc.).
Heaviest cleanups: PayoutCommandHandler (-13), TransferCommandHandler
(-12), RefundCommandHandler (-12), TracingConfig (-13 architecture
explainer), RiskScoringService (-9 Factor 1-8 labels), CollectionCommandHandler
(-7), PaymentEventConsumer (-7), MerchantTeam (-6 Invariant labels),
LockService, MerchantOnboardingWorkflowImpl, PaymentWorkflowImpl,
FxRateLockApplicationService.
Verified: ./gradlew compileJava + compileTestJava BUILD SUCCESSFUL.
* test(infra): replace Mockito generic matchers with literal values (STA-249)
Eliminate any()/eq()/anyString()/anyLong()/anyInt()/anyBoolean()/
anyList() from 30 unit test files across api-gateway-iam (14),
payment-orchestrator (6), fx-liquidity-engine (3), merchant-onboarding
(3), merchant-iam (2), compliance-travel-rule (1), ledger-accounting (1).
~180 matcher usages removed. Stubs now take the literal values the SUT
actually passes; save verifications use eqIgnoringTimestamps / eqIgnoring
from platform-test TestUtils. Where runtime-generated values genuinely
cannot be pre-constructed (workflowId from generated paymentId, Duration
computed at revoke time) we use typed argThat(lambda) -- the same
escape hatch eqIgnoring itself uses.
Verified: 1,467 unit tests pass across all 7 affected modules.
* refactor(infra): collapse ApplicationService layer into CommandHandlers (STA-249)
Controllers now call CommandHandler / QueryHandler directly per
CLAUDE.md "Controller → CommandHandler directly — no intermediate
service layer".
compliance-travel-rule: delete ComplianceCheckApplicationService (thin
pass-through). ComplianceCheckController and CustomerRiskProfileController
inject ComplianceCheckCommandHandler + ComplianceCheckResponseMapper
directly. Tests rewritten to mock the handler.
fx-liquidity-engine: promote FxQuoteApplicationService, FxRateLockApplicationService,
and LiquidityPoolApplicationService to FxQuoteCommandHandler,
FxRateLockCommandHandler, and LiquidityPoolQueryHandler under domain/service/.
Handlers now take primitives and return domain objects (+ idempotency
records), so the hexagonal rule domain-may-not-depend-on-application
stays green. Controllers own response mapping via FxResponseMapper
(added CorridorSnapshot overload). New per-handler unit tests preserve
intent from the removed ApplicationService tests.
Dead-code removal: drop orphaned ApplicationService classes left from
STA-243 — ApiKeyApplicationService, AuthApplicationService,
OAuthClientApplicationService, MerchantApplicationService (api-gateway-iam)
and MerchantApplicationService (merchant-onboarding). Confirmed zero
references in main or test before deletion.
Net: -1505 lines. 13 files deleted, 13 modified, 6 new handlers/tests.
Verified: compliance-travel-rule (268 tests), fx-liquidity-engine (202
tests), full compileJava + compileTestJava BUILD SUCCESSFUL.
* refactor(infra): delete orphan ApplicationService classes missed in collapse (STA-249)
Code-review follow-up — the initial handler-collapse commit (aa89f6e)
added FxQuoteCommandHandler and FxRateLockCommandHandler alongside
the old @service classes instead of replacing them, and left
ApiKeyApplicationService in place despite the PR description
claiming it was deleted.
Net effect before this commit: three @Service-annotated classes were
still being instantiated by Spring component scan with no callers,
and two duplicate test files (FxQuoteApplicationServiceTest,
FxRateLockApplicationServiceTest) still exercised them.
Deletes:
- api-gateway-iam/.../application/service/ApiKeyApplicationService.java
- fx-liquidity-engine/.../application/service/FxQuoteApplicationService.java
- fx-liquidity-engine/.../application/service/FxRateLockApplicationService.java
- fx-liquidity-engine/.../test/.../application/service/FxQuoteApplicationServiceTest.java
- fx-liquidity-engine/.../test/.../application/service/FxRateLockApplicationServiceTest.java
Verified: api-gateway-iam + fx-liquidity-engine unit tests BUILD
SUCCESSFUL (rerun-tasks). Rule 3 now fully resolved.
* test(infra): address CodeRabbit review feedback on PR #270 (STA-249)
12 fixes addressing CodeRabbit review comments:
Production:
- merchant-iam: delete unused countActiveUsersByRoleId stub from
RoleRepository + adapter (role deletion validates in-memory via
MerchantTeam.deleteCustomRole).
Tests:
- MerchantCommandHandlerTest: replace hardcoded "raw-secret" literal
with UUID.randomUUID() reused between stub and expected event.
- ComplianceCheckCommandHandlerTest: use Mockito InOrder over all six
providers/repo/publisher to enforce cross-mock invocation sequence
(shouldInvokeAllProvidersInOrder).
- PaymentEventConsumerTest: assert shouldHaveNoInteractions() on
eventPublisher and poolRepository for all early-return branches
(idempotentConsumed, noLockFound, idempotentExpired, noLockFoundFailed).
- FxQuoteControllerTest: new @nested ReleaseLock with success (204) +
LockNotFoundException propagation.
- AuditLogFilterTest: extract shared expectedAuditEntry(...) helper;
add missing then(auditLogRepository).should().save(...) assertion in
shouldNotFailWhenRepositoryThrows so exception-handling path is
actually exercised.
- FxRateLockCommandHandlerTest: new @nested ReleaseLock with 4 tests —
LockNotFoundException, skip-when-already-expired, happy path with
liquidity return, pool-missing graceful handling.
- MerchantTeamServiceTest: replace argThat(Instant i -> i != null) with
ArgumentCaptor + isAfter(now) semantic check; replace publish(argThat(
Objects::nonNull)) with eqIgnoring on a fully-built expected event.
- KybWebhookControllerTest: add then(workflowClient).shouldHaveNoInteractions()
to invalid-signature test.
- PaymentCommandHandlerTest: strengthen idempotency-replay assertion —
verify findByIdempotencyKey was called + shouldHaveNoMoreInteractions().
- PaymentControllerTest: extract private stubInitiatePayment helper to
DRY up repeated given(commandHandler.initiatePayment(...)) blocks.
- LedgerOutboxEventPublisherTest: switch from eqIgnoring to ArgumentCaptor
so completedAt/detectedAt Instants are actually asserted (TestUtils.eqIgnoring
type-ignores all Instants by design — not suitable for timestamp verification).
Not fixed, documented in PR reply:
- JournalCommandHandler NPE hardening: CLAUDE.md forbids validation for
scenarios that cannot happen; BalanceUpdate key is guaranteed by
BalanceCalculator contract.
- PaymentWorkflowImpl hard-coded wallet/chain: pre-existing sandbox
placeholder from STA-243, out of scope for STA-249 cleanup.
- LockService duplicate liquidity check: pre-existing duplication
inherited from deleted FxRateLockApplicationService; requires touching
LockService which is out of scope. Follow-up ticket.
- CorridorSnapshot extraction to top-level: style preference. Inner
record is the minimal surface area for an internal projection.
Verified: ./gradlew test -x :phase2-integration-tests:test
-x :phase3-integration-tests:test BUILD SUCCESSFUL (128 tasks).1 parent 64e679b commit 4dafa44
99 files changed
Lines changed: 1492 additions & 2051 deletions
File tree
- api-gateway-iam/api-gateway-iam/src
- main/java/com/stablecoin/payments/gateway/iam/application
- controller
- security
- service
- test/java/com/stablecoin/payments/gateway/iam
- application
- controller
- security
- domain/service
- blockchain-custody/blockchain-custody/src
- main/java/com/stablecoin/payments/custody
- domain/service
- infrastructure/persistence
- test/java/com/stablecoin/payments/custody/infrastructure/provider/dev
- compliance-travel-rule/compliance-travel-rule/src
- main/java/com/stablecoin/payments/compliance
- application
- controller
- service
- domain
- model
- service
- infrastructure/provider
- chainalysis
- ofacsdn
- test/java/com/stablecoin/payments/compliance
- application
- controller
- service
- domain/service
- fiat-off-ramp/fiat-off-ramp/src/main/java/com/stablecoin/payments/offramp
- domain/service
- infrastructure
- persistence/entity
- provider/modulr
- fiat-on-ramp/fiat-on-ramp/src/main/java/com/stablecoin/payments/onramp
- domain/service
- infrastructure/provider/stripe
- fx-liquidity-engine/fx-liquidity-engine/src
- main/java/com/stablecoin/payments/fx
- application
- controller
- mapper
- service
- domain
- model
- service
- infrastructure/messaging
- test/java/com/stablecoin/payments/fx
- application
- controller
- service
- domain/service
- infrastructure/messaging
- ledger-accounting/ledger-accounting/src
- main/java/com/stablecoin/payments/ledger
- domain
- model
- service
- infrastructure/messaging
- test/java/com/stablecoin/payments/ledger
- domain/service
- infrastructure/messaging
- merchant-iam/merchant-iam/src
- main/java/com/stablecoin/payments/merchant/iam
- application/controller
- domain/team
- model
- infrastructure/persistence/adapter
- test/java/com/stablecoin/payments/merchant/iam/domain/team
- model/core
- merchant-onboarding/merchant-onboarding/src
- main/java/com/stablecoin/payments/merchant/onboarding
- application
- config
- controller
- service
- infrastructure
- kyb
- temporal/workflow
- test/java/com/stablecoin/payments/merchant/onboarding
- application/controller
- domain/merchant
- infrastructure/temporal/workflow
- payment-orchestrator/payment-orchestrator/src
- main/java/com/stablecoin/payments/orchestrator
- domain
- service
- workflow
- infrastructure/activity
- test/java/com/stablecoin/payments/orchestrator
- application/controller
- domain
- service
- workflow
- infrastructure/activity
- platform-infra/src/main/java/com/stablecoin/payments/platform/infrastructure
- http
- messaging
- tracing
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | | - | |
63 | 61 | | |
64 | 62 | | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
69 | | - | |
70 | 67 | | |
71 | 68 | | |
72 | 69 | | |
73 | 70 | | |
74 | 71 | | |
75 | 72 | | |
76 | | - | |
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
| |||
90 | 86 | | |
91 | 87 | | |
92 | 88 | | |
93 | | - | |
94 | 89 | | |
95 | 90 | | |
96 | 91 | | |
| |||
Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 0 additions & 80 deletions
This file was deleted.
Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 10 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | | - | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
59 | 62 | | |
60 | 63 | | |
61 | 64 | | |
62 | | - | |
| 65 | + | |
| 66 | + | |
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
| |||
Lines changed: 5 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 19 | | |
24 | 20 | | |
25 | 21 | | |
| |||
42 | 38 | | |
43 | 39 | | |
44 | 40 | | |
45 | | - | |
| 41 | + | |
| 42 | + | |
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
| |||
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
61 | | - | |
| 58 | + | |
| 59 | + | |
62 | 60 | | |
63 | 61 | | |
64 | 62 | | |
65 | | - | |
| 63 | + | |
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
| |||
0 commit comments