Phase 1B: carddemo-refdata Spring Boot service for reference data (types, categories, disclosure groups) - #212
Conversation
… categories, and disclosure groups
- JPA entities mapping COBOL copybooks CVTRA03Y, CVTRA04Y, CVTRA02Y
- Full CRUD REST API under /reference/{types,categories,disclosure-groups}
- Bean validation: type code length, category code range, interest rate precision
- PostgreSQL-backed with H2 test profile
- 63 passing tests (unit + integration)
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…9 responses Addresses Devin Review findings: - Custom DuplicateEntityException avoids catching unrelated IllegalArgumentExceptions as 409 - Null-safe message handling in GlobalExceptionHandler
| @Id | ||
| @Column(name = "category_code", nullable = false) | ||
| @Min(0) | ||
| @Max(9999) | ||
| private int categoryCode; |
There was a problem hiding this comment.
🚩 Primitive int PK fields silently default to 0 when omitted from JSON
The categoryCode field in TransactionCategory (TransactionCategory.java:39) and transactionCategoryCode in DisclosureGroup (DisclosureGroup.java:50) are primitive int, so Jackson defaults them to 0 when the JSON field is absent. Since @Min(0) allows 0, a POST request omitting the category code will silently create an entity with code 0 rather than rejecting the request. This is technically valid per the COBOL PIC 9(04) spec (range 0000–9999), but could surprise API consumers. Using Integer with @NotNull would make the field truly required in the JSON body.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Acknowledged — this is technically valid per the COBOL PIC 9(04) spec (range 0000–9999), so 0 is a legitimate category code. Switching to Integer + @NotNull would change the semantics by disallowing code 0, which the legacy system permits. Leaving as-is for fidelity to the COBOL layout.
| username: carddemo | ||
| password: carddemo |
There was a problem hiding this comment.
🚩 Hardcoded database credentials in application.yml shipped with the artifact
The main application.yml contains username: carddemo and password: carddemo (application.yml:7-8). While these are documented as development defaults in the README, they are baked into the packaged JAR. If the application is deployed without overriding these properties via environment variables or external config, it would attempt to connect with these credentials. For a service intended to be deployed as a microservice, consider using placeholder syntax (e.g., ${DB_PASSWORD}) to force explicit configuration at deployment time.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Acknowledged — these are intentional development defaults for local/demo usage. Spring Boot's externalized config (env vars, --spring.datasource.password=..., or external application.yml) will override at deployment time. This matches the pattern used in the other CardDemo modernization modules.
…creates Catches constraint violations from concurrent inserts that pass the existsById check but hit the DB unique constraint, returning 409 instead of 500.
Summary
New
services/carddemo-refdataSpring Boot 3.3 module that replaces the COBOL/DB2 reference-data subsystem (COTRTLIC,COTRTUPC,COBTUPDT) with a REST API backed by PostgreSQL (H2 for tests).Three JPA entities mirror the legacy copybook record layouts:
CVTRA03Y(RECLN=60)TransactionTypetypeCode CHAR(2)CVTRA04Y(RECLN=60)TransactionCategory(typeCode, categoryCode)compositeCVTRA02Y(RECLN=50)DisclosureGroup(accountGroupId, transactionTypeCode, transactionCategoryCode)compositeREST endpoints — full CRUD under
/reference/:Validation enforces COBOL field constraints: type code max 2 chars, category code 0–9999, interest rate as
BigDecimalwith@Digits(integer=4, fraction=2)matchingPIC S9(04)V99.63 tests pass (unit tests with Mockito for services,
@SpringBootTestintegration tests with MockMvc + H2 for controllers,@DataJpaTestfor repositories).Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/31f7cb3a9d244544898908c73ce02252
Requested by: @DhrovS