Commit 4441d92
feat: ESPI 4.0 Schema Compliance - Phase 19: Statement Complete Implementation (#102)
* feat: ESPI 4.0 Schema Compliance - Phase 19: Statement Complete Implementation
Complete implementation of Statement and StatementRef entities per customer.xsd
specification (lines 285-307, 373-393) following Phase 17/18 patterns.
Schema Compliance Changes:
- StatementRefEntity: Changed from @entity to @embeddable (extends Object, not IdentifiedObject)
- Removed UUID primary key, now stored as @ElementCollection in StatementEntity
- statement_refs table: Removed id column, now collection table with statement_id FK only
- StatementDto: Removed ALL IdentifiedObject fields, keeps ONLY issueDateTime + statementRef per XSD
- StatementRefDto: Fixed to match XSD (fileName, mediaType, statementURL only)
Entity Enhancements:
- Added @manytoone relationships for Controller API navigation:
* customer_id → CustomerEntity
* customer_account_id → CustomerAccountEntity
* customer_agreement_id → CustomerAgreementEntity
* usage_summary_id → UsageSummaryEntity
- Updated toString() to follow database field sequence per CLAUDE.md guidelines
- @AssociationOverride for statement_related_links (bidirectional Atom protocol links)
Database Migration (V3):
- statements table: Added customer_account_id, customer_agreement_id, usage_summary_id FKs
- Removed non-schema fields: statement_date, billing_period_start, billing_period_duration
- statement_refs table: Restructured as @ElementCollection table (no id column)
- Added indexes for all relationship foreign keys
Mapper Implementation:
- StatementMapper: Maps ONLY customer.xsd fields (issueDateTime, statementRef)
- StatementRefMapper: Direct 1:1 field mapping (3 fields)
- Uses qualifiedByName for DateTimeMapper epoch conversions
- Follows DRY principle - Atom metadata handled by AtomEntryDto/LinkDto
Repository & Service Simplification:
- Removed 7 non-ID query methods from StatementRepository
- Added 4 ID-based relationship queries (Customer, CustomerAccount, CustomerAgreement, UsageSummary)
- Removed 10 methods from StatementService (date/description/count queries)
- Kept only CRUD + ID-based operations per ESPI compliance patterns
Resolves #28 Phase 19
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* test: Add comprehensive test suite for Phase 19 Statement implementation
Test Coverage:
- StatementRepositoryTest: 7 tests for CRUD + ID-based relationship queries
- StatementPostgreSQLIntegrationTest: 4 tests with real PostgreSQL TestContainer
- StatementMySQLIntegrationTest: 4 tests with real MySQL TestContainer
Key Test Scenarios:
- @ElementCollection StatementRef persistence (no id column)
- All 4 relationship queries (Customer, CustomerAccount, CustomerAgreement, UsageSummary)
- Cascading delete of @ElementCollection
- CRUD operations with real databases
Results: 781 total tests passing (added 15 new tests)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix: Truncate timestamps to microseconds for cross-platform compatibility
Issue: CI/CD failing due to timestamp precision mismatch between platforms
- Windows: microseconds (6 decimals)
- Linux/Mac: nanoseconds (9 decimals)
Solution: Truncate all test timestamps to MICROS using .truncatedTo(ChronoUnit.MICROS)
Changes:
- StatementRepositoryTest: 3 occurrences fixed
- StatementMySQLIntegrationTest: 3 occurrences fixed
- StatementPostgreSQLIntegrationTest: 3 occurrences fixed
Results: All 781 tests passing locally
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 18a8e8b commit 4441d92
13 files changed
Lines changed: 926 additions & 841 deletions
File tree
- openespi-common/src
- main
- java/org/greenbuttonalliance/espi/common
- domain/customer/entity
- dto/customer
- mapper/customer
- repositories/customer
- service/customer
- impl
- resources/db/migration
- test/java/org/greenbuttonalliance/espi/common/repositories
- customer
- integration
Lines changed: 33 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | | - | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
71 | 97 | | |
72 | 98 | | |
73 | 99 | | |
| |||
88 | 114 | | |
89 | 115 | | |
90 | 116 | | |
91 | | - | |
92 | 117 | | |
93 | 118 | | |
94 | 119 | | |
95 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
96 | 125 | | |
97 | 126 | | |
Lines changed: 14 additions & 61 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 26 | + | |
29 | 27 | | |
30 | | - | |
31 | | - | |
| 28 | + | |
32 | 29 | | |
33 | 30 | | |
34 | | - | |
| 31 | + | |
35 | 32 | | |
36 | 33 | | |
37 | 34 | | |
38 | | - | |
39 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
40 | 38 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 39 | + | |
| 40 | + | |
45 | 41 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 42 | + | |
| 43 | + | |
56 | 44 | | |
57 | 45 | | |
58 | 46 | | |
| |||
67 | 55 | | |
68 | 56 | | |
69 | 57 | | |
70 | | - | |
| 58 | + | |
71 | 59 | | |
72 | 60 | | |
73 | 61 | | |
74 | 62 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 63 | | |
Lines changed: 21 additions & 80 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
30 | | - | |
31 | 28 | | |
32 | 29 | | |
33 | 30 | | |
34 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | | - | |
37 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 55 | | |
111 | | - | |
112 | | - | |
113 | | - | |
| 56 | + | |
| 57 | + | |
114 | 58 | | |
115 | | - | |
116 | | - | |
117 | | - | |
| 59 | + | |
| 60 | + | |
118 | 61 | | |
119 | 62 | | |
120 | | - | |
121 | | - | |
122 | | - | |
| 63 | + | |
| 64 | + | |
123 | 65 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
Lines changed: 27 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | 28 | | |
31 | | - | |
| 29 | + | |
32 | 30 | | |
33 | | - | |
| 31 | + | |
34 | 32 | | |
35 | | - | |
36 | | - | |
| 33 | + | |
| 34 | + | |
37 | 35 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
46 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
65 | 59 | | |
66 | | - | |
67 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
68 | 66 | | |
69 | 67 | | |
70 | | - | |
| 68 | + | |
| 69 | + | |
71 | 70 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
0 commit comments