-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Overview
Review and enhance existing XML debug tests to include entity-specific marshalling validation for additional ESPI 4.0 entities.
Current State
Two XML debug test files exist but have limited coverage:
UsageXmlDebugTest.java
- Location:
openespi-common/src/test/java/org/greenbuttonalliance/espi/common/ - Current Coverage: Only tests UsagePoint entity marshalling
- JAXBContext Includes: TimeConfiguration, Authorization, ApplicationInformation (but not tested individually)
- Purpose: Validates
http://naesb.org/espinamespace handling
CustomerXmlDebugTest.java
- Location:
openespi-common/src/test/java/org/greenbuttonalliance/espi/common/ - Current Coverage: Only tests Customer entity marshalling
- JAXBContext Includes: Statement, StatementRef (but not tested individually)
- Purpose: Validates
http://naesb.org/espi/customernamespace handling
Gap Analysis
Both test files validate namespace declarations but don't test individual entity XML structure for several important entities already in their JAXBContext.
Required Enhancements
1. Review Existing Tests
- Review
UsageXmlDebugTest.javafor completeness - Review
CustomerXmlDebugTest.javafor completeness - Verify all entities in JAXBContext have corresponding test methods
2. Add Missing Entity Tests to UsageXmlDebugTest
Add entity-specific XML marshalling tests for:
- TimeConfiguration - Timezone and DST parameters (ESPI core entity)
- Authorization - OAuth2 authorization tokens (ESPI core entity)
- ApplicationInformation - Third-party app registration (ESPI core entity)
3. Add Missing Entity Tests to CustomerXmlDebugTest
Add entity-specific XML marshalling tests for:
- Statement - Billing statement (Phase 19 entity from customer.xsd)
- StatementRef - Statement reference (@embeddable from customer.xsd)
Test Requirements
Each entity-specific test should:
- Create entity with populated fields
- Marshal to XML string
- Validate XML structure matches ESPI 4.0 schema
- Verify namespace declarations are correct
- Validate element ordering per XSD propOrder
- Unmarshal back to entity to verify round-trip
Example Pattern
@Test
@DisplayName("Should marshal TimeConfiguration to ESPI XML")
void shouldMarshalTimeConfiguration() throws JAXBException {
// Arrange - create populated entity
TimeConfigurationEntity entity = new TimeConfigurationEntity();
// ... set fields
// Act - marshal to XML
String xml = marshalToString(entity);
// Assert - validate structure
assertThat(xml).contains("http://naesb.org/espi");
assertThat(xml).contains("<TimeConfiguration");
// ... additional assertions
}Priority Entities
Focus on these high-priority entities first:
- TimeConfiguration - Critical for timezone handling
- Authorization - Critical for OAuth2 security
- ApplicationInformation - Critical for third-party integration
- Statement - Newly implemented Phase 19 entity
- StatementRef - Newly implemented Phase 19 embedded type
Success Criteria
- All entities in JAXBContext have corresponding marshalling tests
- XML output validates against ESPI 4.0 XSD schema
- Round-trip marshalling/unmarshalling works correctly
- Test coverage includes namespace validation
- Test coverage includes element ordering validation
References
- ESPI 4.0 Schema:
openespi-common/src/main/resources/schema/ESPI_4.0/ - usage.xsd: Contains TimeConfiguration, Authorization, ApplicationInformation definitions
- customer.xsd: Contains Statement (lines 373-393), StatementRef (lines 285-307) definitions
Related Issues
- Phase 19 implementation completed in PR feat: ESPI 4.0 Schema Compliance - Phase 19: Statement Complete Implementation #102
- Part of ongoing ESPI 4.0 compliance validation