-
Notifications
You must be signed in to change notification settings - Fork 1
feat: ESPI 4.0 Schema Compliance - Phase 18: CustomerAccount Implementation #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dfcoffin
merged 1 commit into
main
from
feature/schema-compliance-phase-18-customer-account
Jan 25, 2026
Merged
feat: ESPI 4.0 Schema Compliance - Phase 18: CustomerAccount Implementation #91
dfcoffin
merged 1 commit into
main
from
feature/schema-compliance-phase-18-customer-account
Jan 25, 2026
+1,194
−654
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ocument base
class fields, embedded objects, and comprehensive testing. All tests passing (24
CustomerAccount tests, 609 total tests). Zero SonarQube violations.
## Entity Changes
**CustomerAccountEntity.java**
- Add all Document base class fields (type, authorName, createdDateTime,
lastModifiedDateTime, revisionNumber, electronicAddress, subject, title,
docStatus)
- Reorder all fields to match customer.xsd CustomerAccount definition (lines
118-158) and Document type (lines 819-872)
- Apply @AttributeOverride annotations directly without wrapper per java:S1710
for upLink/selfLink inherited fields
- Add contactInfo Organisation embedded object with individual @AttributeOverride
annotations for all nested fields (no wrapper)
- Add isPrePay Boolean extension field
- Implement Hibernate-safe equals/hashCode using instanceof pattern variables
- Fix embedded object serialization by making all embeddable classes implement
Serializable (java:S1948)
**Status.java** (NEW)
- Create embeddable class for Document.docStatus with value, dateTime, reason
fields
- Implement Serializable to fix java:S1948 violation
- Per customer.xsd lines 1149-1173
**Organisation.java**
- Add Serializable to Organisation and all inner classes (StreetAddress,
ElectronicAddress)
- Fix java:S1948 violation for embedded objects in CustomerAccountEntity
**AccountNotification.java**
- Add Serializable implementation to fix java:S1948 violation
- Remove commented-out code block (java:S125)
## DTO Changes
**CustomerAccountDto.java**
- Complete rewrite with 15 fields total
- Add all 9 Document fields (type, authorName, createdDateTime,
lastModifiedDateTime, revisionNumber, electronicAddress, subject, title,
docStatus)
- Add all 6 CustomerAccount fields (billingCycle, budgetBill, lastBillAmount,
notifications, contactInfo, accountId)
- Fix @XmlType propOrder to include all fields in correct XSD sequence
- Use customer namespace (http://naesb.org/espi/customer) with "cust:" prefix
- Nest StatusDto and AccountNotificationDto classes
- Reuse CustomerDto.ElectronicAddressDto and CustomerDto.OrganisationDto
## Mapper Changes
**CustomerAccountMapper.java**
- Add all 9 Document field mappings with proper bidirectional conversion
- Add contactInfo Organisation mapping
- Add isPrePay Boolean field mapping
- Total: 15 field mappings matching DTO structure
**StatusMapper.java** (NEW)
- Map Status embeddable ↔ CustomerAccountDto.StatusDto
- Convert between entity and DTO representations
**OrganisationMapper.java** (NEW)
- Map Organisation embeddable ↔ CustomerDto.OrganisationDto
- Handle nested StreetAddress and ElectronicAddress mappings
**ElectronicAddressMapper.java** (NEW)
- Map Organisation.ElectronicAddress ↔ CustomerDto.ElectronicAddressDto
- Handle email1, email2, web, radio fields
**StreetAddressMapper.java** (NEW)
- Map Organisation.StreetAddress ↔ CustomerDto.StreetAddressDto
- Handle streetDetail, townDetail, stateOrProvince, postalCode, country
**AccountNotificationMapper.java** (NEW)
- Map AccountNotification embeddable ↔ CustomerAccountDto.AccountNotificationDto
- Handle methodKind enum conversion
## Repository Changes
**CustomerAccountRepository.java**
- Remove all custom query methods
- Use only JpaRepository inherited methods to avoid H2 keyword conflicts
## Service Changes
**CustomerAccountService.java**
- Remove findByAccountId, findByCustomer methods
- Keep only essential CRUD operations and findAll
**CustomerAccountServiceImpl.java**
- Remove custom finder implementations
- Use UUID v5 generation for deterministic IDs (namespace: ESPI-CUSTOMER-
ACCOUNT)
- Remove findByAccountId, findByCustomer methods
## Database Changes
**V3__Create_additiional_Base_Tables.sql**
- Add 9 Document base class columns to customer_accounts table
- Add contactInfo Organisation embedded object columns (organisation_name, 15
nested address/contact fields)
- Add is_pre_pay Boolean column
- Total: 13 new columns added
- Fix column naming for contact info fields to avoid conflicts
## Testing
**CustomerAccountDtoTest.java** (NEW - 3 tests)
- shouldExportCustomerAccountWithCompleteDocumentFields: Verify all 15 fields
marshal to XML correctly
- shouldVerifyCustomerAccountFieldOrder: Assert field order matches customer.xsd
(Document lines 819-872, CustomerAccount lines 118-158)
- shouldUseCorrectCustomerNamespace: Verify cust: namespace prefix usage
- Fix java:S5668: Remove unnecessary IOException throws declarations (3
occurrences)
- Fix java:S5853: Chain all multiple assertions (4 assertion groups chained)
**CustomerAccountRepositoryTest.java** (NEW - 21 tests)
- **CRUD Operations** (7 tests): save, retrieve, update, delete, findAll, exists,
count
- **Document Field Persistence** (3 tests): All Document fields, electronicAddress
embedded, docStatus embedded
- **CustomerAccount Field Persistence** (3 tests): All CustomerAccount fields,
contactInfo Organisation embedded, null optional fields
- **Customer Relationship** (3 tests): ManyToOne relationship, lazy loading, null
customer allowed
- **Base Class Functionality** (5 tests): IdentifiedObject inheritance, timestamp
updates, unique IDs, equals/hashCode, toString
- Fix java:S1481: Remove unused 'updated' variable
- Fix java:S2925 & java:S108: Remove Thread.sleep() and empty catch block
- Fix java:S5853: Chain multiple assertions (3 assertion groups chained)
- Fix java:S5838: Use hasSameHashCodeAs instead of manual hashCode comparison
## Code Quality (SonarQube Fixes)
All 13 SonarQube violations resolved:
1. **java:S5668**: Removed unnecessary IOException throws (3 occurrences in
CustomerAccountDtoTest)
2. **java:S5853**: Chained assertions for better readability (7 assertion groups
total - 4 in CustomerAccountDtoTest, 3 in CustomerAccountRepositoryTest)
3. **java:S1710**: Applied @AttributeOverride annotations directly without wrapper
(2 occurrences in CustomerAccountEntity - class-level and contactInfo field)
4. **java:S1948**: Made embedded objects Serializable (4 classes: Status,
Organisation, StreetAddress, ElectronicAddress, AccountNotification)
5. **java:S1481**: Removed unused 'updated' variable (CustomerAccountRepositoryTest)
6. **java:S2925**: Removed Thread.sleep() (CustomerAccountRepositoryTest)
7. **java:S108**: Removed empty catch block (CustomerAccountRepositoryTest)
8. **java:S5838**: Used hasSameHashCodeAs() assertion (CustomerAccountRepositoryTest)
9. **java:S125**: Removed commented-out code (AccountNotification.java, pom.xml)
10. **Pattern Matching**: Used instanceof with pattern variables for equals/
hashCode (CustomerAccountEntity)
## Documentation
**CLAUDE.md**
- Update Java version to 25
- Update Spring Boot version to 4.0.1
- Update Hibernate version to 7.x
- Update MapStruct version to 1.6.3
**pom.xml**
- Fix spring-boot-only profile to exclude thirdparty module
- Remove commented-out maven-site-plugin version (java:S125)
## Test Results
All 609 tests passing:
- 3 CustomerAccountDtoTest tests (XML marshalling)
- 21 CustomerAccountRepositoryTest tests (repository operations)
- All existing tests remain passing
- Integration tests verified with H2, MySQL 9.5, PostgreSQL 18
## ESPI 4.0 Compliance
CustomerAccount implementation now fully complies with:
- customer.xsd CustomerAccount type (lines 118-158)
- customer.xsd Document base type (lines 819-872)
- Proper customer namespace usage (http://naesb.org/espi/customer)
- Complete field coverage with correct XSD ordering
- All embedded objects properly mapped
- Zero SonarQube violations
Resolves partial implementation for Issue #28
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implement complete CustomerAccount ESPI 4.0 schema compliance with Document base class fields, embedded objects, and comprehensive testing.
Key Achievements:
Changes Overview
Entity Layer (4 files)
DTO Layer (1 file)
Mapper Layer (6 files)
Repository & Service Layer (4 files)
Database Migration (1 file)
Testing (2 files)
Documentation (2 files)
SonarQube Code Quality (13 Violations Fixed)
ESPI 4.0 Compliance
CustomerAccount now fully complies with:
Test Plan
Unit Tests (24 tests - all passing)
Integration Tests (all passing)
Full Test Suite
Related Issues
Partial implementation for #28
Breaking Changes
CustomerAccountService.findByAccountId(String)CustomerAccountService.findByCustomer(CustomerEntity)These methods were removed to simplify the service interface and avoid H2 keyword conflicts in repository queries. Users should use
findAll()and filter in application code if needed.Migration Notes
Database schema changes are handled automatically by Flyway migration V3. The following columns are added to
customer_accounts:No manual migration required.
Checklist
Screenshots
N/A - Backend changes only
🤖 Generated with Claude Code