Skip to content

Enhance XML Debug Tests for Additional ESPI Entities #103

@dfcoffin

Description

@dfcoffin

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/espi namespace 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/customer namespace 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.java for completeness
  • Review CustomerXmlDebugTest.java for 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:

  1. Create entity with populated fields
  2. Marshal to XML string
  3. Validate XML structure matches ESPI 4.0 schema
  4. Verify namespace declarations are correct
  5. Validate element ordering per XSD propOrder
  6. 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:

  1. TimeConfiguration - Critical for timezone handling
  2. Authorization - Critical for OAuth2 security
  3. ApplicationInformation - Critical for third-party integration
  4. Statement - Newly implemented Phase 19 entity
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions