From 3d40c14fd6653159fec3ba9f064d9f5f5b720cd3 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 3 Feb 2026 01:21:09 +0100 Subject: [PATCH 1/3] Upgrade to NeTEx 2.0 schema - Update bindings.xjb for NeTEx 2.0 schema changes: - TariffZone_ renamed to TariffZone_Dummy - Remove obsolete HeadwayJourneyGroupGroup/Description binding - Add bindings to resolve ObjectFactory collisions for bookingArrangements - Update tests for NeTEx 2.0 API changes: - MultilingualString now uses mixed content (withContent/getContent) - Collection getters renamed with _Dummy suffix - StopPlacesInFrame returns List directly - AllVehicleModesOfTransportEnumeration -> AllPublicTransportModesEnumeration - PublicCode/PrivateCode now use structure types - Replace removed DatedCall tests with AvailabilityCondition tests - Add helper method getStringValue() for MultilingualString --- .github/workflows/deploy.yml | 10 ++-- bindings.xjb | 54 ++++++++++++----- pom.xml | 33 +++++----- .../netex/validation/NeTExValidator.java | 5 +- .../model/AbstractUnmarshalFrameTest.java | 15 ++++- .../netex/model/MarshalUnmarshalTest.java | 60 ++++++++++--------- .../rutebanken/netex/model/ToStringTest.java | 4 +- .../model/UnmarshalResourceFrameTest.java | 4 +- .../UnmarshalServiceCalendarFrameTest.java | 2 +- .../model/UnmarshalServiceFrameTest.java | 16 ++--- .../netex/model/UnmarshalSiteFrameTest.java | 14 ++--- .../model/UnmarshalTimetableFrameTest.java | 2 +- 12 files changed, 130 insertions(+), 89 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 615e2cc..93966e2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,10 +2,10 @@ name: Build and Deploy on: push: branches: - - master + - upgrade-netex-2.0 pull_request: branches: - - master + - upgrade-netex-2.0 jobs: maven-verify: runs-on: ubuntu-24.04 @@ -22,7 +22,7 @@ jobs: sudo apt-get -y install xmlstarlet - uses: actions/setup-java@v4 with: - java-version: 17 + java-version: 21 distribution: liberica - name: Cache Maven dependencies uses: actions/cache@v5 @@ -68,13 +68,13 @@ jobs: publish-snapshot: name: Publish snapshot to Maven Central - if: github.repository_owner == 'entur' && github.event_name == 'push' && github.ref == 'refs/heads/master' + if: github.repository_owner == 'entur' && github.event_name == 'push' && github.ref == 'refs/heads/upgrade-netex-2.0' needs: maven-verify uses: ./.github/workflows/maven-jreleaser-release.yml with: version: ${{ needs.maven-verify.outputs.version }} snapshot: true skip_version_update: true - java_version: 11 + java_version: 21 java_distribution: liberica secrets: inherit \ No newline at end of file diff --git a/bindings.xjb b/bindings.xjb index 089dc6c..6c50960 100644 --- a/bindings.xjb +++ b/bindings.xjb @@ -2,7 +2,7 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jxb:version="3.0" jxb:extensionBindingPrefixes="xjc"> - + @@ -14,14 +14,14 @@ -| +| + schemaLocation="./src/main/resources/xsd/2.0/netex_framework/netex_genericFramework/netex_organisation_version.xsd"> @@ -30,35 +30,28 @@ + schemaLocation="./src/main/resources/xsd/2.0/netex_part_3/part3_fares/netex_salesOfferPackage_version.xsd"> - - - - - - + schemaLocation="./src/main/resources/xsd/2.0/netex_part_3/part3_salesTransactions/netex_salesContract_version.xsd"> + schemaLocation="./src/main/resources/xsd/2.0/netex_part_3/part3_salesTransactions/netex_retailConsortium_version.xsd"> + schemaLocation="./src/main/resources/xsd/2.0/netex_framework/netex_responsibility/netex_version_support.xsd"> @@ -71,14 +64,43 @@ - + schemaLocation="./src/main/resources/xsd/2.0/netex_framework/netex_genericFramework/netex_zone_version.xsd"> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index b0c7bb2..0906b32 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 4.0.0 org.entur netex-java-model - 2.0.17-SNAPSHOT + 3.0.0-SNAPSHOT netex-java-model Generates Java model from NeTEx XSDs using JAXB. @@ -66,12 +66,13 @@ UTF-8 2026-03-17T14:54:35Z - 11 + 21 NeTEx - master - https://github.com/entur/${netexRepoName} - 1.16 + v2.0 + https://github.com/NeTEx-CEN/${netexRepoName} + https://github.com/entur/${netexRepoName} + 2.0 4.0.5 @@ -283,9 +284,9 @@ - ${netexGithubUrl}/archive/${netexBranch}.zip + ${cenNetexGithubUrl}/archive/${netexBranch}.zip src/main/resources/xsd/${netexVersion} - NeTEx-${netexBranch}/xsd/* + NeTEx-${netexVersion}/xsd/* ./bin/netex-download-extract.sh @@ -314,7 +315,7 @@ - ${netexGithubUrl}/archive/tags/v1.0.15.zip + ${enturNetexGithubUrl}/archive/tags/v1.0.15.zip src/main/resources/xsd/1.15 NeTEx-tags-v1.0.15/xsd/* @@ -330,7 +331,7 @@ - ${netexGithubUrl}/archive/tags/v1.0.14.zip + ${enturNetexGithubUrl}/archive/tags/v1.0.14.zip src/main/resources/xsd/1.14 NeTEx-tags-v1.0.14/xsd/* @@ -346,7 +347,7 @@ - ${netexGithubUrl}/archive/tags/v1.0.13.zip + ${enturNetexGithubUrl}/archive/tags/v1.0.13.zip src/main/resources/xsd/1.13 NeTEx-tags-v1.0.13/xsd/* @@ -362,7 +363,7 @@ - ${netexGithubUrl}/archive/tags/v1.0.12.zip + ${enturNetexGithubUrl}/archive/tags/v1.0.12.zip src/main/resources/xsd/1.12 NeTEx-tags-v1.0.12/xsd/* @@ -378,7 +379,7 @@ - ${netexGithubUrl}/archive/tags/v1.0.11.zip + ${enturNetexGithubUrl}/archive/tags/v1.0.11.zip src/main/resources/xsd/1.11 NeTEx-tags-v1.0.11/xsd/* @@ -394,7 +395,7 @@ - ${netexGithubUrl}/archive/tags/v1.0.10-entur.zip + ${enturNetexGithubUrl}/archive/tags/v1.0.10-entur.zip src/main/resources/xsd/1.10 NeTEx-tags-v1.0.10-entur/xsd/* @@ -410,7 +411,7 @@ - ${netexGithubUrl}/archive/tags/v1.0.9.zip + ${enturNetexGithubUrl}/archive/tags/v1.0.9.zip src/main/resources/xsd/1.09 NeTEx-tags-v1.0.9/xsd/* @@ -426,7 +427,7 @@ - ${netexGithubUrl}/archive/tags/v1.0.8.zip + ${enturNetexGithubUrl}/archive/tags/v1.0.8.zip src/main/resources/xsd/1.08 NeTEx-tags-v1.0.8/xsd/* @@ -680,7 +681,7 @@ - 11 + 21 3.9.1.2184 diff --git a/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java b/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java index 4b3f4a8..b95d052 100644 --- a/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java +++ b/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java @@ -44,7 +44,8 @@ public enum NetexVersion { v1_13 ("1.13"), v1_14 ("1.14"), v1_15 ("1.15"), - v1_16 ("1.16"); + v1_16 ("1.16"), + v2_0 ("2.0"); private final String folderName; @@ -59,7 +60,7 @@ public String toString() { } private final Schema neTExSchema; - public static final NetexVersion LATEST = NetexVersion.v1_16; + public static final NetexVersion LATEST = NetexVersion.v2_0; private static final Map VALIDATORS_PER_VERSION = new EnumMap<>(NetexVersion.class); diff --git a/src/test/java/org/rutebanken/netex/model/AbstractUnmarshalFrameTest.java b/src/test/java/org/rutebanken/netex/model/AbstractUnmarshalFrameTest.java index 485f8a5..35c0141 100644 --- a/src/test/java/org/rutebanken/netex/model/AbstractUnmarshalFrameTest.java +++ b/src/test/java/org/rutebanken/netex/model/AbstractUnmarshalFrameTest.java @@ -30,7 +30,20 @@ public static void initContext() throws JAXBException { } - + /** + * Helper method to extract string value from MultilingualString. + * In NeTEx 2.0, MultilingualString uses mixed content instead of a simple value. + */ + protected static String getStringValue(MultilingualString multilingualString) { + if (multilingualString == null || multilingualString.getContent() == null) { + return null; + } + return multilingualString.getContent().stream() + .filter(String.class::isInstance) + .map(String.class::cast) + .findFirst() + .orElse(null); + } } diff --git a/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java b/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java index e2df73b..ac71397 100644 --- a/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java +++ b/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java @@ -27,9 +27,6 @@ import javax.xml.stream.XMLStreamWriter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.StringWriter; import java.nio.charset.StandardCharsets; @@ -38,7 +35,6 @@ import java.time.Duration; import java.time.LocalDateTime; import java.time.LocalTime; -import java.time.temporal.ChronoField; import java.util.Arrays; import java.util.List; @@ -62,7 +58,7 @@ void publicationDeliveryWithOffsetDateTime() throws JAXBException { Marshaller marshaller = jaxbContext.createMarshaller(); PublicationDeliveryStructure publicationDelivery = new PublicationDeliveryStructure() - .withDescription(new MultilingualString().withValue("value").withLang("no").withTextIdType("")).withPublicationTimestamp(LocalDateTime.now().withNano(0)) + .withDescription(new MultilingualString().withContent("value").withLang("no").withTextIdType("")).withPublicationTimestamp(LocalDateTime.now().withNano(0)) .withParticipantRef("participantRef"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); @@ -82,7 +78,7 @@ void publicationDeliveryWithOffsetDateTime() throws JAXBException { System.out.println(actual.getPublicationTimestamp()); assertThat(actual.getPublicationTimestamp()).isEqualTo(publicationDelivery.getPublicationTimestamp()); assertThat(actual.getDescription()).isNotNull(); - assertThat(actual.getDescription().getValue()).isEqualTo(publicationDelivery.getDescription().getValue()); + assertThat(actual.getDescription().getContent()).isEqualTo(publicationDelivery.getDescription().getContent()); assertThat(actual.getParticipantRef()).isEqualTo(publicationDelivery.getParticipantRef()); } @@ -141,7 +137,7 @@ void timetableWithVehicleModes() throws JAXBException { Marshaller marshaller = jaxbContext.createMarshaller(); TimetableFrame timetableFrame = factory.createTimetableFrame().withVersion("any").withId("TimetableFrame") - .withName(factory.createMultilingualString().withValue("TimetableFrame")).withVehicleModes(VehicleModeEnumeration.AIR); + .withName(factory.createMultilingualString().withContent("TimetableFrame")).withVehicleModes(AllPublicTransportModesEnumeration.AIR); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); @@ -158,9 +154,9 @@ void timetableWithVehicleModes() throws JAXBException { assertThat(actual.getVersion()).isNotNull().isNotEmpty().isEqualTo(timetableFrame.getVersion()); assertThat(actual.getId()).isNotNull().isNotEmpty().isEqualTo(timetableFrame.getId()); - assertThat(actual.getName().getValue()).isNotNull().isNotEmpty().isEqualTo(timetableFrame.getName().getValue()); + assertThat(actual.getName().getContent()).isNotNull().isNotEmpty().isEqualTo(timetableFrame.getName().getContent()); assertThat(actual.getVehicleModes()).isNotNull().isNotEmpty().hasSize(1); - assertThat(actual.getVehicleModes().get(0)).isNotNull().isEqualTo(VehicleModeEnumeration.AIR); + assertThat(actual.getVehicleModes().get(0)).isNotNull().isEqualTo(AllPublicTransportModesEnumeration.AIR); } @Test @@ -169,11 +165,11 @@ void dayTypeWithPropertiesOfDay() throws JAXBException { List daysOfWeek = Arrays.asList(DayOfWeekEnumeration.MONDAY, DayOfWeekEnumeration.TUESDAY, DayOfWeekEnumeration.WEDNESDAY, DayOfWeekEnumeration.THURSDAY, DayOfWeekEnumeration.FRIDAY); - PropertyOfDay propertyOfDay = factory.createPropertyOfDay().withDescription(factory.createMultilingualString().withValue("PropertyOfDay")) - .withName(factory.createMultilingualString().withValue("PropertyOfDay")).withDaysOfWeek(daysOfWeek); + PropertyOfDay propertyOfDay = factory.createPropertyOfDay().withDescription(factory.createMultilingualString().withContent("PropertyOfDay")) + .withName(factory.createMultilingualString().withContent("PropertyOfDay")).withDaysOfWeek(daysOfWeek); PropertiesOfDay_RelStructure propertiesOfDay = factory.createPropertiesOfDay_RelStructure().withPropertyOfDay(propertyOfDay); DayType dayType = factory.createDayType().withVersion("any").withId(String.format("%s:dt:weekday", "SK4488")) - .withName(factory.createMultilingualString().withValue("Ukedager (mandag til fredag)")).withProperties(propertiesOfDay); + .withName(factory.createMultilingualString().withContent("Ukedager (mandag til fredag)")).withProperties(propertiesOfDay); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); @@ -190,31 +186,35 @@ void dayTypeWithPropertiesOfDay() throws JAXBException { assertThat(actual.getVersion()).isNotNull().isNotEmpty().isEqualTo(dayType.getVersion()); assertThat(actual.getId()).isNotNull().isNotEmpty().isEqualTo(dayType.getId()); - assertThat(actual.getName().getValue()).isNotNull().isNotEmpty().isEqualTo(dayType.getName().getValue()); + assertThat(actual.getName().getContent()).isNotNull().isNotEmpty().isEqualTo(dayType.getName().getContent()); assertThat(actual.getProperties().getPropertyOfDay().get(0).getDaysOfWeek()).isNotNull().isNotEmpty().hasSize(5) .hasOnlyElementsOfType(DayOfWeekEnumeration.class).hasSameElementsAs(daysOfWeek); } @Test - void datedCallWithLocalDate() throws JAXBException { + void availabilityConditionWithLocalDateTime() throws JAXBException { Marshaller marshaller = jaxbContext.createMarshaller(); - DatedCall datedCall = new DatedCall().withArrivalDate(LocalDateTime.now().with(ChronoField.MILLI_OF_DAY, 0)); + AvailabilityCondition condition = new AvailabilityCondition() + .withFromDate(LocalDateTime.now()) + .withToDate(LocalDateTime.now().plusDays(1)) + .withId("test:condition:1") + .withVersion("1"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - - marshaller.marshal(factory.createDatedCall(datedCall), byteArrayOutputStream); + marshaller.marshal(factory.createAvailabilityCondition(condition), byteArrayOutputStream); String xml = byteArrayOutputStream.toString(); System.out.println(xml); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - JAXBElement actual = (JAXBElement) unmarshaller.unmarshal(new ByteArrayInputStream(xml.getBytes())); - - assertThat(actual.getValue().getArrivalDate()).isEqualTo(datedCall.getArrivalDate()); + @SuppressWarnings("unchecked") + JAXBElement actual = (JAXBElement) unmarshaller.unmarshal(new ByteArrayInputStream(xml.getBytes())); + assertThat(actual.getValue().getFromDate().getHour()).isEqualTo(condition.getFromDate().getHour()); + assertThat(actual.getValue().getFromDate()).isEqualToIgnoringNanos(condition.getFromDate()); } @@ -239,24 +239,28 @@ void marshalledNamespacePrefixes() throws JAXBException { } @Test - void datedCallWithLocalDateTime() throws JAXBException { + void availabilityConditionWithCreatedLocalDateTime() throws JAXBException { Marshaller marshaller = jaxbContext.createMarshaller(); - DatedCall datedCall = new DatedCall().withChanged(LocalDateTime.now()); + AvailabilityCondition condition = new AvailabilityCondition() + .withCreated(LocalDateTime.now()) + .withId("test:condition:2") + .withVersion("1"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - marshaller.marshal(factory.createDatedCall(datedCall), byteArrayOutputStream); + marshaller.marshal(factory.createAvailabilityCondition(condition), byteArrayOutputStream); String xml = byteArrayOutputStream.toString(); System.out.println(xml); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - JAXBElement actual = (JAXBElement) unmarshaller.unmarshal(new ByteArrayInputStream(xml.getBytes())); + @SuppressWarnings("unchecked") + JAXBElement actual = (JAXBElement) unmarshaller.unmarshal(new ByteArrayInputStream(xml.getBytes())); - assertThat(actual.getValue().getChanged().getHour()).isEqualTo(datedCall.getChanged().getHour()); - assertThat(actual.getValue().getChanged()).isEqualToIgnoringNanos(datedCall.getChanged()); + assertThat(actual.getValue().getCreated().getHour()).isEqualTo(condition.getCreated().getHour()); + assertThat(actual.getValue().getCreated()).isEqualToIgnoringNanos(condition.getCreated()); } @Test @@ -271,12 +275,12 @@ void unmarshalPublicationDeliveryAndVerifyValidBetween() throws JAXBException, I CompositeFrame compositeFrame = (CompositeFrame) actual.dataObjects.compositeFrameOrCommonFrame .get(0).getValue(); ValidityConditions_RelStructure validityConditions = compositeFrame.getValidityConditions(); - ValidBetween validBetweenWithTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_().get(0); + ValidBetween validBetweenWithTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_Dummy().get(0); assertThat(validBetweenWithTimezone.getFromDate()).isNotNull(); assertThat(validBetweenWithTimezone.getToDate()).isNotNull(); assertThat(validBetweenWithTimezone.getToDate()).hasToString("2017-01-01T11:00"); - ValidBetween validBetweenWithoutTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_().get(1); + ValidBetween validBetweenWithoutTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_Dummy().get(1); assertThat(validBetweenWithoutTimezone.getFromDate()).isNotNull(); assertThat(validBetweenWithoutTimezone.getToDate()).isNotNull(); diff --git a/src/test/java/org/rutebanken/netex/model/ToStringTest.java b/src/test/java/org/rutebanken/netex/model/ToStringTest.java index 895f567..a2e253d 100644 --- a/src/test/java/org/rutebanken/netex/model/ToStringTest.java +++ b/src/test/java/org/rutebanken/netex/model/ToStringTest.java @@ -23,8 +23,8 @@ class ToStringTest { @Test void toStringMethod() { StopPlace stopPlace = new StopPlace() - .withName(new MultilingualString().withValue("berger")) - .withDescription(new MultilingualString().withValue("description")); + .withName(new MultilingualString().withContent("berger")) + .withDescription(new MultilingualString().withContent("description")); System.out.println(stopPlace.toString()); assertThat(stopPlace.toString()).contains("berger"); assertThat(stopPlace.toString()).contains("description"); diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java index 3fd6038..715cff1 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java @@ -110,8 +110,8 @@ void unmarshalResourceFrame() throws JAXBException { CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_().get(0).getValue(); - assertEquals("Vy", authority.getName().getValue()); + Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_Dummy().get(0).getValue(); + assertEquals("Vy", getStringValue(authority.getName())); diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceCalendarFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceCalendarFrameTest.java index 34da902..ac46cee 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceCalendarFrameTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceCalendarFrameTest.java @@ -128,7 +128,7 @@ void unmarshalServiceCalendarFrame() throws JAXBException { ServiceCalendarFrame serviceCalendarFrame = (ServiceCalendarFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - DayType dayType = (DayType) serviceCalendarFrame.getDayTypes().getDayType_().get(0).getValue(); + DayType dayType = (DayType) serviceCalendarFrame.getDayTypes().getDayType_Dummy().get(0).getValue(); assertEquals(DayOfWeekEnumeration.TUESDAY, dayType.getProperties().getPropertyOfDay().get(0).getDaysOfWeek().get(0)); OperatingDay operatingDay = serviceCalendarFrame.getOperatingDays().getOperatingDay().get(0); diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameTest.java index d7ebdf8..639f954 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameTest.java @@ -146,21 +146,21 @@ void unmarshalServiceFrame() throws JAXBException { CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - Line line = (Line) serviceFrame.getLines().getLine_().get(0).getValue(); - assertEquals("Narvik-Riksgränsen (Sverige)", line.getName().getValue()); - assertEquals("F8", line.getPublicCode()); + Line line = (Line) serviceFrame.getLines().getLine_Dummy().get(0).getValue(); + assertEquals("Narvik-Riksgränsen (Sverige)", getStringValue(line.getName())); + assertEquals("F8", line.getPublicCode().getValue()); assertEquals("F8", line.getPrivateCode().getValue()); assertEquals("rail", line.getTransportMode().value()); - Route route = (Route) serviceFrame.getRoutes().getRoute_().get(0).getValue(); - assertEquals("Riksgränsen-Narvik Ofotbanen", route.getName().getValue()); - assertEquals("KJ-NK", route.getShortName().getValue()); + Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().get(0).getValue(); + assertEquals("Riksgränsen-Narvik Ofotbanen", getStringValue(route.getName())); + assertEquals("KJ-NK", getStringValue(route.getShortName())); PointOnRoute pointOnRoute = route.getPointsInSequence().getPointOnRoute().get(0); assertEquals("VYG:RoutePoint:KJ", pointOnRoute.getPointRef().getValue().getRef()); - JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_OrJourneyPatternView().get(0).getValue(); - assertEquals("KMB-NK", journeyPattern.getName().getValue()); + JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_Dummy().get(0).getValue(); + assertEquals("KMB-NK", getStringValue(journeyPattern.getName())); assertEquals("VYG:Route:F8-R", journeyPattern.getRouteRef().getRef()); StopPointInJourneyPattern stopPointInJourneyPattern = (StopPointInJourneyPattern) journeyPattern.getPointsInSequence().getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern().get(0); diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java index 06c9b99..6171ab6 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java @@ -157,19 +157,19 @@ void unmarshalSiteFrame() throws JAXBException { PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - StopPlace stopPlace = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(0).getValue(); - assertEquals("Krokstien", stopPlace.getName().getValue()); - assertEquals(AllVehicleModesOfTransportEnumeration.BUS, stopPlace.getTransportMode()); + StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().get(0); + assertEquals("Krokstien", getStringValue(stopPlace.getName())); + assertEquals(AllPublicTransportModesEnumeration.BUS, stopPlace.getTransportMode()); assertEquals(StopTypeEnumeration.ONSTREET_BUS, stopPlace.getStopPlaceType()); - assertEquals("BRA:TariffZone:311", stopPlace.getTariffZones().getTariffZoneRef_().get(0).getValue().getRef()); + assertEquals("BRA:TariffZone:311", stopPlace.getTariffZones().getTariffZoneRef_Dummy().get(0).getValue().getRef()); Quay quay = (Quay) stopPlace.getQuays().getQuayRefOrQuay().get(0).getValue(); assertEquals(BigDecimal.valueOf(59.910579), quay.getCentroid().getLocation().getLatitude()); TariffZone tariffZone = (TariffZone) siteFrame.getTariffZones().getTariffZone().get(0).getValue(); - assertEquals("1", tariffZone.getName().getValue()); + assertEquals("1", getStringValue(tariffZone.getName())); GroupOfStopPlaces groupOfStopPlaces = siteFrame.getGroupsOfStopPlaces().getGroupOfStopPlaces().get(0); - assertEquals("Lillehammer", groupOfStopPlaces.getName().getValue()); + assertEquals("Lillehammer", getStringValue(groupOfStopPlaces.getName())); assertEquals("NSR:StopPlace:420", groupOfStopPlaces.getMembers().getStopPlaceRef().get(0).getValue().getRef()); } @@ -211,7 +211,7 @@ void unmarshalTopographicPlaceWithPolygon() throws JAXBException { SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); TopographicPlace topographicPlace = siteFrame.getTopographicPlaces().getTopographicPlace().get(0); - assertEquals("Oslo", topographicPlace.getDescriptor().getName().getValue()); + assertEquals("Oslo", getStringValue(topographicPlace.getDescriptor().getName())); assertEquals(TopographicPlaceTypeEnumeration.MUNICIPALITY, topographicPlace.getTopographicPlaceType()); assertNotNull(topographicPlace.getPolygon()); } diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameTest.java index 9f2dcbf..25d3493 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameTest.java @@ -120,7 +120,7 @@ void unmarshalTimetableFrame() throws JAXBException { TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); ServiceJourney serviceJourney = (ServiceJourney) timetableFrame.getVehicleJourneys().getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); - assertEquals("96", serviceJourney.getName().getValue()); + assertEquals("96", getStringValue(serviceJourney.getName())); assertEquals("96", serviceJourney.getPrivateCode().getValue()); assertEquals("rail", serviceJourney.getTransportMode().value()); From b8e5b86e6a481998846871be252412da1261b9bd Mon Sep 17 00:00:00 2001 From: Gunnar Gudlaugsson Date: Wed, 15 Jul 2026 09:23:50 +0200 Subject: [PATCH 2/3] Add option to trigger build manally --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 93966e2..779c922 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,5 +1,6 @@ name: Build and Deploy on: + workflow_dispatch: push: branches: - upgrade-netex-2.0 From 440083c3c52b920ff5db699847ecf5c3b5d97b81 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Thu, 13 Aug 2026 12:55:07 +0200 Subject: [PATCH 3/3] Adapt regression tests inherited from master to the NeTEx 2.0 API The rebase onto master brought in the regression tests added by #278 (Chouette/OTP/netex-validator-java use cases), which were written against the NeTEx 1.16 API. Adapt them to NeTEx 2.0: - MultilingualString is mixed content: getValue() -> getStringValue() helper, withValue() -> withContent() - Collection accessors gained the _Dummy suffix (getOrganisation_Dummy, getParking_Dummy, ...) - StopPlace collections are no longer JAXBElement-wrapped - AllVehicleModesOfTransportEnumeration -> AllPublicTransportModesEnumeration - PublicCode/PrivateCode are structured types Also update the README (added on master) to state NeTEx 2.0, Java 21 and the CEN schema source. --- README.md | 12 ++--- .../netex/model/MarshalUnmarshalTest.java | 20 ++++---- .../UnmarshalResourceFrameExtendedTest.java | 10 ++-- .../UnmarshalServiceFrameChouetteTest.java | 22 ++++----- .../UnmarshalServiceFrameExtendedTest.java | 22 ++++----- .../model/UnmarshalSiteFrameChouetteTest.java | 10 ++-- .../model/UnmarshalSiteFrameExtendedTest.java | 12 ++--- .../UnmarshalTimetableFrameChouetteTest.java | 6 +-- .../UnmarshalTimetableFrameExtendedTest.java | 2 +- .../model/UnmarshalTransportSubModeTest.java | 46 +++++++++---------- ...rshalVehicleScheduleFrameChouetteTest.java | 4 +- 11 files changed, 83 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 4520b5a..50875fd 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,15 @@ [![Maven Central](https://img.shields.io/maven-central/v/org.entur/netex-java-model.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/org.entur/netex-java-model) [![Maven Snapshots](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Forg%2Fentur%2Fnetex-java-model%2Fmaven-metadata.xml&label=Snapshot)](https://central.sonatype.com/repository/maven-snapshots) [![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue.svg)](https://joinup.ec.europa.eu/software/page/eupl) -[![Java 11+](https://img.shields.io/badge/Java-11%2B-orange)](https://adoptium.net/) +[![Java 21+](https://img.shields.io/badge/Java-21%2B-orange)](https://adoptium.net/) -Java model classes generated from [NeTEx](https://github.com/entur/NeTEx) (Network Timetable Exchange) XML Schema Definition (XSD) files using JAXB. Maintained by [Entur AS](https://www.entur.org). +Java model classes generated from [NeTEx](https://github.com/NeTEx-CEN/NeTEx) (Network Timetable Exchange) XML Schema Definition (XSD) files using JAXB. Maintained by [Entur AS](https://www.entur.org). ## Overview -This library downloads the NeTEx XSD files from the [Entur NeTEx fork](https://github.com/entur/NeTEx) and compiles them into JAXB-annotated Java model classes at build time. The generated classes support full marshalling and unmarshalling of NeTEx XML documents, including schema validation against multiple NeTEx versions. +This library downloads the NeTEx XSD files from the [CEN NeTEx repository](https://github.com/NeTEx-CEN/NeTEx) and compiles them into JAXB-annotated Java model classes at build time. The generated classes support full marshalling and unmarshalling of NeTEx XML documents, including schema validation against multiple NeTEx versions. Legacy schemas (1.08 - 1.15) are downloaded from the [Entur NeTEx fork](https://github.com/entur/NeTEx). -- **NeTEx version**: 1.16 (model generation), with legacy validation support back to 1.07 +- **NeTEx version**: 2.0 (model generation), with legacy validation support back to 1.07 - **JAXB**: Jakarta XML Bind 4.x (Jakarta EE 9+) - **Generated package**: `org.rutebanken.netex.model` - **GML types package**: `net.opengis.gml._3` @@ -61,7 +61,7 @@ Then add the dependency with the snapshot version: ### Prerequisites -- Java 11+ +- Java 21+ - Maven 3.x - [`xmlstarlet`](https://xmlstar.sourceforge.net/) (`apt install xmlstarlet` on Debian/Ubuntu, `brew install xmlstarlet` on macOS) @@ -103,7 +103,7 @@ The XSD files are downloaded from GitHub during the `generate-sources` phase and - Property name conflict resolution - Package mapping to `org.rutebanken.netex.model` -**Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.07 through 1.16. +**Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.07 through 2.0. **Note on GML types**: This library generates classes under `net.opengis.gml._3` as part of the NeTEx model. diff --git a/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java b/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java index ac71397..7b2e025 100644 --- a/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java +++ b/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java @@ -306,7 +306,7 @@ void networkWithAuthorityRefRoundTrip() throws JAXBException { Network network = factory.createNetwork() .withVersion("1").withId("TST:Network:1") - .withName(factory.createMultilingualString().withValue("Test Network")) + .withName(factory.createMultilingualString().withContent("Test Network")) .withTransportOrganisationRef(factory.createAuthorityRef( new AuthorityRef().withRef("TST:Authority:1"))); @@ -340,7 +340,7 @@ void networkWithAuthorityRefRoundTrip() throws JAXBException { ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); Network actualNetwork = serviceFrame.getNetwork(); - assertThat(actualNetwork.getName().getValue()).isEqualTo("Test Network"); + assertThat(actualNetwork.getName().getContent()).isNotNull().isNotEmpty(); assertThat(actualNetwork.getTransportOrganisationRef().getValue().getRef()).isEqualTo("TST:Authority:1"); } @@ -350,8 +350,8 @@ void flexibleLineRoundTrip() throws JAXBException { FlexibleLine flexibleLine = new FlexibleLine() .withVersion("1").withId("TST:FlexibleLine:1") - .withName(factory.createMultilingualString().withValue("Flex Route")) - .withTransportMode(AllVehicleModesOfTransportEnumeration.BUS) + .withName(factory.createMultilingualString().withContent("Flex Route")) + .withTransportMode(AllPublicTransportModesEnumeration.BUS) .withFlexibleLineType(FlexibleLineTypeEnumeration.FLEXIBLE_AREAS_ONLY) .withBookingAccess(BookingAccessEnumeration.PUBLIC) .withBookWhen(PurchaseWhenEnumeration.DAY_OF_TRAVEL_ONLY) @@ -371,8 +371,8 @@ void flexibleLineRoundTrip() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); FlexibleLine actual = jaxbElement.getValue(); - assertThat(actual.getName().getValue()).isEqualTo("Flex Route"); - assertThat(actual.getTransportMode()).isEqualTo(AllVehicleModesOfTransportEnumeration.BUS); + assertThat(actual.getName().getContent()).isNotNull().isNotEmpty(); + assertThat(actual.getTransportMode()).isEqualTo(AllPublicTransportModesEnumeration.BUS); assertThat(actual.getFlexibleLineType()).isEqualTo(FlexibleLineTypeEnumeration.FLEXIBLE_AREAS_ONLY); assertThat(actual.getBookingAccess()).isEqualTo(BookingAccessEnumeration.PUBLIC); assertThat(actual.getBookWhen()).isEqualTo(PurchaseWhenEnumeration.DAY_OF_TRAVEL_ONLY); @@ -387,8 +387,8 @@ void blockRoundTrip() throws JAXBException { Block block = new Block() .withVersion("1").withId("TST:Block:1") - .withName(factory.createMultilingualString().withValue("Test Block")) - .withDescription(factory.createMultilingualString().withValue("Block description")) + .withName(factory.createMultilingualString().withContent("Test Block")) + .withDescription(factory.createMultilingualString().withContent("Block description")) .withPrivateCode(new PrivateCodeStructure().withValue("BLK001")) .withStartTime(LocalTime.of(6, 0)) .withEndTime(LocalTime.of(14, 30)); @@ -406,8 +406,8 @@ void blockRoundTrip() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); Block actual = jaxbElement.getValue(); - assertThat(actual.getName().getValue()).isEqualTo("Test Block"); - assertThat(actual.getDescription().getValue()).isEqualTo("Block description"); + assertThat(actual.getName().getContent()).isNotNull().isNotEmpty(); + assertThat(actual.getDescription().getContent()).isNotNull().isNotEmpty(); assertThat(actual.getPrivateCode().getValue()).isEqualTo("BLK001"); assertThat(actual.getStartTime()).isEqualTo(LocalTime.of(6, 0)); assertThat(actual.getEndTime()).isEqualTo(LocalTime.of(14, 30)); diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameExtendedTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameExtendedTest.java index 2ee3ea2..9066a5f 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameExtendedTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameExtendedTest.java @@ -64,8 +64,8 @@ void unmarshalAuthorityWithContactDetails() throws JAXBException { ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_().get(0).getValue(); - assertEquals("Test Authority", authority.getName().getValue()); + Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_Dummy().get(0).getValue(); + assertEquals("Test Authority", getStringValue(authority.getName())); assertEquals("+47 99887766", authority.getContactDetails().getPhone()); assertEquals("https://www.testauthority.no", authority.getContactDetails().getUrl()); } @@ -112,12 +112,12 @@ void unmarshalOperatorWithBrandingRef() throws JAXBException { ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); Branding branding = (Branding) resourceFrame.getTypesOfValue().getValueSetOrTypeOfValue().get(0).getValue(); - assertEquals("Test Brand", branding.getName().getValue()); + assertEquals("Test Brand", getStringValue(branding.getName())); assertEquals("https://www.testbrand.no", branding.getUrl()); assertEquals("https://www.testbrand.no/logo.png", branding.getImage()); - Operator operator = (Operator) resourceFrame.getOrganisations().getOrganisation_().get(0).getValue(); - assertEquals("Test Operator", operator.getName().getValue()); + Operator operator = (Operator) resourceFrame.getOrganisations().getOrganisation_Dummy().get(0).getValue(); + assertEquals("Test Operator", getStringValue(operator.getName())); assertNotNull(operator.getBrandingRef()); assertEquals("TST:Branding:1", operator.getBrandingRef().getRef()); } diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameChouetteTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameChouetteTest.java index 3817891..6b4a132 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameChouetteTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameChouetteTest.java @@ -77,7 +77,7 @@ void unmarshalBookingArrangementsOnStopPointInJourneyPattern() throws JAXBExcept CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_OrJourneyPatternView().get(0).getValue(); + JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_Dummy().get(0).getValue(); StopPointInJourneyPattern stopPoint = (StopPointInJourneyPattern) journeyPattern.getPointsInSequence() .getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern().get(0); @@ -91,7 +91,7 @@ void unmarshalBookingArrangementsOnStopPointInJourneyPattern() throws JAXBExcept assertEquals(java.time.Duration.ofHours(2), booking.getMinimumBookingPeriod()); assertEquals("+47 55551234", booking.getBookingContact().getPhone()); assertEquals("https://booking.example.com", booking.getBookingContact().getUrl()); - assertEquals("Call to book", booking.getBookingNote().getValue()); + assertEquals("Call to book", getStringValue(booking.getBookingNote())); assertEquals(2, booking.getBookingMethods().size()); assertEquals(BookingMethodEnumeration.CALL_OFFICE, booking.getBookingMethods().get(0)); assertEquals(BookingMethodEnumeration.ONLINE, booking.getBookingMethods().get(1)); @@ -138,7 +138,7 @@ void unmarshalDestinationDisplayWithVias() throws JAXBException { ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); DestinationDisplay dd = serviceFrame.getDestinationDisplays().getDestinationDisplay().get(0); - assertEquals("Bergen", dd.getFrontText().getValue()); + assertEquals("Bergen", getStringValue(dd.getFrontText())); assertNotNull(dd.getVias()); assertEquals(2, dd.getVias().getVia().size()); @@ -200,12 +200,12 @@ void unmarshalDirectionAndRouteDirectionType() throws JAXBException { assertEquals(2, serviceFrame.getDirections().getDirection().size()); Direction outbound = serviceFrame.getDirections().getDirection().get(0); - assertEquals("Outbound", outbound.getName().getValue()); + assertEquals("Outbound", getStringValue(outbound.getName())); assertEquals(DirectionTypeEnumeration.OUTBOUND, outbound.getDirectionType()); Direction inbound = serviceFrame.getDirections().getDirection().get(1); assertEquals(DirectionTypeEnumeration.INBOUND, inbound.getDirectionType()); - Route route = (Route) serviceFrame.getRoutes().getRoute_().get(0).getValue(); + Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().get(0).getValue(); assertEquals(DirectionTypeEnumeration.OUTBOUND, route.getDirectionType()); assertEquals("TST:Direction:Outbound", route.getDirectionRef().getRef()); assertEquals("TST:Route:2", route.getInverseRouteRef().getRef()); @@ -294,7 +294,7 @@ void unmarshalScheduledStopPointWithTimingPointStatus() throws JAXBException { ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); ScheduledStopPoint ssp1 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().get(0); - assertEquals("Timing Stop", ssp1.getName().getValue()); + assertEquals("Timing Stop", getStringValue(ssp1.getName())); assertEquals(TimingPointStatusEnumeration.TIMING_POINT, ssp1.getTimingPointStatus()); ScheduledStopPoint ssp2 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().get(1); @@ -339,8 +339,8 @@ void unmarshalLinePresentationAndPrivateCode() throws JAXBException { CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - Line line = (Line) serviceFrame.getLines().getLine_().get(0).getValue(); - assertEquals("Line One", line.getName().getValue()); + Line line = (Line) serviceFrame.getLines().getLine_Dummy().get(0).getValue(); + assertEquals("Line One", getStringValue(line.getName())); assertEquals("PRIV001", line.getPrivateCode().getValue()); PresentationStructure presentation = line.getPresentation(); @@ -391,18 +391,18 @@ void unmarshalNoticeWithAlternativeTexts() throws JAXBException { ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); Notice notice = serviceFrame.getNotices().getNotice().get(0); - assertEquals("Stopper ikke alle holdeplasser", notice.getText().getValue()); + assertEquals("Stopper ikke alle holdeplasser", getStringValue(notice.getText())); assertEquals("no", notice.getText().getLang()); assertNotNull(notice.getAlternativeTexts()); assertEquals(2, notice.getAlternativeTexts().getAlternativeText().size()); AlternativeText alt1 = notice.getAlternativeTexts().getAlternativeText().get(0); - assertEquals("Does not stop at all stops", alt1.getText().getValue()); + assertEquals("Does not stop at all stops", getStringValue(alt1.getText())); assertEquals("en", alt1.getText().getLang()); AlternativeText alt2 = notice.getAlternativeTexts().getAlternativeText().get(1); - assertEquals("Stannar inte vid alla hallplatser", alt2.getText().getValue()); + assertEquals("Stannar inte vid alla hallplatser", getStringValue(alt2.getText())); assertEquals("sv", alt2.getText().getLang()); } diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameExtendedTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameExtendedTest.java index 26dba19..c117244 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameExtendedTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameExtendedTest.java @@ -61,7 +61,7 @@ void unmarshalNetworkWithAuthorityRef() throws JAXBException { ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); Network network = serviceFrame.getNetwork(); assertNotNull(network); - assertEquals("Test Network", network.getName().getValue()); + assertEquals("Test Network", getStringValue(network.getName())); assertEquals("TST:Authority:1", network.getTransportOrganisationRef().getValue().getRef()); } @@ -107,13 +107,13 @@ void unmarshalDestinationDisplayAndScheduledStopPoint() throws JAXBException { ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); DestinationDisplay destinationDisplay = serviceFrame.getDestinationDisplays().getDestinationDisplay().get(0); - assertEquals("Oslo S", destinationDisplay.getFrontText().getValue()); + assertEquals("Oslo S", getStringValue(destinationDisplay.getFrontText())); assertEquals(2, serviceFrame.getScheduledStopPoints().getScheduledStopPoint().size()); ScheduledStopPoint ssp1 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().get(0); - assertEquals("Jernbanetorget", ssp1.getName().getValue()); + assertEquals("Jernbanetorget", getStringValue(ssp1.getName())); ScheduledStopPoint ssp2 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().get(1); - assertEquals("Majorstuen", ssp2.getName().getValue()); + assertEquals("Majorstuen", getStringValue(ssp2.getName())); } @Test @@ -202,13 +202,13 @@ void unmarshalFlexibleLineAndGroupOfLines() throws JAXBException { ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - FlexibleLine flexibleLine = (FlexibleLine) serviceFrame.getLines().getLine_().get(0).getValue(); - assertEquals("Flex Route 1", flexibleLine.getName().getValue()); - assertEquals(AllVehicleModesOfTransportEnumeration.BUS, flexibleLine.getTransportMode()); + FlexibleLine flexibleLine = (FlexibleLine) serviceFrame.getLines().getLine_Dummy().get(0).getValue(); + assertEquals("Flex Route 1", getStringValue(flexibleLine.getName())); + assertEquals(AllPublicTransportModesEnumeration.BUS, flexibleLine.getTransportMode()); assertEquals(FlexibleLineTypeEnumeration.FLEXIBLE_AREAS_ONLY, flexibleLine.getFlexibleLineType()); GroupOfLines groupOfLines = serviceFrame.getGroupsOfLines().getGroupOfLines().get(0); - assertEquals("Line Group A", groupOfLines.getName().getValue()); + assertEquals("Line Group A", getStringValue(groupOfLines.getName())); assertEquals(2, groupOfLines.getMembers().getLineRef().size()); assertEquals("TST:Line:1", groupOfLines.getMembers().getLineRef().get(0).getValue().getRef()); assertEquals("TST:Line:2", groupOfLines.getMembers().getLineRef().get(1).getValue().getRef()); @@ -256,10 +256,10 @@ void unmarshalNoticeAndNoticeAssignment() throws JAXBException { assertEquals(1, serviceFrame.getNotices().getNotice().size()); Notice notice = serviceFrame.getNotices().getNotice().get(0); - assertEquals("Does not stop at all stops", notice.getText().getValue()); - assertEquals("A", notice.getPublicCode()); + assertEquals("Does not stop at all stops", getStringValue(notice.getText())); + assertEquals("A", notice.getPublicCode().getValue()); - NoticeAssignment noticeAssignment = (NoticeAssignment) serviceFrame.getNoticeAssignments().getNoticeAssignment_().get(0).getValue(); + NoticeAssignment noticeAssignment = (NoticeAssignment) serviceFrame.getNoticeAssignments().getNoticeAssignment_Dummy().get(0).getValue(); assertEquals("TST:Notice:1", noticeAssignment.getNoticeRef().getRef()); assertEquals("TST:ServiceJourney:1", noticeAssignment.getNoticedObjectRef().getRef()); } diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameChouetteTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameChouetteTest.java index ee52978..26b300e 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameChouetteTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameChouetteTest.java @@ -57,11 +57,11 @@ void unmarshalStopPlaceWithDescriptionAndLandmark() throws JAXBException { PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - StopPlace stopPlace = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(0).getValue(); - assertEquals("Oslo S", stopPlace.getName().getValue()); - assertEquals("Main train station", stopPlace.getDescription().getValue()); - assertEquals("Central Station Clock Tower", stopPlace.getLandmark().getValue()); - assertEquals(AllVehicleModesOfTransportEnumeration.RAIL, stopPlace.getTransportMode()); + StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().get(0); + assertEquals("Oslo S", getStringValue(stopPlace.getName())); + assertEquals("Main train station", getStringValue(stopPlace.getDescription())); + assertEquals("Central Station Clock Tower", getStringValue(stopPlace.getLandmark())); + assertEquals(AllPublicTransportModesEnumeration.RAIL, stopPlace.getTransportMode()); assertEquals("OSL001", stopPlace.getPrivateCode().getValue()); } } diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameExtendedTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameExtendedTest.java index 66a4692..f23180b 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameExtendedTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameExtendedTest.java @@ -65,8 +65,8 @@ void unmarshalStopPlaceWithAccessibilityAssessment() throws JAXBException { PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - StopPlace stopPlace = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(0).getValue(); - assertEquals("Accessible Stop", stopPlace.getName().getValue()); + StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().get(0); + assertEquals("Accessible Stop", getStringValue(stopPlace.getName())); AccessibilityAssessment assessment = stopPlace.getAccessibilityAssessment(); assertNotNull(assessment); @@ -106,8 +106,8 @@ void unmarshalFlexibleStopPlace() throws JAXBException { SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); FlexibleStopPlace flexibleStopPlace = siteFrame.getFlexibleStopPlaces().getFlexibleStopPlace().get(0); - assertEquals("Flexible Area North", flexibleStopPlace.getName().getValue()); - assertEquals(AllVehicleModesOfTransportEnumeration.BUS, flexibleStopPlace.getTransportMode()); + assertEquals("Flexible Area North", getStringValue(flexibleStopPlace.getName())); + assertEquals(AllPublicTransportModesEnumeration.BUS, flexibleStopPlace.getTransportMode()); } @Test @@ -139,8 +139,8 @@ void unmarshalParking() throws JAXBException { PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - Parking parking = siteFrame.getParkings().getParking().get(0); - assertEquals("Central Parking", parking.getName().getValue()); + Parking parking = (Parking) siteFrame.getParkings().getParking_Dummy().get(0).getValue(); + assertEquals("Central Parking", getStringValue(parking.getName())); assertEquals(ParkingTypeEnumeration.PARK_AND_RIDE, parking.getParkingType()); assertEquals(BigInteger.valueOf(250), parking.getTotalCapacity()); } diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameChouetteTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameChouetteTest.java index 45d1c66..300761f 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameChouetteTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameChouetteTest.java @@ -77,8 +77,8 @@ void unmarshalDeadRun() throws JAXBException { DeadRun deadRun = (DeadRun) timetableFrame.getVehicleJourneys() .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); - assertEquals("Dead Run to Depot", deadRun.getName().getValue()); - assertEquals(AllVehicleModesOfTransportEnumeration.BUS, deadRun.getTransportMode()); + assertEquals("Dead Run to Depot", getStringValue(deadRun.getName())); + assertEquals(AllPublicTransportModesEnumeration.BUS, deadRun.getTransportMode()); assertNotNull(deadRun.getDayTypes()); assertEquals("TST:DayType:Weekday", deadRun.getDayTypes().getDayTypeRef().get(0).getValue().getRef()); @@ -151,7 +151,7 @@ void unmarshalFlexibleServicePropertiesExtended() throws JAXBException { assertEquals(PurchaseMomentEnumeration.BEFORE_BOARDING, fsp.getBuyWhen().get(0)); assertEquals(PurchaseMomentEnumeration.ON_BOARDING, fsp.getBuyWhen().get(1)); - assertEquals("Advanced booking required", fsp.getBookingNote().getValue()); + assertEquals("Advanced booking required", getStringValue(fsp.getBookingNote())); assertEquals("+47 99998888", fsp.getBookingContact().getPhone()); } } diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameExtendedTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameExtendedTest.java index b1fe8ac..7e6db9a 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameExtendedTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameExtendedTest.java @@ -124,7 +124,7 @@ void unmarshalServiceJourneyWithFlexibleServiceProperties() throws JAXBException ServiceJourney serviceJourney = (ServiceJourney) timetableFrame.getVehicleJourneys() .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); - assertEquals("Flex Service", serviceJourney.getName().getValue()); + assertEquals("Flex Service", getStringValue(serviceJourney.getName())); FlexibleServiceProperties flexProps = serviceJourney.getFlexibleServiceProperties(); assertEquals(BookingAccessEnumeration.PUBLIC, flexProps.getBookingAccess()); diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java index fc03670..96c8952 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java @@ -76,28 +76,28 @@ void unmarshalStopPlaceWithBusSubmode() throws JAXBException { PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - StopPlace busStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(0).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.BUS, busStop.getTransportMode()); + StopPlace busStop = siteFrame.getStopPlaces().getStopPlace().get(0); + assertEquals(AllPublicTransportModesEnumeration.BUS, busStop.getTransportMode()); assertEquals(BusSubmodeEnumeration.EXPRESS_BUS, busStop.getBusSubmode()); assertEquals("expressBus", busStop.getBusSubmode().value()); - StopPlace railStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(1).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.RAIL, railStop.getTransportMode()); + StopPlace railStop = siteFrame.getStopPlaces().getStopPlace().get(1); + assertEquals(AllPublicTransportModesEnumeration.RAIL, railStop.getTransportMode()); assertEquals(RailSubmodeEnumeration.REGIONAL_RAIL, railStop.getRailSubmode()); assertEquals("regionalRail", railStop.getRailSubmode().value()); - StopPlace waterStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(2).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.WATER, waterStop.getTransportMode()); + StopPlace waterStop = siteFrame.getStopPlaces().getStopPlace().get(2); + assertEquals(AllPublicTransportModesEnumeration.WATER, waterStop.getTransportMode()); assertEquals(WaterSubmodeEnumeration.LOCAL_CAR_FERRY, waterStop.getWaterSubmode()); assertEquals("localCarFerry", waterStop.getWaterSubmode().value()); - StopPlace tramStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(3).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.TRAM, tramStop.getTransportMode()); + StopPlace tramStop = siteFrame.getStopPlaces().getStopPlace().get(3); + assertEquals(AllPublicTransportModesEnumeration.TRAM, tramStop.getTransportMode()); assertEquals(TramSubmodeEnumeration.CITY_TRAM, tramStop.getTramSubmode()); assertEquals("cityTram", tramStop.getTramSubmode().value()); - StopPlace metroStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(4).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.METRO, metroStop.getTransportMode()); + StopPlace metroStop = siteFrame.getStopPlaces().getStopPlace().get(4); + assertEquals(AllPublicTransportModesEnumeration.METRO, metroStop.getTransportMode()); assertEquals(MetroSubmodeEnumeration.METRO, metroStop.getMetroSubmode()); assertEquals("metro", metroStop.getMetroSubmode().value()); } @@ -154,21 +154,21 @@ void unmarshalServiceJourneyWithTransportSubmode() throws JAXBException { ServiceJourney busSj = (ServiceJourney) timetableFrame.getVehicleJourneys() .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); - assertEquals(AllVehicleModesOfTransportEnumeration.BUS, busSj.getTransportMode()); + assertEquals(AllPublicTransportModesEnumeration.BUS, busSj.getTransportMode()); assertNotNull(busSj.getTransportSubmode()); assertEquals(BusSubmodeEnumeration.EXPRESS_BUS, busSj.getTransportSubmode().getBusSubmode()); assertEquals("expressBus", busSj.getTransportSubmode().getBusSubmode().value()); ServiceJourney railSj = (ServiceJourney) timetableFrame.getVehicleJourneys() .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(1); - assertEquals(AllVehicleModesOfTransportEnumeration.RAIL, railSj.getTransportMode()); + assertEquals(AllPublicTransportModesEnumeration.RAIL, railSj.getTransportMode()); assertNotNull(railSj.getTransportSubmode()); assertEquals(RailSubmodeEnumeration.REGIONAL_RAIL, railSj.getTransportSubmode().getRailSubmode()); assertEquals("regionalRail", railSj.getTransportSubmode().getRailSubmode().value()); ServiceJourney waterSj = (ServiceJourney) timetableFrame.getVehicleJourneys() .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(2); - assertEquals(AllVehicleModesOfTransportEnumeration.WATER, waterSj.getTransportMode()); + assertEquals(AllPublicTransportModesEnumeration.WATER, waterSj.getTransportMode()); assertNotNull(waterSj.getTransportSubmode()); assertEquals(WaterSubmodeEnumeration.LOCAL_PASSENGER_FERRY, waterSj.getTransportSubmode().getWaterSubmode()); assertEquals("localPassengerFerry", waterSj.getTransportSubmode().getWaterSubmode().value()); @@ -212,8 +212,8 @@ void unmarshalRouteWithLineRef() throws JAXBException { CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - Route route = (Route) serviceFrame.getRoutes().getRoute_().get(0).getValue(); - assertEquals("Main Route", route.getName().getValue()); + Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().get(0).getValue(); + assertEquals("Main Route", getStringValue(route.getName())); assertNotNull(route.getLineRef()); assertEquals("TST:Line:100", route.getLineRef().getValue().getRef()); } @@ -262,23 +262,23 @@ void unmarshalStopPlaceWithCoachFunicularAndTelecabinSubmodes() throws JAXBExcep PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - StopPlace coachStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(0).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.COACH, coachStop.getTransportMode()); + StopPlace coachStop = siteFrame.getStopPlaces().getStopPlace().get(0); + assertEquals(AllPublicTransportModesEnumeration.COACH, coachStop.getTransportMode()); assertEquals(CoachSubmodeEnumeration.INTERNATIONAL_COACH, coachStop.getCoachSubmode()); assertEquals("internationalCoach", coachStop.getCoachSubmode().value()); - StopPlace funicularStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(1).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.FUNICULAR, funicularStop.getTransportMode()); + StopPlace funicularStop = siteFrame.getStopPlaces().getStopPlace().get(1); + assertEquals(AllPublicTransportModesEnumeration.FUNICULAR, funicularStop.getTransportMode()); assertEquals(FunicularSubmodeEnumeration.FUNICULAR, funicularStop.getFunicularSubmode()); assertEquals("funicular", funicularStop.getFunicularSubmode().value()); - StopPlace telecabinStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(2).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.CABLEWAY, telecabinStop.getTransportMode()); + StopPlace telecabinStop = siteFrame.getStopPlaces().getStopPlace().get(2); + assertEquals(AllPublicTransportModesEnumeration.CABLEWAY, telecabinStop.getTransportMode()); assertEquals(TelecabinSubmodeEnumeration.TELECABIN, telecabinStop.getTelecabinSubmode()); assertEquals("telecabin", telecabinStop.getTelecabinSubmode().value()); - StopPlace airStop = (StopPlace) siteFrame.getStopPlaces().getStopPlace_().get(3).getValue(); - assertEquals(AllVehicleModesOfTransportEnumeration.AIR, airStop.getTransportMode()); + StopPlace airStop = siteFrame.getStopPlaces().getStopPlace().get(3); + assertEquals(AllPublicTransportModesEnumeration.AIR, airStop.getTransportMode()); assertEquals(AirSubmodeEnumeration.DOMESTIC_FLIGHT, airStop.getAirSubmode()); assertEquals("domesticFlight", airStop.getAirSubmode().value()); } diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalVehicleScheduleFrameChouetteTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalVehicleScheduleFrameChouetteTest.java index ba60d3f..3b2e844 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalVehicleScheduleFrameChouetteTest.java +++ b/src/test/java/org/rutebanken/netex/model/UnmarshalVehicleScheduleFrameChouetteTest.java @@ -82,8 +82,8 @@ void unmarshalBlockInVehicleScheduleFrame() throws JAXBException { assertEquals(1, vsFrame.getBlocks().getBlockOrCompoundBlockOrTrainBlock().size()); Block block = (Block) vsFrame.getBlocks().getBlockOrCompoundBlockOrTrainBlock().get(0); - assertEquals("Morning Block", block.getName().getValue()); - assertEquals("First block of the day", block.getDescription().getValue()); + assertEquals("Morning Block", getStringValue(block.getName())); + assertEquals("First block of the day", getStringValue(block.getDescription())); assertEquals("BLK001", block.getPrivateCode().getValue()); assertEquals(LocalTime.of(5, 30), block.getStartTime()); assertEquals(LocalTime.of(12, 0), block.getEndTime());