-
Notifications
You must be signed in to change notification settings - Fork 1
feat: ESPI 4.0 Schema Compliance - Phase 25: EndDevice + DTO Cleanup #94
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
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
…t backfill - Complete EndDevice ESPI 4.0 schema compliance plan - Backfill missing integration tests for Phases 18, 23, 24 - 17 files total: 2 modified, 15 created - Expected 756+ tests (660 unit + 96 integration) Related to #28 Phase 25
- Extract ElectronicAddressDto from CustomerDto nested class - Extract LifecycleDateDto from EndDeviceDto nested class - Extract AcceptanceTestDto from EndDeviceDto nested class - Update all references across DTOs and mappers - Remove duplicate equals/hashCode from MeterEntity (inherited from EndDeviceEntity) Benefits: - No artificial dependencies (EndDevice no longer depends on CustomerDto) - Better reusability (Meter will use LifecycleDateDto and AcceptanceTestDto) - Consistent pattern (matches StatusDto being separate) - Easier testing and maintenance Related to #28 Phase 25 Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Resource DTOs must ONLY contain fields defined in customer.xsd. - Removed id field (not in XSD) - Removed uuid/@XmlAttribute mRID (not in XSD) Per ESPI 4.0 Atom protocol pattern: - AtomEntryDto handles resource identification (<id> element) - Resource DTOs contain ONLY XSD-defined fields - Service layer maps between entity.id and AtomEntryDto.id This ensures: ✅ Strict XSD schema compliance ✅ No mRID attribute on resource elements ✅ Clean separation: Atom wrapper vs resource content Related to #28 Phase 25 Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…88) ## Phase 25: EndDevice Implementation ### New Files - EndDeviceMapper.java - Entity-to-DTO mapping with LifecycleDateMapper and AcceptanceTestMapper - EndDeviceRepository.java - JPA repository for EndDevice persistence - EndDeviceService.java + EndDeviceServiceImpl.java - Service layer for EndDevice operations - EndDeviceDtoTest.java - Unit tests for EndDevice DTO XML marshalling - EndDeviceRepositoryTest.java - Unit tests for EndDevice repository operations ### EndDeviceDto Enhancements - Rewritten to match ESPI 4.0 customer.xsd structure - Added 16 XSD-compliant fields (12 Asset + 4 EndDevice) - Removed Atom protocol fields (id, published, updated, links) - Proper namespace: http://naesb.org/espi/customer ## ESPI 4.0 DTO Cleanup (All DTOs) ### Customer Domain DTOs (4 files) - CustomerDto, CustomerAccountDto, CustomerAgreementDto, ServiceLocationDto - Removed uuid field for strict XSD compliance - AtomEntryDto now handles all Atom protocol metadata ### Usage Domain DTOs (9 files) - UsagePointDto, MeterReadingDto, IntervalBlockDto, ReadingTypeDto - TimeConfigurationDto, UsageSummaryDto, ElectricPowerQualitySummaryDto - ApplicationInformationDto, AuthorizationDto - Removed id and uuid fields for strict ESPI 4.0 compliance - Resource DTOs contain ONLY XSD-defined fields ### JAXB Marshalling Fixes - Added @XmlJavaTypeAdapter(OffsetDateTimeAdapter.class) to: - LifecycleDateDto: manufacturedDate, installationDate - AcceptanceTestDto: dateTime - Ensures proper ISO-8601 timestamp serialization in XML ### NotificationMethodKind Enum Fix - Updated to match customer.xsd enumeration exactly - XSD values: CALL, EMAIL, LETTER, OTHER, IVR - Fixed: PHONE → CALL, removed SMS and IN_PERSON (not in XSD) ## Integration Tests (8 new files) ### Phase 18 Backfill - CustomerAccountMySQLIntegrationTest.java - CustomerAccountPostgreSQLIntegrationTest.java ### Phase 23 Backfill - ServiceLocationMySQLIntegrationTest.java - ServiceLocationPostgreSQLIntegrationTest.java ### Phase 24 Backfill - CustomerAgreementMySQLIntegrationTest.java - CustomerAgreementPostgreSQLIntegrationTest.java ### Phase 25 - EndDeviceMySQLIntegrationTest.java - EndDevicePostgreSQLIntegrationTest.java ### TestDataBuilders Enhancement - Added 4 helper methods: createValidCustomerAccount, createValidServiceLocation createValidCustomerAgreement, createValidEndDevice ## Test Fixes (16 files) ### DTO Constructor Signature Updates - Fixed 46 constructor calls across 16 test files - Removed first uuid/id parameter to match cleaned DTO signatures - Pattern: new CustomerDto(uuid, ...) → new CustomerDto(...) ### ElectronicAddressDto Import Fixes - Updated imports in 5 files to reference standalone class - Changed CustomerDto.ElectronicAddressDto → ElectronicAddressDto ## Database Migration - Verified end_devices table in V3__Create_additiional_Base_Tables.sql - All 16 EndDevice XSD fields properly mapped to database columns ## Test Results - Unit Tests: 654 tests, 0 failures, 0 errors - Integration Tests: 99 tests, 0 failures, 0 errors - BUILD SUCCESS ## ESPI 4.0 Compliance Achievement ✅ All customer domain DTOs strictly XSD-compliant ✅ All usage domain DTOs strictly XSD-compliant ✅ Resource DTOs contain ONLY XSD fields (no Atom metadata) ✅ AtomEntryDto handles id, published, updated, links ✅ MapStruct: @mapping(target = "id", ignore = true) in toEntity methods only ✅ Service layer maps entity.id ↔ AtomEntryDto.id Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
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
Phase 25: EndDevice Implementation
New Components
✅ EndDeviceMapper.java - Entity-to-DTO mapping with LifecycleDateMapper and AcceptanceTestMapper
✅ EndDeviceRepository.java - JPA repository
✅ EndDeviceService.java + EndDeviceServiceImpl.java - Service layer
✅ EndDeviceDtoTest.java - XML marshalling tests
✅ EndDeviceRepositoryTest.java - Repository tests
EndDeviceDto Structure
ESPI 4.0 DTO Cleanup (Breaking Change)
Affected DTOs (13 files)
Customer Domain (4 DTOs):
Usage Domain (9 DTOs):
Changes Applied
idfield (Long) from all DTOsuuidfield (String) from all DTOs@Mapping(target = "id", ignore = true)in toEntity methods onlyIntegration Tests Backfill (8 new files)
Phase 18 Backfill: CustomerAccount
Phase 23 Backfill: ServiceLocation
Phase 24 Backfill: CustomerAgreement
Phase 25: EndDevice
Each integration test follows consistent pattern:
Bug Fixes
NotificationMethodKind Enum Alignment
Issue: Java enum values didn't match customer.xsd enumeration
Before:
After (matches XSD):
XSD Reference: customer.xsd lines 1961-1996
JAXB OffsetDateTime Marshalling
Issue: OffsetDateTime fields serializing as empty elements
Fix: Added
@XmlJavaTypeAdapter(OffsetDateTimeAdapter.class)to:Result: Proper ISO-8601 timestamp serialization in XML
Test Constructor Signature Updates
Fixed 46 constructor calls across 16 test files:
Pattern Applied:
ElectronicAddressDto Import Fixes
Issue: Tests referencing
CustomerDto.ElectronicAddressDto(nested class)Fix: Updated 5 files:
import org.greenbuttonalliance.espi.common.dto.customer.ElectronicAddressDto;CustomerDto.ElectronicAddressDto→ElectronicAddressDtoTest Results
Unit Tests
Integration Tests
Coverage
Database Migration
✅ Verified end_devices table in V3__Create_additiional_Base_Tables.sql
ESPI 4.0 Compliance Achievement
✅ Customer Domain DTOs - All strictly XSD-compliant
✅ Usage Domain DTOs - All strictly XSD-compliant
✅ Resource DTOs - Contain ONLY XSD fields (no Atom metadata)
✅ AtomEntryDto - Handles id, published, updated, links
✅ MapStruct Mappings - Proper ignore patterns
✅ Service Layer - Correct entity.id ↔ AtomEntryDto.id mapping
✅ NotificationMethodKind - Matches customer.xsd enumeration
✅ JAXB Marshalling - OffsetDateTime fields serialize correctly
Breaking Changes
All DTO constructors no longer accept
idoruuidparameters. Code using these constructors must be updated:PHONE→CALLSMS→ removed (not in XSD)IN_PERSON→ removed (not in XSD)IVR→ added (from XSD)Migration Guide
For Developers
id/uuidparameterPHONE→CALLmvn testFor API Consumers
Files Changed
Checklist
🤖 Generated with Claude Code