Skip to content

Commit a0d113c

Browse files
dfcoffinclaude
andauthored
feat: Phase 1 - TimeConfiguration ESPI 4.0 schema compliance with JAXB (#51)
* feat: Phase 1 - TimeConfiguration ESPI 4.0 schema compliance with JAXB Implements Phase 1 of 26-phase NAESB ESPI 4.0 schema compliance plan using JAXB (Jakarta XML Binding) for XML marshalling/unmarshalling on Spring Boot 4.0.1 and Java 25. ## Implementation **DTO Layer (JAXB):** - TimeConfigurationDto: JAXB DTO with @XmlRootElement and XSD propOrder compliance - Byte array cloning for DST rules (defensive copying) - Utility methods: getTzOffsetInHours(), getEffectiveOffset(), hasDstRules() - All 11 XML marshalling/unmarshalling tests passing **Mapper Layer:** - TimeConfigurationMapper: MapStruct bidirectional Entity-DTO conversion - UUID handling: Entity.id → DTO.uuid mapping - Ignores transient and managed fields **Repository:** - Removed 3 XPath-based query methods (non-index queries) - Retained 2 index-based query methods: findAllIds(), findAllIdsByUsagePointId() **Database Migration:** - V4__Create_Time_Configurations.sql: XSD propOrder column sequence - Indexes on created, updated, tz_offset ## Code Quality (SonarQube Fixes) **TimeConfigurationDtoTest:** - Replaced generic "throws Exception" with specific "throws JAXBException" (3 methods) - Fixed variable naming to match camelCase convention (utcMinusEight, utcPlusFivePointFive) - Methods that call marshaller/unmarshaller now declare JAXBException **TimeConfigurationRepositoryTest:** - Chained assertions for better readability (3 locations) - Removed unused variables (2 occurrences) - Used hasSameHashCodeAs() for hashCode assertion **SonarQube Configuration:** - Created sonar-project.properties to exclude Oracle-specific SQL rules - Project uses MySQL, PostgreSQL, H2 - VARCHAR2 rule doesn't apply - Configured multicriteria exclusions for sql:S6397 and sql:Oracle* rules ## Testing - ✅ All 11 TimeConfigurationDtoTest tests pass (Spring Boot 4.0 + Java 25) - ✅ XML marshalling/unmarshalling validated - ✅ JAXB functionality verified with realistic timezone data - ✅ Round-trip marshalling integrity confirmed ## Documentation **Analysis Documents:** - DTO_APPROACH_COMPARISON.md: JAXB vs Jackson XML evaluation - PR50_MULTI_PHASE_IMPACT.md: Spring Boot 4.0 upgrade impact on all 26 phases - PR50_TEST_FAILURE_FIX.md: Timestamp precision test fix - JUNIE_VS_CLAUDE_GUIDELINES_COMPARISON.md: Test pattern migration guide **Plan Updates:** - MULTI_PHASE_SCHEMA_COMPLIANCE_PLAN.md: Updated with Spring Boot 4.0 stack - Added comprehensive Spring Boot 4.0 test patterns for remaining 25 phases ## Technology Stack - Java 25 (LTS - Zulu 25.28+85-CA) - Spring Boot 4.0.1 - Jakarta EE 11 - JAXB (jakarta.xml.bind-api 4.x) - MapStruct 1.6.3 Team Decision: JAXB selected for all 26 phases due to Jackson 3.0 XML immaturity in Spring Boot 4.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix: Remove duplicate V4 Flyway migration - table already exists in V2 The time_configurations table was already created in V2__MySQL_Specific_Tables.sql because it contains BLOB columns requiring vendor-specific handling. The V4 migration was attempting to create the same table, causing CI/CD failures with error: SQL State: 42S01 Error Code: 1050 Message: Table 'time_configurations' already exists Changes: - Deleted openespi-common/src/main/resources/db/migration/V4__Create_Time_Configurations.sql - Fixed openespi-thirdparty/pom.xml artifactId capitalization for consistency Related to #51 (Phase 1: TimeConfiguration DTO implementation) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.5 <[email protected]>
1 parent 81322fc commit a0d113c

File tree

14 files changed

+2845
-81
lines changed

14 files changed

+2845
-81
lines changed

MULTI_PHASE_SCHEMA_COMPLIANCE_PLAN.md

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,37 @@
44

55
This plan reviews domain entities in `/domain/usage`, `/domain/customer`, and `/domain/common` to ensure compliance with NAESB ESPI 4.0 schema (espi.xsd and customer.xsd) element sequences.
66

7+
---
8+
9+
## Technology Stack
10+
11+
**Baseline (Spring Boot 4.0 + Java 25):**
12+
- **Java**: 25 (LTS - Zulu 25.28+85-CA)
13+
- **Spring Boot**: 4.0.1
14+
- **Jakarta EE**: 11
15+
- **Maven**: 3.9+
16+
- **MapStruct**: 1.6.3
17+
- **JAXB**: jakarta.xml.bind-api 4.x
18+
- **TestContainers**: 1.20.x
19+
20+
**Testing Framework:**
21+
- **JUnit**: 5.x (JUnit Platform 6.0.1)
22+
- **Mockito**: 5.x via @MockitoBean/@MockitoSpyBean (Spring Boot 4.0)
23+
- **AssertJ**: 3.x
24+
- **Test Dependencies**: Granular test starters:
25+
- `spring-boot-starter-webmvc-test`
26+
- `spring-boot-starter-data-jpa-test`
27+
- `spring-boot-starter-validation-test`
28+
- `spring-boot-starter-restclient-test`
29+
30+
**DTO Marshalling Approach:**
31+
- **JAXB (Jakarta XML Binding)** - Selected for all 26 phases
32+
- **Rationale**: Jackson 3.0 XML support is immature in Spring Boot 4.0; JAXB provides proven, stable XML schema compliance with strict XSD element sequencing
33+
34+
**IMPORTANT:** All 26 phases are implemented against the Spring Boot 4.0 + Java 25 baseline established by PR #50 (merged 2025-12-29).
35+
36+
---
37+
738
**Excluded Entities** (already completed):
839
- ApplicationInformationEntity
940
- AuthorizationEntity
@@ -66,11 +97,18 @@ This plan reviews domain entities in `/domain/usage`, `/domain/customer`, and `/
6697
- `db/vendor/mysql/V2__MySQL_Specific_Tables.sql`
6798
- `db/vendor/postgres/V2__PostgreSQL_Specific_Tables.sql`
6899

69-
7. **Testing**:
70-
- Update unit tests for TimeConfiguration entity, service, repository
71-
- Add/update integration tests using TestContainers
72-
- Add XML marshalling/unmarshalling tests to verify schema compliance
73-
- Validate generated XML against espi.xsd using XSD schema validation
100+
7. **Testing** (Spring Boot 4.0 Patterns):
101+
- **Unit Tests**: Update tests for TimeConfiguration entity, service, repository
102+
- Use `@MockitoBean` instead of deprecated `@MockBean`
103+
- Use `@MockitoSpyBean` instead of deprecated `@SpyBean`
104+
- Add `@AutoConfigureMockMvc` if using `@SpringBootTest` with web layer
105+
- **Integration Tests**: Add/update tests using TestContainers
106+
- TestContainers dependency: `org.testcontainers:testcontainers-junit-jupiter` (artifact ID changed in Spring Boot 4.0)
107+
- **XML Marshalling Tests**: Create JAXB XML marshalling/unmarshalling tests
108+
- Use pure JUnit 5 (no Spring Boot test dependencies required)
109+
- Verify element sequence matches espi.xsd
110+
- Test round-trip serialization (marshal → unmarshal → verify equality)
111+
- **XSD Validation**: Validate generated XML against espi.xsd using schema validation
74112

75113
8. **Commit, Push, PR**:
76114
- Stage all changes: `git add .`
@@ -1120,8 +1158,24 @@ This 26-phase plan ensures comprehensive schema compliance review for all NAESB
11201158
**Git Branch Naming Pattern**:
11211159
`feature/schema-compliance-phase-{number}-{entity-name}`
11221160

1123-
**Test Requirements**:
1124-
- Unit tests for entity, service, repository
1125-
- Integration tests using TestContainers (MySQL, PostgreSQL, H2)
1126-
- XML marshalling/unmarshalling tests for ALL phases
1127-
- XSD schema validation (espi.xsd for usage domain, customer.xsd for customer domain)
1161+
**Test Requirements** (Spring Boot 4.0 + Java 25):
1162+
- **Unit Tests**: Entity, service, repository tests using:
1163+
- `@MockitoBean` (NOT `@MockBean` - deprecated in Spring Boot 4.0)
1164+
- `@MockitoSpyBean` (NOT `@SpyBean` - deprecated in Spring Boot 4.0)
1165+
- `@AutoConfigureMockMvc` annotation required when using `@SpringBootTest` with web layer
1166+
- **Integration Tests**: TestContainers for MySQL, PostgreSQL, H2
1167+
- Dependency: `org.testcontainers:testcontainers-junit-jupiter` (artifact ID changed from `junit-jupiter`)
1168+
- **XML Marshalling Tests**: JAXB XML marshalling/unmarshalling tests for ALL 26 phases
1169+
- Pure JUnit 5 tests (no Spring Boot test dependencies needed)
1170+
- Verify XSD element sequence compliance
1171+
- Test round-trip serialization
1172+
- **XSD Schema Validation**:
1173+
- Usage domain (Phases 1-16): Validate against `espi.xsd`
1174+
- Customer domain (Phases 17-26): Validate against `customer.xsd`
1175+
1176+
**Spring Boot 4.0 Migration Notes:**
1177+
- Test annotation package relocations:
1178+
- `@WebMvcTest`: `org.springframework.boot.webmvc.test.autoconfigure` (moved from `org.springframework.boot.test.autoconfigure.web.servlet`)
1179+
- `@DataJpaTest`: `org.springframework.boot.data.jpa.test.autoconfigure` (moved from `org.springframework.boot.test.autoconfigure.orm.jpa`)
1180+
- Granular test dependencies replace single `spring-boot-starter-test`
1181+
- See `.junie/guidelines.md` for comprehensive Spring Boot 4.0 test migration guidance

0 commit comments

Comments
 (0)