From 8949919280a8c580b9cbc146a9d9b439d73b90b5 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 3 Feb 2026 01:21:09 +0100 Subject: [PATCH 01/27] 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, including the regression tests added by #278 (Chouette/OTP/netex-validator-java use cases): - 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 - Build and publish snapshots with Java 21 in CI - Update the README to state NeTEx 2.0, Java 21 and the CEN schema source --- .github/workflows/deploy.yml | 4 +- README.md | 12 +-- bindings.xjb | 54 +++++++++---- pom.xml | 49 ++++++++---- .../netex/validation/NeTExValidator.java | 7 +- .../model/AbstractUnmarshalFrameTest.java | 15 +++- .../netex/model/MarshalUnmarshalTest.java | 80 ++++++++++--------- .../rutebanken/netex/model/ToStringTest.java | 4 +- .../UnmarshalResourceFrameExtendedTest.java | 14 ++-- .../model/UnmarshalResourceFrameTest.java | 4 +- .../UnmarshalServiceCalendarFrameTest.java | 2 +- .../UnmarshalServiceFrameChouetteTest.java | 22 ++--- .../UnmarshalServiceFrameExtendedTest.java | 22 ++--- .../model/UnmarshalServiceFrameTest.java | 16 ++-- .../model/UnmarshalSiteFrameChouetteTest.java | 10 +-- .../model/UnmarshalSiteFrameExtendedTest.java | 12 +-- .../netex/model/UnmarshalSiteFrameTest.java | 14 ++-- .../UnmarshalTimetableFrameChouetteTest.java | 6 +- .../UnmarshalTimetableFrameExtendedTest.java | 2 +- .../model/UnmarshalTimetableFrameTest.java | 2 +- .../model/UnmarshalTransportSubModeTest.java | 46 +++++------ ...rshalVehicleScheduleFrameChouetteTest.java | 4 +- .../netex/validation/NeTExValidatorTest.java | 11 +-- 23 files changed, 233 insertions(+), 179 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c835c8c6..ce89b5ef 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,7 +22,7 @@ jobs: sudo apt-get -y install xmlstarlet - uses: actions/setup-java@v6.0.1 with: - java-version: 17 + java-version: 21 distribution: liberica - name: Cache Maven dependencies uses: actions/cache@v6.1.0 @@ -75,6 +75,6 @@ jobs: 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/README.md b/README.md index 6cec8b98..2215b245 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.1 (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. A version is validated against its latest patch schema: documents declaring 1.16 are validated against the 1.16.1 schema, which is backward compatible with 1.16. +**Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.07 through 2.0. A version is validated against its latest patch schema: documents declaring 1.16 are validated against the 1.16.1 schema, which is backward compatible with 1.16. **Note on GML types**: This library generates classes under `net.opengis.gml._3` as part of the NeTEx model. diff --git a/bindings.xjb b/bindings.xjb index ffcaccde..6c509603 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 f6aa7eb9..903bd70f 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 - tags/v1.0.16.1 - https://github.com/entur/${netexRepoName} - 1.16.1 + 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-tags-v1.0.16.1/xsd/* + NeTEx-${netexVersion}/xsd/* ./bin/netex-download-extract.sh @@ -305,6 +306,22 @@ + + + download-extract-legacy-1.16 + generate-resources + + exec + + + + ${enturNetexGithubUrl}/archive/tags/v1.0.16.1.zip + src/main/resources/xsd/1.16.1 + NeTEx-tags-v1.0.16.1/xsd/* + + ./bin/netex-download-extract.sh + + download-extract-legacy-1.15 @@ -314,7 +331,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 +347,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 +363,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 +379,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 +395,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 +411,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 +427,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 +443,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/* @@ -673,7 +690,7 @@ - 11 + 21 diff --git a/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java b/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java index 7cd69393..c40c07c1 100644 --- a/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java +++ b/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java @@ -47,14 +47,15 @@ public enum NetexVersion { /** * NeTEx 1.16, validated against the latest 1.16 patch schema. Patch releases of the schema * are backward compatible, and documents only ever declare the minor version, so a document - * declaring 1.16 is validated against the same schema the model is generated from. + * declaring 1.16 is validated against the 1.16.1 schema. */ v1_16 ("1.16", "1.16.1"), /** * @deprecated the 1.16.1 schema is what {@link #v1_16} validates against. Use {@link #v1_16}. */ @Deprecated - v1_16_1 ("1.16.1"); + v1_16_1 ("1.16.1"), + v2_0 ("2.0"); private final String version; private final String folderName; @@ -78,7 +79,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 485f8a58..35c01413 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 e2df73b6..7b2e0259 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(); @@ -302,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"))); @@ -336,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"); } @@ -346,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) @@ -367,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); @@ -383,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)); @@ -402,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/ToStringTest.java b/src/test/java/org/rutebanken/netex/model/ToStringTest.java index 895f5677..a2e253d8 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/UnmarshalResourceFrameExtendedTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameExtendedTest.java index 7ca3c6bb..42e5f78c 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()); } @@ -157,13 +157,13 @@ void unmarshalResponsibilitySetWithAssociatedContract() throws JAXBException { ResourceFrame resourceFrame = (ResourceFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); ResponsibilitySet responsibilitySet = resourceFrame.getResponsibilitySets().getResponsibilitySet().get(0); - assertEquals("Contracted operation", responsibilitySet.getName().getValue()); + assertEquals("Contracted operation", getStringValue(responsibilitySet.getName())); ResponsibilityRoleAssignment_VersionedChildStructure roleAssignment = responsibilitySet.getRoles().getResponsibilityRoleAssignment().get(0); ContractRef_RelStructure associatedContract = roleAssignment.getAssociatedContract(); assertNotNull(associatedContract); - ContractRefStructure contractRef = associatedContract.getContractRef(); + ContractRefStructure contractRef = associatedContract.getContractRef().getValue(); assertNotNull(contractRef); assertEquals("TST:Contract:1", contractRef.getRef()); assertEquals("1", contractRef.getVersion()); diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java index 3fd60384..715cff1f 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 34da902f..ac46cee7 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/UnmarshalServiceFrameChouetteTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameChouetteTest.java index 38178919..6b4a132c 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 26dba195..c117244d 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/UnmarshalServiceFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameTest.java index d7ebdf88..639f9544 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/UnmarshalSiteFrameChouetteTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameChouetteTest.java index ee529781..26b300ee 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 66a46924..f23180bb 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/UnmarshalSiteFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java index 06c9b992..6171ab65 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/UnmarshalTimetableFrameChouetteTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameChouetteTest.java index 45d1c660..300761fe 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 b1fe8ac3..7e6db9ae 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/UnmarshalTimetableFrameTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameTest.java index 9f2dcbf7..25d3493b 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()); diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java b/src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java index fc036702..96c89526 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 ba60d3f7..3b2e8448 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()); diff --git a/src/test/java/org/rutebanken/netex/validation/NeTExValidatorTest.java b/src/test/java/org/rutebanken/netex/validation/NeTExValidatorTest.java index 74168092..6f2d3254 100644 --- a/src/test/java/org/rutebanken/netex/validation/NeTExValidatorTest.java +++ b/src/test/java/org/rutebanken/netex/validation/NeTExValidatorTest.java @@ -56,6 +56,8 @@ void validatePublicationDeliveryWithLatestVersion() throws IOException, SAXExcep /** * AssociatedContract / ContractRef on a ResponsibilityRoleAssignment was added in NeTEx 1.16.1 * (entur/NeTEx#63). 1.16 is validated against the 1.16.1 schema, so it is valid against 1.16 too. + * It is not validated against 2.0 here: 2.0 enforces a key reference from ContractRef to a Contract + * declared in the same document, which 1.16.1 has no place for in a ResourceFrame. */ private static final String RESPONSIBILITY_SET_WITH_ASSOCIATED_CONTRACT = "\n" + "\n" + @@ -80,8 +82,8 @@ void validatePublicationDeliveryWithLatestVersion() throws IOException, SAXExcep ""; @Test - void latestVersionIs1_16() { - assertEquals(NeTExValidator.NetexVersion.v1_16, NeTExValidator.LATEST); + void latestVersionIs2_0() { + assertEquals(NeTExValidator.NetexVersion.v2_0, NeTExValidator.LATEST); } @Test @@ -89,11 +91,6 @@ void version1_16IsNamed1_16() { assertEquals("1.16", NeTExValidator.NetexVersion.v1_16.toString()); } - @Test - void validateResponsibilitySetWithAssociatedContractAgainstLatestVersion() throws IOException, SAXException { - neTExValidator.validate(new StreamSource(new StringReader(RESPONSIBILITY_SET_WITH_ASSOCIATED_CONTRACT))); - } - @Test void validateResponsibilitySetWithAssociatedContractAgainstVersion1_16() throws IOException, SAXException { NeTExValidator validator1_16 = NeTExValidator.getNeTExValidator(NeTExValidator.NetexVersion.v1_16); From a1c99fb7d33208b86994e9e72a002ea5f974fb16 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Thu, 24 Sep 2026 14:37:11 +0200 Subject: [PATCH 02/27] Download NeTEx XSD from the TransmodelEcosystem repository The NeTEx GitHub repository moved from NeTEx-CEN/NeTEx to TransmodelEcosystem/NeTEx. --- README.md | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2215b245..60b5f9ba 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ [![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue.svg)](https://joinup.ec.europa.eu/software/page/eupl) [![Java 21+](https://img.shields.io/badge/Java-21%2B-orange)](https://adoptium.net/) -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). +Java model classes generated from [NeTEx](https://github.com/TransmodelEcosystem/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 [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). +This library downloads the NeTEx XSD files from the [NeTEx repository](https://github.com/TransmodelEcosystem/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**: 2.0 (model generation), with legacy validation support back to 1.07 - **JAXB**: Jakarta XML Bind 4.x (Jakarta EE 9+) diff --git a/pom.xml b/pom.xml index 903bd70f..7e0a7cb6 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ NeTEx v2.0 - https://github.com/NeTEx-CEN/${netexRepoName} + https://github.com/TransmodelEcosystem/${netexRepoName} https://github.com/entur/${netexRepoName} 2.0 From d4d3c4b66c113cea27010e76382f75bae09ce2a7 Mon Sep 17 00:00:00 2001 From: Thomas Gran Date: Mon, 21 Sep 2026 12:29:05 +0200 Subject: [PATCH 03/27] Turn netex-java-model into a JPMS module Adds module-info.java declaring org.entur.netex.java.model, replacing the Automatic-Module-Name manifest entry. requires transitive is used for jakarta.xml.bind, java.xml and org.apache.commons.lang3 since their types leak into the public API (JAXBException, QName/XMLGregorianCalendar, OmitNullsToStringStyle extends ToStringStyle). The generated model packages (org.rutebanken.netex.model, net.opengis.gml._3, uk.org.siri.siri) use field-level JAXB access, so they're opened to jakarta.xml.bind, org.glassfish.jaxb.runtime and org.apache.commons.lang3 - verified by running with each opens target removed until `mvn clean test` passed cleanly on the module path (Surefire auto-detects module-info.java and runs on the module path). Also renames org.rutebanken.util to org.rutebanken.netex.util for consistency with the other org.rutebanken.netex.* packages. --- bindings.xjb | 8 ++++---- pom.xml | 1 - src/main/java/module-info.java | 19 +++++++++++++++++++ .../util/FastLocalDateTimeParser.java | 2 +- .../util/LocalDateTimeISO8601XmlAdapter.java | 2 +- .../{ => netex}/util/LocalDateXmlAdapter.java | 2 +- .../util/LocalTimeISO8601XmlAdapter.java | 2 +- .../{ => netex}/util/VersionXmlAdapter.java | 2 +- .../util/FastLocalDateTimeParserTest.java | 2 +- .../LocalDateTimeISO8601XmlAdapterTest.java | 2 +- .../util/LocalTimeISO8601XmlAdapterTest.java | 2 +- .../util/VersionXmlAdapterTest.java | 2 +- 12 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 src/main/java/module-info.java rename src/main/java/org/rutebanken/{ => netex}/util/FastLocalDateTimeParser.java (99%) rename src/main/java/org/rutebanken/{ => netex}/util/LocalDateTimeISO8601XmlAdapter.java (98%) rename src/main/java/org/rutebanken/{ => netex}/util/LocalDateXmlAdapter.java (98%) rename src/main/java/org/rutebanken/{ => netex}/util/LocalTimeISO8601XmlAdapter.java (98%) rename src/main/java/org/rutebanken/{ => netex}/util/VersionXmlAdapter.java (97%) rename src/test/java/org/rutebanken/{ => netex}/util/FastLocalDateTimeParserTest.java (99%) rename src/test/java/org/rutebanken/{ => netex}/util/LocalDateTimeISO8601XmlAdapterTest.java (98%) rename src/test/java/org/rutebanken/{ => netex}/util/LocalTimeISO8601XmlAdapterTest.java (99%) rename src/test/java/org/rutebanken/{ => netex}/util/VersionXmlAdapterTest.java (98%) diff --git a/bindings.xjb b/bindings.xjb index 6c509603..583c20b1 100644 --- a/bindings.xjb +++ b/bindings.xjb @@ -5,9 +5,9 @@ - - - + + + @@ -53,7 +53,7 @@ - + diff --git a/pom.xml b/pom.xml index 7e0a7cb6..eb72049c 100644 --- a/pom.xml +++ b/pom.xml @@ -647,7 +647,6 @@ - org.entur.netex.java.model ${git.commit.id} ${git.commit.time} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 00000000..1f9a59c2 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,19 @@ +module org.entur.netex.java.model { + requires transitive jakarta.xml.bind; + requires transitive java.xml; + requires transitive org.apache.commons.lang3; + requires io.github.threetenjaxb.core; + requires org.slf4j; + + exports org.rutebanken.netex; + exports org.rutebanken.netex.client; + exports org.rutebanken.netex.validation; + exports org.rutebanken.netex.model; + exports org.rutebanken.netex.util; + exports net.opengis.gml._3; + exports uk.org.siri.siri; + + opens org.rutebanken.netex.model to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3; + opens net.opengis.gml._3 to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3; + opens uk.org.siri.siri to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3; +} diff --git a/src/main/java/org/rutebanken/util/FastLocalDateTimeParser.java b/src/main/java/org/rutebanken/netex/util/FastLocalDateTimeParser.java similarity index 99% rename from src/main/java/org/rutebanken/util/FastLocalDateTimeParser.java rename to src/main/java/org/rutebanken/netex/util/FastLocalDateTimeParser.java index 52567580..3d516129 100644 --- a/src/main/java/org/rutebanken/util/FastLocalDateTimeParser.java +++ b/src/main/java/org/rutebanken/netex/util/FastLocalDateTimeParser.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.util; +package org.rutebanken.netex.util; import java.time.DateTimeException; import java.time.LocalDate; diff --git a/src/main/java/org/rutebanken/util/LocalDateTimeISO8601XmlAdapter.java b/src/main/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapter.java similarity index 98% rename from src/main/java/org/rutebanken/util/LocalDateTimeISO8601XmlAdapter.java rename to src/main/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapter.java index 8838ad64..18b438a5 100644 --- a/src/main/java/org/rutebanken/util/LocalDateTimeISO8601XmlAdapter.java +++ b/src/main/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapter.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.util; +package org.rutebanken.netex.util; import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalDateTime; diff --git a/src/main/java/org/rutebanken/util/LocalDateXmlAdapter.java b/src/main/java/org/rutebanken/netex/util/LocalDateXmlAdapter.java similarity index 98% rename from src/main/java/org/rutebanken/util/LocalDateXmlAdapter.java rename to src/main/java/org/rutebanken/netex/util/LocalDateXmlAdapter.java index 66f5949e..22f46ed9 100644 --- a/src/main/java/org/rutebanken/util/LocalDateXmlAdapter.java +++ b/src/main/java/org/rutebanken/netex/util/LocalDateXmlAdapter.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.util; +package org.rutebanken.netex.util; import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalDate; diff --git a/src/main/java/org/rutebanken/util/LocalTimeISO8601XmlAdapter.java b/src/main/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapter.java similarity index 98% rename from src/main/java/org/rutebanken/util/LocalTimeISO8601XmlAdapter.java rename to src/main/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapter.java index b86c7e08..9e60ce42 100644 --- a/src/main/java/org/rutebanken/util/LocalTimeISO8601XmlAdapter.java +++ b/src/main/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapter.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.util; +package org.rutebanken.netex.util; import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalTime; diff --git a/src/main/java/org/rutebanken/util/VersionXmlAdapter.java b/src/main/java/org/rutebanken/netex/util/VersionXmlAdapter.java similarity index 97% rename from src/main/java/org/rutebanken/util/VersionXmlAdapter.java rename to src/main/java/org/rutebanken/netex/util/VersionXmlAdapter.java index e8cedb60..34231a3b 100644 --- a/src/main/java/org/rutebanken/util/VersionXmlAdapter.java +++ b/src/main/java/org/rutebanken/netex/util/VersionXmlAdapter.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.util; +package org.rutebanken.netex.util; import jakarta.xml.bind.annotation.adapters.XmlAdapter; diff --git a/src/test/java/org/rutebanken/util/FastLocalDateTimeParserTest.java b/src/test/java/org/rutebanken/netex/util/FastLocalDateTimeParserTest.java similarity index 99% rename from src/test/java/org/rutebanken/util/FastLocalDateTimeParserTest.java rename to src/test/java/org/rutebanken/netex/util/FastLocalDateTimeParserTest.java index 857195b7..4177d641 100644 --- a/src/test/java/org/rutebanken/util/FastLocalDateTimeParserTest.java +++ b/src/test/java/org/rutebanken/netex/util/FastLocalDateTimeParserTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.util; +package org.rutebanken.netex.util; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; diff --git a/src/test/java/org/rutebanken/util/LocalDateTimeISO8601XmlAdapterTest.java b/src/test/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapterTest.java similarity index 98% rename from src/test/java/org/rutebanken/util/LocalDateTimeISO8601XmlAdapterTest.java rename to src/test/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapterTest.java index 3abd18a7..239e2671 100644 --- a/src/test/java/org/rutebanken/util/LocalDateTimeISO8601XmlAdapterTest.java +++ b/src/test/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapterTest.java @@ -1,4 +1,4 @@ -package org.rutebanken.util; +package org.rutebanken.netex.util; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/rutebanken/util/LocalTimeISO8601XmlAdapterTest.java b/src/test/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapterTest.java similarity index 99% rename from src/test/java/org/rutebanken/util/LocalTimeISO8601XmlAdapterTest.java rename to src/test/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapterTest.java index f32e1af3..b2bc0c13 100644 --- a/src/test/java/org/rutebanken/util/LocalTimeISO8601XmlAdapterTest.java +++ b/src/test/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapterTest.java @@ -1,4 +1,4 @@ -package org.rutebanken.util; +package org.rutebanken.netex.util; import java.util.List; import java.util.stream.Collectors; diff --git a/src/test/java/org/rutebanken/util/VersionXmlAdapterTest.java b/src/test/java/org/rutebanken/netex/util/VersionXmlAdapterTest.java similarity index 98% rename from src/test/java/org/rutebanken/util/VersionXmlAdapterTest.java rename to src/test/java/org/rutebanken/netex/util/VersionXmlAdapterTest.java index 825c5cf1..b2eb8527 100644 --- a/src/test/java/org/rutebanken/util/VersionXmlAdapterTest.java +++ b/src/test/java/org/rutebanken/netex/util/VersionXmlAdapterTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.util; +package org.rutebanken.netex.util; import org.junit.jupiter.api.Test; From 952c8f29116bc416e912a1386b12504ae0f48d78 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Fri, 25 Sep 2026 08:14:26 +0200 Subject: [PATCH 04/27] Update CLAUDE.md for the JPMS module and the netex.util package rename --- CLAUDE.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 063a38df..7fd79aa3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -9,7 +9,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co - **Organization**: Entur AS (Norwegian public transport data provider) - **License**: EUPL-1.2 - **Java Version**: 11+ (builds on 17 in CI) -- **Package**: `org.rutebanken.netex.model` (generated), `org.rutebanken.netex` and `org.rutebanken.util` (source) +- **Package**: `org.rutebanken.netex.model` (generated), `org.rutebanken.netex` and `org.rutebanken.netex.util` (source) ## Build Commands @@ -37,9 +37,10 @@ mvn validate │ ├── annotation-replacer.sh # Post-processes generated Java files │ └── version_updater.sh # Updates version references ├── bindings.xjb # JAXB customization bindings -├── src/main/java/org/rutebanken/ -│ ├── netex/ # Utilities (validation, client, toString style) -│ └── util/ # XML adapters for Java 8 time types +├── src/main/java/ +│ ├── module-info.java # JPMS module descriptor (org.entur.netex.java.model) +│ └── org/rutebanken/netex/ # Utilities (validation, client, toString style) +│ └── util/ # XML adapters for Java 8 time types ├── src/main/resources/xsd/ # NeTEx XSD files (downloaded at build time) ├── src/test/ # JUnit 5 tests for marshalling/unmarshalling └── target/generated-sources/ # JAXB-generated model classes (build artifact) @@ -54,7 +55,7 @@ mvn validate - **Generated Code**: Model classes are generated in `target/generated-sources/` during build. Do not manually edit generated code. -- **NeTEx Version**: Configured in `pom.xml` via `` property (currently 1.16). +- **NeTEx Version**: Configured in `pom.xml` via `` property (currently 2.0). - **Validation**: `NeTExValidator` class provides XML schema validation against NeTEx XSD. From 97dd38fbc39353d5d9e3f214f19970e94ad201d6 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 09:33:06 +0200 Subject: [PATCH 05/27] Change Maven coordinates to org.entur:netex2-java-model The NeTEx 2.0 model is published as a separate artifact so that it can coexist with the NeTEx 1.x model (org.entur:netex-java-model) on the same classpath. --- .github/workflows/hotfix-finish.yml | 2 +- .github/workflows/release-finish.yml | 2 +- README.md | 10 +++++----- pom.xml | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/hotfix-finish.yml b/.github/workflows/hotfix-finish.yml index ad126f5a..2a9c8fb5 100644 --- a/.github/workflows/hotfix-finish.yml +++ b/.github/workflows/hotfix-finish.yml @@ -174,7 +174,7 @@ jobs: - **Hotfix Version:** $VERSION - **Git Tag:** \`v${VERSION}\` - - **Maven Central (netex-java-model):** https://central.sonatype.com/artifact/org.entur/netex-java-model/${VERSION} + - **Maven Central (netex2-java-model):** https://central.sonatype.com/artifact/org.entur/netex2-java-model/${VERSION} - **Hotfix Branch:** Deleted - **Merged to master:** ${{ inputs.merge_to_master }} diff --git a/.github/workflows/release-finish.yml b/.github/workflows/release-finish.yml index 2050c05a..6ad43da1 100644 --- a/.github/workflows/release-finish.yml +++ b/.github/workflows/release-finish.yml @@ -277,7 +277,7 @@ jobs: - **Released Version:** $VERSION - **Git Tag:** \`v${VERSION}\` - - **Maven Central (netex-java-model):** https://central.sonatype.com/artifact/org.entur/netex-java-model/${VERSION} + - **Maven Central (netex2-java-model):** https://central.sonatype.com/artifact/org.entur/netex2-java-model/${VERSION} - **Next Development Version ($BASE_BRANCH):** ${{ steps.next_version.outputs.next_version }} - **Release Branch:** Merged to $BASE_BRANCH and deleted diff --git a/README.md b/README.md index 60b5f9ba..eebf7e25 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # netex-java-model [![Build and push](https://github.com/entur/netex-java-model/actions/workflows/deploy.yml/badge.svg)](https://github.com/entur/netex-java-model/actions/workflows/deploy.yml) -[![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) +[![Maven Central](https://img.shields.io/maven-central/v/org.entur/netex2-java-model.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/org.entur/netex2-java-model) +[![Maven Snapshots](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Forg%2Fentur%2Fnetex2-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 21+](https://img.shields.io/badge/Java-21%2B-orange)](https://adoptium.net/) @@ -24,12 +24,12 @@ This library downloads the NeTEx XSD files from the [NeTEx repository](https://g ```xml org.entur - netex-java-model + netex2-java-model LATEST ``` -See [Maven Central](https://central.sonatype.com/artifact/org.entur/netex-java-model) for the latest released version. +See [Maven Central](https://central.sonatype.com/artifact/org.entur/netex2-java-model) for the latest released version. ### Snapshot @@ -52,7 +52,7 @@ Then add the dependency with the snapshot version: ```xml org.entur - netex-java-model + netex2-java-model LATEST-SNAPSHOT ``` diff --git a/pom.xml b/pom.xml index eb72049c..8ce5393a 100644 --- a/pom.xml +++ b/pom.xml @@ -16,10 +16,10 @@ 4.0.0 org.entur - netex-java-model + netex2-java-model 3.0.0-SNAPSHOT - netex-java-model + netex2-java-model Generates Java model from NeTEx XSDs using JAXB. https://github.com/entur/netex-java-model From e3716a427bf06a4aa94f81c6a666d48d0defe2b8 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 09:33:40 +0200 Subject: [PATCH 06/27] Change base package from org.rutebanken.netex to org.entur.netex2 The generated model now lives in org.entur.netex2.model and the hand-written utilities in org.entur.netex2, org.entur.netex2.client, org.entur.netex2.util and org.entur.netex2.validation. The JPMS module is renamed accordingly to org.entur.netex2 so that the module name matches its root package. --- CLAUDE.md | 8 ++++---- README.md | 10 +++++----- bindings.xjb | 10 +++++----- pom.xml | 2 +- src/main/java/module-info.java | 14 +++++++------- .../netex2}/OmitNullsToStringStyle.java | 2 +- .../netex2}/client/PublicationDeliveryClient.java | 8 ++++---- .../netex2}/util/FastLocalDateTimeParser.java | 2 +- .../util/LocalDateTimeISO8601XmlAdapter.java | 2 +- .../netex2}/util/LocalDateXmlAdapter.java | 2 +- .../netex2}/util/LocalTimeISO8601XmlAdapter.java | 2 +- .../netex2}/util/VersionXmlAdapter.java | 2 +- .../netex2}/validation/NeTExValidator.java | 2 +- ...definedSchemaListClasspathResourceResolver.java | 2 +- .../netex2}/model/AbstractUnmarshalFrameTest.java | 2 +- .../netex2}/model/MarshalUnmarshalTest.java | 4 ++-- .../netex => entur/netex2}/model/ToStringTest.java | 2 +- .../model/UnmarshalResourceFrameExtendedTest.java | 2 +- .../netex2}/model/UnmarshalResourceFrameTest.java | 2 +- .../model/UnmarshalServiceCalendarFrameTest.java | 2 +- .../model/UnmarshalServiceFrameChouetteTest.java | 2 +- .../model/UnmarshalServiceFrameExtendedTest.java | 2 +- .../netex2}/model/UnmarshalServiceFrameTest.java | 2 +- .../model/UnmarshalSiteFrameChouetteTest.java | 2 +- .../model/UnmarshalSiteFrameExtendedTest.java | 2 +- .../netex2}/model/UnmarshalSiteFrameTest.java | 2 +- .../model/UnmarshalTimetableFrameChouetteTest.java | 2 +- .../model/UnmarshalTimetableFrameExtendedTest.java | 2 +- .../netex2}/model/UnmarshalTimetableFrameTest.java | 2 +- .../model/UnmarshalTransportSubModeTest.java | 2 +- .../UnmarshalVehicleScheduleFrameChouetteTest.java | 2 +- .../netex2}/util/FastLocalDateTimeParserTest.java | 2 +- .../util/LocalDateTimeISO8601XmlAdapterTest.java | 2 +- .../util/LocalTimeISO8601XmlAdapterTest.java | 2 +- .../netex2}/util/VersionXmlAdapterTest.java | 2 +- .../netex2}/validation/NeTExValidatorTest.java | 2 +- 36 files changed, 57 insertions(+), 57 deletions(-) rename src/main/java/org/{rutebanken/netex => entur/netex2}/OmitNullsToStringStyle.java (97%) rename src/main/java/org/{rutebanken/netex => entur/netex2}/client/PublicationDeliveryClient.java (95%) rename src/main/java/org/{rutebanken/netex => entur/netex2}/util/FastLocalDateTimeParser.java (99%) rename src/main/java/org/{rutebanken/netex => entur/netex2}/util/LocalDateTimeISO8601XmlAdapter.java (98%) rename src/main/java/org/{rutebanken/netex => entur/netex2}/util/LocalDateXmlAdapter.java (98%) rename src/main/java/org/{rutebanken/netex => entur/netex2}/util/LocalTimeISO8601XmlAdapter.java (98%) rename src/main/java/org/{rutebanken/netex => entur/netex2}/util/VersionXmlAdapter.java (97%) rename src/main/java/org/{rutebanken/netex => entur/netex2}/validation/NeTExValidator.java (99%) rename src/main/java/org/{rutebanken/netex => entur/netex2}/validation/PredefinedSchemaListClasspathResourceResolver.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/AbstractUnmarshalFrameTest.java (97%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/MarshalUnmarshalTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/ToStringTest.java (97%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalResourceFrameExtendedTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalResourceFrameTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalServiceCalendarFrameTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalServiceFrameChouetteTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalServiceFrameExtendedTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalServiceFrameTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalSiteFrameChouetteTest.java (98%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalSiteFrameExtendedTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalSiteFrameTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalTimetableFrameChouetteTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalTimetableFrameExtendedTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalTimetableFrameTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalTransportSubModeTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/model/UnmarshalVehicleScheduleFrameChouetteTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/util/FastLocalDateTimeParserTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/util/LocalDateTimeISO8601XmlAdapterTest.java (98%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/util/LocalTimeISO8601XmlAdapterTest.java (99%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/util/VersionXmlAdapterTest.java (98%) rename src/test/java/org/{rutebanken/netex => entur/netex2}/validation/NeTExValidatorTest.java (99%) diff --git a/CLAUDE.md b/CLAUDE.md index 7fd79aa3..9a0e03c8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -9,7 +9,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co - **Organization**: Entur AS (Norwegian public transport data provider) - **License**: EUPL-1.2 - **Java Version**: 11+ (builds on 17 in CI) -- **Package**: `org.rutebanken.netex.model` (generated), `org.rutebanken.netex` and `org.rutebanken.netex.util` (source) +- **Package**: `org.entur.netex2.model` (generated), `org.entur.netex2` and `org.entur.netex2.util` (source) ## Build Commands @@ -38,8 +38,8 @@ mvn validate │ └── version_updater.sh # Updates version references ├── bindings.xjb # JAXB customization bindings ├── src/main/java/ -│ ├── module-info.java # JPMS module descriptor (org.entur.netex.java.model) -│ └── org/rutebanken/netex/ # Utilities (validation, client, toString style) +│ ├── module-info.java # JPMS module descriptor (org.entur.netex2) +│ └── org/entur/netex2/ # Utilities (validation, client, toString style) │ └── util/ # XML adapters for Java 8 time types ├── src/main/resources/xsd/ # NeTEx XSD files (downloaded at build time) ├── src/test/ # JUnit 5 tests for marshalling/unmarshalling @@ -51,7 +51,7 @@ mvn validate - **JAXB Bindings**: The `bindings.xjb` file customizes code generation, including: - Java 8 time type adapters (`LocalDateTime`, `LocalTime`, `Duration`) - Property name conflict resolution - - Package naming (`org.rutebanken.netex.model`) + - Package naming (`org.entur.netex2.model`) - **Generated Code**: Model classes are generated in `target/generated-sources/` during build. Do not manually edit generated code. diff --git a/README.md b/README.md index eebf7e25..b70186e3 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This library downloads the NeTEx XSD files from the [NeTEx repository](https://g - **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` +- **Generated package**: `org.entur.netex2.model` - **GML types package**: `net.opengis.gml._3` ## Usage @@ -88,9 +88,9 @@ The XSD files are downloaded from GitHub during the `generate-sources` phase and │ ├── annotation-replacer.sh # Post-processes generated Java files │ └── version_updater.sh # Updates version references in bindings ├── bindings.xjb # JAXB customization bindings -├── src/main/java/org/rutebanken/ -│ ├── netex/ # NeTEx utilities (validation, toString style) -│ └── util/ # XML adapters for Java time types +├── src/main/java/org/entur/ +│ └── netex2/ # NeTEx utilities (validation, client, toString style) +│ └── util/ # XML adapters for Java time types ├── src/main/resources/xsd/ # Downloaded NeTEx XSD files (build artifact) └── src/test/ # JUnit 5 marshalling/unmarshalling tests ``` @@ -101,7 +101,7 @@ The XSD files are downloaded from GitHub during the `generate-sources` phase and - Java 8 time type adapters (`LocalDateTime`, `LocalTime`, `Duration`) via `threeten-jaxb-core` - Fluent builder API (`withX()` methods) via `jaxb-fluent-api` - Property name conflict resolution -- Package mapping to `org.rutebanken.netex.model` +- Package mapping to `org.entur.netex2.model` **Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.07 through 2.0. A version is validated against its latest patch schema: documents declaring 1.16 are validated against the 1.16.1 schema, which is backward compatible with 1.16. diff --git a/bindings.xjb b/bindings.xjb index 583c20b1..3906d60a 100644 --- a/bindings.xjb +++ b/bindings.xjb @@ -5,9 +5,9 @@ - - - + + + @@ -16,7 +16,7 @@ | - + @@ -53,7 +53,7 @@ - + diff --git a/pom.xml b/pom.xml index 8ce5393a..9fd93f88 100644 --- a/pom.xml +++ b/pom.xml @@ -535,7 +535,7 @@ -no-header -Xbug986 -Xfluent-api - -Xts:style:org.rutebanken.netex.OmitNullsToStringStyle.INSTANCE + -Xts:style:org.entur.netex2.OmitNullsToStringStyle.INSTANCE diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 1f9a59c2..96b5b3e8 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,19 +1,19 @@ -module org.entur.netex.java.model { +module org.entur.netex2 { requires transitive jakarta.xml.bind; requires transitive java.xml; requires transitive org.apache.commons.lang3; requires io.github.threetenjaxb.core; requires org.slf4j; - exports org.rutebanken.netex; - exports org.rutebanken.netex.client; - exports org.rutebanken.netex.validation; - exports org.rutebanken.netex.model; - exports org.rutebanken.netex.util; + exports org.entur.netex2; + exports org.entur.netex2.client; + exports org.entur.netex2.validation; + exports org.entur.netex2.model; + exports org.entur.netex2.util; exports net.opengis.gml._3; exports uk.org.siri.siri; - opens org.rutebanken.netex.model to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3; + opens org.entur.netex2.model to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3; opens net.opengis.gml._3 to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3; opens uk.org.siri.siri to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3; } diff --git a/src/main/java/org/rutebanken/netex/OmitNullsToStringStyle.java b/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java similarity index 97% rename from src/main/java/org/rutebanken/netex/OmitNullsToStringStyle.java rename to src/main/java/org/entur/netex2/OmitNullsToStringStyle.java index 2aecc0fd..4511e27e 100644 --- a/src/main/java/org/rutebanken/netex/OmitNullsToStringStyle.java +++ b/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex; +package org.entur.netex2; import org.apache.commons.lang3.builder.ToStringStyle; diff --git a/src/main/java/org/rutebanken/netex/client/PublicationDeliveryClient.java b/src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java similarity index 95% rename from src/main/java/org/rutebanken/netex/client/PublicationDeliveryClient.java rename to src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java index 312b1c7f..10944b01 100644 --- a/src/main/java/org/rutebanken/netex/client/PublicationDeliveryClient.java +++ b/src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java @@ -13,16 +13,16 @@ * limitations under the Licence. */ -package org.rutebanken.netex.client; +package org.entur.netex2.client; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Unmarshaller; -import org.rutebanken.netex.model.ObjectFactory; -import org.rutebanken.netex.model.PublicationDeliveryStructure; -import org.rutebanken.netex.validation.NeTExValidator; +import org.entur.netex2.model.ObjectFactory; +import org.entur.netex2.model.PublicationDeliveryStructure; +import org.entur.netex2.validation.NeTExValidator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; diff --git a/src/main/java/org/rutebanken/netex/util/FastLocalDateTimeParser.java b/src/main/java/org/entur/netex2/util/FastLocalDateTimeParser.java similarity index 99% rename from src/main/java/org/rutebanken/netex/util/FastLocalDateTimeParser.java rename to src/main/java/org/entur/netex2/util/FastLocalDateTimeParser.java index 3d516129..4940d78a 100644 --- a/src/main/java/org/rutebanken/netex/util/FastLocalDateTimeParser.java +++ b/src/main/java/org/entur/netex2/util/FastLocalDateTimeParser.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import java.time.DateTimeException; import java.time.LocalDate; diff --git a/src/main/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapter.java b/src/main/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapter.java similarity index 98% rename from src/main/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapter.java rename to src/main/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapter.java index 18b438a5..8014388f 100644 --- a/src/main/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapter.java +++ b/src/main/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapter.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalDateTime; diff --git a/src/main/java/org/rutebanken/netex/util/LocalDateXmlAdapter.java b/src/main/java/org/entur/netex2/util/LocalDateXmlAdapter.java similarity index 98% rename from src/main/java/org/rutebanken/netex/util/LocalDateXmlAdapter.java rename to src/main/java/org/entur/netex2/util/LocalDateXmlAdapter.java index 22f46ed9..fc2dec8a 100644 --- a/src/main/java/org/rutebanken/netex/util/LocalDateXmlAdapter.java +++ b/src/main/java/org/entur/netex2/util/LocalDateXmlAdapter.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalDate; diff --git a/src/main/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapter.java b/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java similarity index 98% rename from src/main/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapter.java rename to src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java index 9e60ce42..10bf7364 100644 --- a/src/main/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapter.java +++ b/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalTime; diff --git a/src/main/java/org/rutebanken/netex/util/VersionXmlAdapter.java b/src/main/java/org/entur/netex2/util/VersionXmlAdapter.java similarity index 97% rename from src/main/java/org/rutebanken/netex/util/VersionXmlAdapter.java rename to src/main/java/org/entur/netex2/util/VersionXmlAdapter.java index 34231a3b..896c656e 100644 --- a/src/main/java/org/rutebanken/netex/util/VersionXmlAdapter.java +++ b/src/main/java/org/entur/netex2/util/VersionXmlAdapter.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import jakarta.xml.bind.annotation.adapters.XmlAdapter; diff --git a/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java b/src/main/java/org/entur/netex2/validation/NeTExValidator.java similarity index 99% rename from src/main/java/org/rutebanken/netex/validation/NeTExValidator.java rename to src/main/java/org/entur/netex2/validation/NeTExValidator.java index c40c07c1..799b077b 100644 --- a/src/main/java/org/rutebanken/netex/validation/NeTExValidator.java +++ b/src/main/java/org/entur/netex2/validation/NeTExValidator.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.validation; +package org.entur.netex2.validation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/rutebanken/netex/validation/PredefinedSchemaListClasspathResourceResolver.java b/src/main/java/org/entur/netex2/validation/PredefinedSchemaListClasspathResourceResolver.java similarity index 99% rename from src/main/java/org/rutebanken/netex/validation/PredefinedSchemaListClasspathResourceResolver.java rename to src/main/java/org/entur/netex2/validation/PredefinedSchemaListClasspathResourceResolver.java index 6075ea3f..f6012a4a 100644 --- a/src/main/java/org/rutebanken/netex/validation/PredefinedSchemaListClasspathResourceResolver.java +++ b/src/main/java/org/entur/netex2/validation/PredefinedSchemaListClasspathResourceResolver.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.validation; +package org.entur.netex2.validation; import org.w3c.dom.ls.LSInput; import org.w3c.dom.ls.LSResourceResolver; diff --git a/src/test/java/org/rutebanken/netex/model/AbstractUnmarshalFrameTest.java b/src/test/java/org/entur/netex2/model/AbstractUnmarshalFrameTest.java similarity index 97% rename from src/test/java/org/rutebanken/netex/model/AbstractUnmarshalFrameTest.java rename to src/test/java/org/entur/netex2/model/AbstractUnmarshalFrameTest.java index 35c01413..06400c2e 100644 --- a/src/test/java/org/rutebanken/netex/model/AbstractUnmarshalFrameTest.java +++ b/src/test/java/org/entur/netex2/model/AbstractUnmarshalFrameTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java b/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java rename to src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java index 7b2e0259..bc14b7a7 100644 --- a/src/test/java/org/rutebanken/netex/model/MarshalUnmarshalTest.java +++ b/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -415,7 +415,7 @@ void blockRoundTrip() throws JAXBException { @Test void fragmentShouldNotContainNetexNamespace() throws Exception { - JAXBContext netexJaxBContext = JAXBContext.newInstance("net.opengis.gml._3:org.rutebanken.netex.model:uk.org.siri.siri"); + JAXBContext netexJaxBContext = JAXBContext.newInstance("net.opengis.gml._3:org.entur.netex2.model:uk.org.siri.siri"); Marshaller marshaller = netexJaxBContext.createMarshaller(); marshaller.setProperty(jakarta.xml.bind.Marshaller.JAXB_ENCODING, StandardCharsets.UTF_8.name()); diff --git a/src/test/java/org/rutebanken/netex/model/ToStringTest.java b/src/test/java/org/entur/netex2/model/ToStringTest.java similarity index 97% rename from src/test/java/org/rutebanken/netex/model/ToStringTest.java rename to src/test/java/org/entur/netex2/model/ToStringTest.java index a2e253d8..24125fd6 100644 --- a/src/test/java/org/rutebanken/netex/model/ToStringTest.java +++ b/src/test/java/org/entur/netex2/model/ToStringTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameExtendedTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java index 42e5f78c..bf259b71 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java index 715cff1f..83b9be5f 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalResourceFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceCalendarFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalServiceCalendarFrameTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java index ac46cee7..2d6c5395 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceCalendarFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameChouetteTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java index 6b4a132c..fdd7878a 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameExtendedTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java index c117244d..009e3f90 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java index 639f9544..1b98b08c 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalServiceFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameChouetteTest.java similarity index 98% rename from src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameChouetteTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalSiteFrameChouetteTest.java index 26b300ee..7de67110 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameChouetteTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameExtendedTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java index f23180bb..dabf72bd 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java index 6171ab65..7ab306a7 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameChouetteTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java index 300761fe..b4db8e69 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameExtendedTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java index 7e6db9ae..2bc590b2 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java index 25d3493b..ef6c3f3f 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalTimetableFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java index 96c89526..b808ab0f 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalTransportSubModeTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/model/UnmarshalVehicleScheduleFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/model/UnmarshalVehicleScheduleFrameChouetteTest.java rename to src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java index 3b2e8448..cb0411ed 100644 --- a/src/test/java/org/rutebanken/netex/model/UnmarshalVehicleScheduleFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.model; +package org.entur.netex2.model; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; diff --git a/src/test/java/org/rutebanken/netex/util/FastLocalDateTimeParserTest.java b/src/test/java/org/entur/netex2/util/FastLocalDateTimeParserTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/util/FastLocalDateTimeParserTest.java rename to src/test/java/org/entur/netex2/util/FastLocalDateTimeParserTest.java index 4177d641..a74188a4 100644 --- a/src/test/java/org/rutebanken/netex/util/FastLocalDateTimeParserTest.java +++ b/src/test/java/org/entur/netex2/util/FastLocalDateTimeParserTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; diff --git a/src/test/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapterTest.java b/src/test/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapterTest.java similarity index 98% rename from src/test/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapterTest.java rename to src/test/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapterTest.java index 239e2671..acae9c74 100644 --- a/src/test/java/org/rutebanken/netex/util/LocalDateTimeISO8601XmlAdapterTest.java +++ b/src/test/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapterTest.java @@ -1,4 +1,4 @@ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapterTest.java b/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapterTest.java rename to src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java index b2bc0c13..173174e1 100644 --- a/src/test/java/org/rutebanken/netex/util/LocalTimeISO8601XmlAdapterTest.java +++ b/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java @@ -1,4 +1,4 @@ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import java.util.List; import java.util.stream.Collectors; diff --git a/src/test/java/org/rutebanken/netex/util/VersionXmlAdapterTest.java b/src/test/java/org/entur/netex2/util/VersionXmlAdapterTest.java similarity index 98% rename from src/test/java/org/rutebanken/netex/util/VersionXmlAdapterTest.java rename to src/test/java/org/entur/netex2/util/VersionXmlAdapterTest.java index b2eb8527..2c851ba9 100644 --- a/src/test/java/org/rutebanken/netex/util/VersionXmlAdapterTest.java +++ b/src/test/java/org/entur/netex2/util/VersionXmlAdapterTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.util; +package org.entur.netex2.util; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/rutebanken/netex/validation/NeTExValidatorTest.java b/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java similarity index 99% rename from src/test/java/org/rutebanken/netex/validation/NeTExValidatorTest.java rename to src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java index 6f2d3254..a7cf4905 100644 --- a/src/test/java/org/rutebanken/netex/validation/NeTExValidatorTest.java +++ b/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java @@ -13,7 +13,7 @@ * limitations under the Licence. */ -package org.rutebanken.netex.validation; +package org.entur.netex2.validation; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; From e07ba160a25e276462680c4176ff9b704eea4743 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 09:45:04 +0200 Subject: [PATCH 07/27] Map xsd:date to java.time.LocalDate xsd:date elements (OperatingDay/CalendarDate, DayTypeAssignment/Date, ServiceCalendar/FromDate and ToDate, ...) were previously bound to LocalDateTime at midnight. They are now bound to LocalDate. LocalDateXmlAdapter accepts an optional trailing zone offset when unmarshalling, as permitted by xsd:date, and ignores it. Dates are always marshalled as yyyy-MM-dd. xsd:dateTime elements are still bound to LocalDateTime. --- CLAUDE.md | 2 +- README.md | 2 +- bindings.xjb | 2 +- .../netex2/util/LocalDateXmlAdapter.java | 31 ++++++----- .../UnmarshalServiceCalendarFrameTest.java | 5 +- .../netex2/util/LocalDateXmlAdapterTest.java | 53 +++++++++++++++++++ 6 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 src/test/java/org/entur/netex2/util/LocalDateXmlAdapterTest.java diff --git a/CLAUDE.md b/CLAUDE.md index 9a0e03c8..78e67aee 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -49,7 +49,7 @@ mvn validate ## Key Technical Details - **JAXB Bindings**: The `bindings.xjb` file customizes code generation, including: - - Java 8 time type adapters (`LocalDateTime`, `LocalTime`, `Duration`) + - Java 8 time type adapters (`LocalDateTime`, `LocalDate`, `LocalTime`, `Duration`) - Property name conflict resolution - Package naming (`org.entur.netex2.model`) diff --git a/README.md b/README.md index b70186e3..a0211583 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ The XSD files are downloaded from GitHub during the `generate-sources` phase and ## Key Technical Details **JAXB customizations** (`bindings.xjb`): -- Java 8 time type adapters (`LocalDateTime`, `LocalTime`, `Duration`) via `threeten-jaxb-core` +- Java 8 time type adapters (`LocalDateTime`, `LocalDate`, `LocalTime`, `Duration`) via `threeten-jaxb-core` - Fluent builder API (`withX()` methods) via `jaxb-fluent-api` - Property name conflict resolution - Package mapping to `org.entur.netex2.model` diff --git a/bindings.xjb b/bindings.xjb index 3906d60a..4ff53f73 100644 --- a/bindings.xjb +++ b/bindings.xjb @@ -7,7 +7,7 @@ - + diff --git a/src/main/java/org/entur/netex2/util/LocalDateXmlAdapter.java b/src/main/java/org/entur/netex2/util/LocalDateXmlAdapter.java index fc2dec8a..232cf2d1 100644 --- a/src/main/java/org/entur/netex2/util/LocalDateXmlAdapter.java +++ b/src/main/java/org/entur/netex2/util/LocalDateXmlAdapter.java @@ -17,35 +17,34 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; -import java.time.temporal.ChronoField; -public class LocalDateXmlAdapter extends XmlAdapter { - private static final DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd") +/** + * Maps xs:date to {@link LocalDate}. An optional trailing time zone offset (allowed by xs:date) is + * accepted when unmarshalling and ignored; dates are always marshalled without an offset. + */ +public class LocalDateXmlAdapter extends XmlAdapter { + + private static final DateTimeFormatter PARSER = new DateTimeFormatterBuilder() + .append(DateTimeFormatter.ISO_LOCAL_DATE) .optionalStart().appendPattern("XXXXX").optionalEnd() - .parseDefaulting(ChronoField.HOUR_OF_DAY, 0) - .parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0) - .parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0) - .parseDefaulting(ChronoField.OFFSET_SECONDS,OffsetDateTime.now().getLong(ChronoField.OFFSET_SECONDS) ) - .toFormatter(); + .toFormatter(); @Override - public LocalDateTime unmarshal(String inputDate) { + public LocalDate unmarshal(String inputDate) { // fast path for the common forms, the formatter handles everything else LocalDate fast = FastLocalDateTimeParser.parseDate(inputDate); if (fast != null) { - return fast.atStartOfDay(); + return fast; } - return LocalDateTime.parse(inputDate, formatter); + return LocalDate.parse(inputDate, PARSER); } @Override - public String marshal(LocalDateTime inputDate) { - if(inputDate != null) { - return formatter.format(inputDate); + public String marshal(LocalDate inputDate) { + if (inputDate != null) { + return DateTimeFormatter.ISO_LOCAL_DATE.format(inputDate); } else { return null; } diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java index 2d6c5395..d1c61734 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java @@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; +import java.time.LocalDate; import java.time.LocalDateTime; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -132,13 +133,13 @@ void unmarshalServiceCalendarFrame() throws JAXBException { assertEquals(DayOfWeekEnumeration.TUESDAY, dayType.getProperties().getPropertyOfDay().get(0).getDaysOfWeek().get(0)); OperatingDay operatingDay = serviceCalendarFrame.getOperatingDays().getOperatingDay().get(0); - assertEquals(LocalDateTime.of(2023,10,29,0,0), operatingDay.getCalendarDate()); + assertEquals(LocalDate.of(2023, 10, 29), operatingDay.getCalendarDate()); OperatingPeriod operatingPeriod = (OperatingPeriod) serviceCalendarFrame.getOperatingPeriods().getOperatingPeriodOrUicOperatingPeriod().get(0); assertEquals(LocalDateTime.of(2023,8,17,0,0), operatingPeriod.getFromDate()); DayTypeAssignment dayTypeAssignment = serviceCalendarFrame.getDayTypeAssignments().getDayTypeAssignment().get(0); - assertEquals(LocalDateTime.of(2024,5,1,0,0), dayTypeAssignment.getDate()); + assertEquals(LocalDate.of(2024, 5, 1), dayTypeAssignment.getDate()); } diff --git a/src/test/java/org/entur/netex2/util/LocalDateXmlAdapterTest.java b/src/test/java/org/entur/netex2/util/LocalDateXmlAdapterTest.java new file mode 100644 index 00000000..ab4f1965 --- /dev/null +++ b/src/test/java/org/entur/netex2/util/LocalDateXmlAdapterTest.java @@ -0,0 +1,53 @@ +package org.entur.netex2.util; + +import org.junit.jupiter.api.Test; + +import java.time.LocalDate; +import java.time.format.DateTimeParseException; + +import static org.junit.jupiter.api.Assertions.*; + +class LocalDateXmlAdapterTest { + + private final LocalDateXmlAdapter adapter = new LocalDateXmlAdapter(); + + @Test + void testUnmarshalBasicDate() { + LocalDate result = adapter.unmarshal("2026-08-31"); + assertEquals(LocalDate.of(2026, 8, 31), result); + } + + @Test + void testUnmarshalDateWithOffset() { + LocalDate result = adapter.unmarshal("2026-05-03+02:00"); + assertEquals(LocalDate.of(2026, 5, 3), result); + } + + @Test + void testUnmarshalDateWithUtcDesignator() { + LocalDate result = adapter.unmarshal("2026-05-03Z"); + assertEquals(LocalDate.of(2026, 5, 3), result); + } + + @Test + void testUnmarshalDateTimeIsRejected() { + assertThrows(DateTimeParseException.class, () -> adapter.unmarshal("2026-05-03T00:00:00")); + } + + @Test + void testMarshalBasicDate() { + String result = adapter.marshal(LocalDate.of(2026, 8, 31)); + assertEquals("2026-08-31", result); + } + + @Test + void testMarshalNull() { + assertNull(adapter.marshal(null)); + } + + @Test + void testRoundTrip() { + LocalDate original = LocalDate.of(2026, 5, 3); + assertEquals(original, adapter.unmarshal(adapter.marshal(original))); + } +} From ef56abd6c99144bafbc2630b21d2744b29195d99 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 09:45:43 +0200 Subject: [PATCH 08/27] Remove stray '|' character from bindings.xjb --- bindings.xjb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings.xjb b/bindings.xjb index 4ff53f73..a8abb727 100644 --- a/bindings.xjb +++ b/bindings.xjb @@ -14,7 +14,7 @@ -| + From 0744e762fbcf6abadf50a0e4aa8c03d14d9e2938 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 11:10:51 +0200 Subject: [PATCH 09/27] Fix outdated Java version and schema sources in CLAUDE.md --- CLAUDE.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 78e67aee..1a2f343e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,12 +4,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Project Overview -**netex-java-model** is a Java library that generates JAXB model classes from NeTEx (Network Timetable Exchange) XML Schema Definition (XSD) files. The XSD files are downloaded from https://github.com/entur/NeTEx and compiled into Java classes at build time. +**netex2-java-model** (Maven coordinates `org.entur:netex2-java-model`) is a Java library that generates JAXB model classes from NeTEx (Network Timetable Exchange) XML Schema Definition (XSD) files. The NeTEx 2.0 XSD is downloaded from https://github.com/TransmodelEcosystem/NeTEx and compiled into Java classes at build time. The legacy schemas used only for validation (1.04beta - 1.16.1) are downloaded from the Entur fork at https://github.com/entur/NeTEx. - **Organization**: Entur AS (Norwegian public transport data provider) - **License**: EUPL-1.2 -- **Java Version**: 11+ (builds on 17 in CI) -- **Package**: `org.entur.netex2.model` (generated), `org.entur.netex2` and `org.entur.netex2.util` (source) +- **Java Version**: 21+ (builds and publishes on 21 in CI) +- **Package**: `org.entur.netex2.model` (generated), `org.entur.netex2`, `org.entur.netex2.client`, `org.entur.netex2.validation` and `org.entur.netex2.util` (source). GML and SIRI types are generated in `net.opengis.gml._3` and `uk.org.siri.siri`. ## Build Commands @@ -57,7 +57,7 @@ mvn validate - **NeTEx Version**: Configured in `pom.xml` via `` property (currently 2.0). -- **Validation**: `NeTExValidator` class provides XML schema validation against NeTEx XSD. +- **Validation**: `NeTExValidator` class provides XML schema validation against NeTEx XSD, for versions 1.04beta through 2.0. Documents declaring 1.16 are validated against the 1.16.1 schema. ## CI/CD From 207d7aed3e1584861fbd392668688f6c1e7fe39d Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 11:15:23 +0200 Subject: [PATCH 10/27] Drop the deprecated NetexVersion.v1_16_1 The 1.16.1 schema is only reachable through v1_16, which validates against it. The deprecated constant was added for the 2.0.16.x hotfixes and is not needed in the 3.0 API. --- .../java/org/entur/netex2/validation/NeTExValidator.java | 5 ----- .../org/entur/netex2/validation/NeTExValidatorTest.java | 7 ------- 2 files changed, 12 deletions(-) diff --git a/src/main/java/org/entur/netex2/validation/NeTExValidator.java b/src/main/java/org/entur/netex2/validation/NeTExValidator.java index 799b077b..0ea0994b 100644 --- a/src/main/java/org/entur/netex2/validation/NeTExValidator.java +++ b/src/main/java/org/entur/netex2/validation/NeTExValidator.java @@ -50,11 +50,6 @@ public enum NetexVersion { * declaring 1.16 is validated against the 1.16.1 schema. */ v1_16 ("1.16", "1.16.1"), - /** - * @deprecated the 1.16.1 schema is what {@link #v1_16} validates against. Use {@link #v1_16}. - */ - @Deprecated - v1_16_1 ("1.16.1"), v2_0 ("2.0"); private final String version; diff --git a/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java b/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java index a7cf4905..96539069 100644 --- a/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java +++ b/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java @@ -97,11 +97,4 @@ void validateResponsibilitySetWithAssociatedContractAgainstVersion1_16() throws validator1_16.validate(new StreamSource(new StringReader(RESPONSIBILITY_SET_WITH_ASSOCIATED_CONTRACT))); } - @Test - @SuppressWarnings("deprecation") - void validateResponsibilitySetWithAssociatedContractAgainstDeprecatedVersion1_16_1() throws IOException, SAXException { - NeTExValidator validator1_16_1 = NeTExValidator.getNeTExValidator(NeTExValidator.NetexVersion.v1_16_1); - validator1_16_1.validate(new StreamSource(new StringReader(RESPONSIBILITY_SET_WITH_ASSOCIATED_CONTRACT))); - } - } From 707d9deebc8e599af650892c037ff08cec85a52e Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 11:48:38 +0200 Subject: [PATCH 11/27] Build fallback release workflows with Java 21 The manual release and hotfix workflows still set up Java 11, but the enforcer plugin now requires Java 21. --- .github/workflows/hotfix-manual.yml | 2 +- .github/workflows/release-manual.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hotfix-manual.yml b/.github/workflows/hotfix-manual.yml index 7fcc0d6b..e9e4139a 100644 --- a/.github/workflows/hotfix-manual.yml +++ b/.github/workflows/hotfix-manual.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/setup-java@v6.0.1 with: - java-version: 11 + java-version: 21 distribution: liberica cache: maven diff --git a/.github/workflows/release-manual.yml b/.github/workflows/release-manual.yml index e6c6ee3b..de79a20d 100644 --- a/.github/workflows/release-manual.yml +++ b/.github/workflows/release-manual.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/setup-java@v6.0.1 with: - java-version: 11 + java-version: 21 distribution: liberica cache: maven From 74769bbd55dcd432081d2a138d68f3ec00619a3a Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 11:48:44 +0200 Subject: [PATCH 12/27] Upgrade JUnit to 6.1.3 and remove the Renovate pin The pin existed because JUnit 6 requires Java 17 and the library targeted Java 11. The baseline is now Java 21. --- pom.xml | 2 +- renovate.json | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 9fd93f88..c633778d 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ 3.27.7 - 5.14.4 + 6.1.3 1.6.13 diff --git a/renovate.json b/renovate.json index 8d143a2f..39991a8c 100644 --- a/renovate.json +++ b/renovate.json @@ -11,13 +11,6 @@ "matchPackageNames": [ "/^org\\.apache\\.cxf/" ] - }, - { - "description": "Pin JUnit to 5.x - JUnit 6 requires Java 17, this library targets Java 11", - "allowedVersions": "<6.0.0", - "matchPackageNames": [ - "/^org\\.junit/" - ] } ] } From c11932e67ce4088e3b83ad8151bfd9ed734e64ae Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 11:48:58 +0200 Subject: [PATCH 13/27] Fix README drift after the 3.0 changes Use the new artifact name as title, state the actual range of legacy validation schemas, credit threeten-jaxb-core only for Duration, and mention the SIRI package and the JPMS module name. --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a0211583..b9b5f999 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# netex-java-model +# netex2-java-model [![Build and push](https://github.com/entur/netex-java-model/actions/workflows/deploy.yml/badge.svg)](https://github.com/entur/netex-java-model/actions/workflows/deploy.yml) [![Maven Central](https://img.shields.io/maven-central/v/org.entur/netex2-java-model.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/org.entur/netex2-java-model) @@ -10,12 +10,14 @@ Java model classes generated from [NeTEx](https://github.com/TransmodelEcosystem ## Overview -This library downloads the NeTEx XSD files from the [NeTEx repository](https://github.com/TransmodelEcosystem/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). +This library downloads the NeTEx XSD files from the [NeTEx repository](https://github.com/TransmodelEcosystem/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. The legacy schemas used only for validation (1.04beta - 1.16.1) are downloaded from the [Entur NeTEx fork](https://github.com/entur/NeTEx). -- **NeTEx version**: 2.0 (model generation), with legacy validation support back to 1.07 +- **NeTEx version**: 2.0 (model generation), with legacy validation support back to 1.04beta - **JAXB**: Jakarta XML Bind 4.x (Jakarta EE 9+) - **Generated package**: `org.entur.netex2.model` - **GML types package**: `net.opengis.gml._3` +- **SIRI types package**: `uk.org.siri.siri` +- **JPMS module**: `org.entur.netex2` ## Usage @@ -98,14 +100,14 @@ The XSD files are downloaded from GitHub during the `generate-sources` phase and ## Key Technical Details **JAXB customizations** (`bindings.xjb`): -- Java 8 time type adapters (`LocalDateTime`, `LocalDate`, `LocalTime`, `Duration`) via `threeten-jaxb-core` +- Java time type adapters: `LocalDateTime`, `LocalDate` and `LocalTime` via adapters in `org.entur.netex2.util`, `Duration` via `threeten-jaxb-core` - Fluent builder API (`withX()` methods) via `jaxb-fluent-api` - Property name conflict resolution - Package mapping to `org.entur.netex2.model` -**Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.07 through 2.0. A version is validated against its latest patch schema: documents declaring 1.16 are validated against the 1.16.1 schema, which is backward compatible with 1.16. +**Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.04beta through 2.0. A version is validated against its latest patch schema: documents declaring 1.16 are validated against the 1.16.1 schema, which is backward compatible with 1.16. -**Note on GML types**: This library generates classes under `net.opengis.gml._3` as part of the NeTEx model. +**Note on GML and SIRI types**: This library generates classes under `net.opengis.gml._3` and `uk.org.siri.siri` as part of the NeTEx model. These packages are the same as in `netex-java-model` 2.x, so both libraries can share a classpath but not a module path. ## License From 9df65965ca850e548400816900861aa94b595184 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 12:06:38 +0200 Subject: [PATCH 14/27] Upgrade CXF XJC to 4.2.0 and drop the Renovate pin CXF XJC 4.1.x bundles JAXB RI 4.0.6, which generates xsd:list and simple-typed properties with an enumeration type as that enumeration instead of String (JAXB RI #1819). This was pinned on the 2.x line to avoid a source-incompatible change in a patch release; 3.0 is a breaking release, so the type-safe enums are adopted here. 4.2.0 is a dependency-bump release over 4.1.3 with the same JAXB RI 4.0.7 and generates the same model. Generated API changes: - PropertyOfDayStructure.weeksOfMonth: List -> List - RechargingEquipmentProfile_VersionStructure.currentType: String -> CurrentTypeEnumeration - VehicleChargingEquipment_VersionStructure.currentType: String -> CurrentTypeEnumeration - New enums CurrentTypeEnumeration, WeekOfMonthEnumeration, WeeksOfMonthEnumeration --- pom.xml | 4 ++-- renovate.json | 11 +---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index c633778d..f99abac5 100644 --- a/pom.xml +++ b/pom.xml @@ -80,8 +80,8 @@ 2.1.8 2.2.0 - 4.0.2 - 4.0.2 + 4.2.0 + 4.2.0 2.0.19 diff --git a/renovate.json b/renovate.json index 39991a8c..cd36abcd 100644 --- a/renovate.json +++ b/renovate.json @@ -3,14 +3,5 @@ "github>entur/ror-renovate-config", "github>entur/ror-renovate-config:groupNonMajorWeekly" ], - "separateMinorPatch": true, - "packageRules": [ - { - "description": "Pin CXF XJC to 4.0.x - 4.1.x changes code generation for xsd:list with enum itemType (JAXB RI #1819)", - "allowedVersions": "<4.1.0", - "matchPackageNames": [ - "/^org\\.apache\\.cxf/" - ] - } - ] + "separateMinorPatch": true } From 078f54fb997b49665ce4f56ef08b01d285d17389 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 12:19:15 +0200 Subject: [PATCH 15/27] Drop the cxf-xjc-runtime dependency The generated code references nothing under org.apache.cxf: the toString plugin uses OmitNullsToStringStyle from this library. The runtime-scoped jar was only leaked to consumers. --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index f99abac5..4a1794a1 100644 --- a/pom.xml +++ b/pom.xml @@ -138,12 +138,6 @@ ${glassfish-jaxb.version} runtime - - org.apache.cxf.xjc-utils - cxf-xjc-runtime - ${cxf-xjc.version} - runtime - From bc1a231192d7a10d6a749790746cf07fb0c49486 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 12:23:24 +0200 Subject: [PATCH 16/27] Export org.entur.netex2.util only to the JAXB modules The adapters in this package are referenced by the generated model and instantiated reflectively by the JAXB runtime; nothing else needs them. --- src/main/java/module-info.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 96b5b3e8..46ed9023 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -9,7 +9,7 @@ exports org.entur.netex2.client; exports org.entur.netex2.validation; exports org.entur.netex2.model; - exports org.entur.netex2.util; + exports org.entur.netex2.util to jakarta.xml.bind, org.glassfish.jaxb.core, org.glassfish.jaxb.runtime; exports net.opengis.gml._3; exports uk.org.siri.siri; From b43c088bd2edeb2c0f2a95c9d1cfaa8097673909 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 12:23:24 +0200 Subject: [PATCH 17/27] Make the NeTExValidator constructors private Instances are cached per version and obtained through the static getNeTExValidator methods, which the constructor Javadoc already asked callers to use. --- .../netex2/client/PublicationDeliveryClient.java | 2 +- .../org/entur/netex2/validation/NeTExValidator.java | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java b/src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java index 10944b01..c015fb03 100644 --- a/src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java +++ b/src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java @@ -55,7 +55,7 @@ public PublicationDeliveryClient(String publicationDeliveryUrl, boolean validate this.jaxbContext = JAXBContext.newInstance(PublicationDeliveryStructure.class); this.validateAgainstSchema = validateAgainstSchema; if(validateAgainstSchema) { - neTExValidator = new NeTExValidator(); + neTExValidator = NeTExValidator.getNeTExValidator(); } } diff --git a/src/main/java/org/entur/netex2/validation/NeTExValidator.java b/src/main/java/org/entur/netex2/validation/NeTExValidator.java index 0ea0994b..339d4dcb 100644 --- a/src/main/java/org/entur/netex2/validation/NeTExValidator.java +++ b/src/main/java/org/entur/netex2/validation/NeTExValidator.java @@ -105,16 +105,10 @@ public static NeTExValidator getNeTExValidator() throws IOException, SAXExceptio /** - * Use static getNeTExValidator to avoid initializing more schemas than needed. + * Validators are cached per version; use {@link #getNeTExValidator(NetexVersion)} or + * {@link #getNeTExValidator()}. */ - public NeTExValidator() throws IOException, SAXException { - this(LATEST); - } - - /** - * Use static getNeTExValidator to avoid initializing more schemas than needed. - */ - public NeTExValidator(NetexVersion version) throws IOException, SAXException { + private NeTExValidator(NetexVersion version) throws IOException, SAXException { SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); String resourceName = "xsd/"+ version.folderName +"/NeTEx_publication.xsd"; From 7856b096f266e9d471e3fc5d910dc65131bc2122 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:23:15 +0200 Subject: [PATCH 18/27] Stop exporting org.entur.netex2 OmitNullsToStringStyle is only passed by the generated toString() methods to commons-lang3, which calls it through the ToStringStyle type. No module needs the package exported. --- src/main/java/module-info.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 46ed9023..666ffda3 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -5,7 +5,6 @@ requires io.github.threetenjaxb.core; requires org.slf4j; - exports org.entur.netex2; exports org.entur.netex2.client; exports org.entur.netex2.validation; exports org.entur.netex2.model; From 6cc3657f9ac6f0ceae8af437928f5be9d2020f38 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:26:58 +0200 Subject: [PATCH 19/27] Remove pre-JReleaser relics from the pom Releases and snapshots are published by JReleaser through the GitHub workflows. The jfrog snapshot repository, the wagon-ssh-external extension, the maven-release-plugin configuration (which referenced profiles that no longer exist) and the unused nexus-staging, gpg and dependency plugin version properties are left over from the previous release process. The sonar profile no longer redeclares jdk.version. --- pom.xml | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/pom.xml b/pom.xml index 4a1794a1..bd6c5e83 100644 --- a/pom.xml +++ b/pom.xml @@ -53,13 +53,6 @@ https://github.com/entur/netex-java-model/tree/master HEAD - - - snapshots - entur2-snapshots - https://entur2.jfrog.io/entur2/libs-snapshot-local - - @@ -92,14 +85,10 @@ 6.1.3 - 1.6.13 3.6.4 3.6.0 3.4.0 3.12.0 - 3.3.1 - 1.6 - 3.1.2 3.16.0 3.5.1 @@ -179,15 +168,6 @@ - - - - org.apache.maven.wagon - wagon-ssh-external - 3.5.3 - - @@ -560,24 +540,6 @@ - - org.apache.maven.plugins - maven-release-plugin - ${maven-release-plugin.version} - - true - false - release,sign,!noPublicDeploy - deploy - - - - org.apache.maven.scm - maven-scm-provider-gitexe - 2.2.1 - - - org.apache.maven.plugins maven-enforcer-plugin @@ -682,10 +644,6 @@ false - - 21 - - From 23d8a26001e605a8d857bc8a5ddc5ba2fdc42927 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:26:58 +0200 Subject: [PATCH 20/27] Delete the downloaded XSD directory on mvn clean The build only removes the schema folders it is about to download again, so folders from earlier builds (1.15.x, 1.16) ended up in locally built jars. --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index bd6c5e83..5feb6d34 100644 --- a/pom.xml +++ b/pom.xml @@ -177,6 +177,14 @@ maven-clean-plugin ${maven-clean-plugin.version} + + + + + src/main/resources/xsd + + + maven-install-plugin From e93483772891d1efeaaa2a72bc5f5ef462db8a82 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:28:36 +0200 Subject: [PATCH 21/27] Fix IntelliJ inspection findings in the handwritten sources - OmitNullsToStringStyle: annotate serialVersionUID with @Serial - LocalTimeISO8601XmlAdapter: Javadoc paragraph break instead of a blank line, which Javadoc ignores - FastLocalDateTimeParser: readDate always started at 0, so the start parameter is dropped; hasValidZoneSuffix was only ever called negated and is inverted into hasInvalidZoneSuffix --- .../entur/netex2/OmitNullsToStringStyle.java | 6 +-- .../netex2/util/FastLocalDateTimeParser.java | 38 +++++++++---------- .../util/LocalTimeISO8601XmlAdapter.java | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java b/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java index 4511e27e..7a0b2b71 100644 --- a/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java +++ b/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java @@ -17,11 +17,11 @@ import org.apache.commons.lang3.builder.ToStringStyle; +import java.io.Serial; + public class OmitNullsToStringStyle extends ToStringStyle { - /** - * - */ + @Serial private static final long serialVersionUID = 7043613680114711384L; public static final ToStringStyle INSTANCE = new OmitNullsToStringStyle(); diff --git a/src/main/java/org/entur/netex2/util/FastLocalDateTimeParser.java b/src/main/java/org/entur/netex2/util/FastLocalDateTimeParser.java index 4940d78a..2e476f52 100644 --- a/src/main/java/org/entur/netex2/util/FastLocalDateTimeParser.java +++ b/src/main/java/org/entur/netex2/util/FastLocalDateTimeParser.java @@ -80,10 +80,10 @@ private FastLocalDateTimeParser() {} * @return the parsed date, or {@code null} if {@code text} is null or not in the supported form */ static LocalDate parseDate(String text) { - if (text == null || text.length() < DATE_LENGTH || !hasValidZoneSuffix(text, DATE_LENGTH)) { + if (text == null || text.length() < DATE_LENGTH || hasInvalidZoneSuffix(text, DATE_LENGTH)) { return null; } - return readDate(text, 0); + return readDate(text); } /** @@ -108,7 +108,7 @@ static LocalDateTime parseDateTime(String text) { if (text == null || text.length() <= DATE_TIME_SEPARATOR || text.charAt(DATE_TIME_SEPARATOR) != 'T') { return null; } - LocalDate date = readDate(text, 0); + LocalDate date = readDate(text); if (date == null) { return null; } @@ -129,20 +129,20 @@ private static LocalTime parseTimeAt(String text, int start) { return null; } int fractionEnd = readFractionEnd(text, timeEnd); - if (fractionEnd == INVALID || !hasValidZoneSuffix(text, fractionEnd)) { + if (fractionEnd == INVALID || hasInvalidZoneSuffix(text, fractionEnd)) { return null; } return readTime(text, start, readNanos(text, timeEnd, fractionEnd)); } - /** Reads {@code yyyy-MM-dd} at {@code start}; {@code null} if malformed or out of range. */ - private static LocalDate readDate(String text, int start) { - if (text.charAt(start + 4) != '-' || text.charAt(start + 7) != '-') { + /** Reads {@code yyyy-MM-dd} at the start of the text; {@code null} if malformed or out of range. */ + private static LocalDate readDate(String text) { + if (text.charAt(4) != '-' || text.charAt(7) != '-') { return null; } - int year = readDigits(text, start, 4); - int month = readDigits(text, start + 5, 2); - int day = readDigits(text, start + 8, 2); + int year = readDigits(text, 0, 4); + int month = readDigits(text, 5, 2); + int day = readDigits(text, 8, 2); // year 0000 is not a valid year-of-era for the 'yyyy' pattern: leave it to the formatter if (year <= 0 || month == INVALID || day == INVALID) { return null; @@ -210,30 +210,30 @@ private static int readNanos(String text, int start, int fractionEnd) { } /** - * Checks that the text either ends at {@code start} or continues with exactly a zone designator: - * {@code Z} or {@code ±HH:MM} within the ±18:00 range. + * Returns {@code true} unless the text ends at {@code start} or continues with exactly a zone + * designator: {@code Z} or {@code ±HH:MM} within the ±18:00 range. */ - private static boolean hasValidZoneSuffix(String text, int start) { + private static boolean hasInvalidZoneSuffix(String text, int start) { int length = text.length(); if (start == length) { - return true; + return false; } char designator = text.charAt(start); if (designator == 'Z') { - return start + 1 == length; + return start + 1 != length; } if (designator != '+' && designator != '-') { - return false; + return true; } if (start + OFFSET_LENGTH != length || text.charAt(start + 3) != ':') { - return false; + return true; } int hours = readDigits(text, start + 1, 2); int minutes = readDigits(text, start + 4, 2); if (hours == INVALID || minutes == INVALID || minutes >= 60) { - return false; + return true; } - return hours < MAX_OFFSET_HOURS || (hours == MAX_OFFSET_HOURS && minutes == 0); + return hours > MAX_OFFSET_HOURS || (hours == MAX_OFFSET_HOURS && minutes != 0); } /** Reads exactly {@code count} ASCII digits starting at {@code start}, or {@link #INVALID}. */ diff --git a/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java b/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java index 10bf7364..df40b756 100644 --- a/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java +++ b/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java @@ -36,7 +36,7 @@ public class LocalTimeISO8601XmlAdapter extends XmlAdapter { /** * We store a cache of parsed LocalTime instances to avoid wasting memory in immutable value * objects that strictly identical and interchangeable. - * + *

* We only cache times that are full seconds to avoid increasing the size of the cache unduly, * since there is a limited number of seconds in a single day. */ From ce96e3fff14e7e19eb6f5a6adb79de5a92623a64 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:35:10 +0200 Subject: [PATCH 22/27] Make OmitNullsToStringStyle final with a private constructor The style is only meant to be used through INSTANCE. This also removes the javac this-escape warning about the overridable setters called from the constructor. --- src/main/java/org/entur/netex2/OmitNullsToStringStyle.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java b/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java index 7a0b2b71..2cc05588 100644 --- a/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java +++ b/src/main/java/org/entur/netex2/OmitNullsToStringStyle.java @@ -19,13 +19,13 @@ import java.io.Serial; -public class OmitNullsToStringStyle extends ToStringStyle { +public final class OmitNullsToStringStyle extends ToStringStyle { @Serial private static final long serialVersionUID = 7043613680114711384L; public static final ToStringStyle INSTANCE = new OmitNullsToStringStyle(); - public OmitNullsToStringStyle() { + private OmitNullsToStringStyle() { this.setUseClassName(false); this.setUseIdentityHashCode(false); this.setUseFieldNames(true); From 2440b25c76a5e0a86dc77a7dd00c17e841576e95 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:40:10 +0200 Subject: [PATCH 23/27] Fix the Sonar code smells in the tests - Replace the 32 string-literal concatenations of XML documents with text blocks (S6126). Trailing spaces inside the documents are kept with \s so the values are unchanged. - Stream.toList() instead of collect(Collectors.toList()) (S6204) - Drop redundant public modifiers from JUnit 5 test classes and methods (S5786) - NeTExValidatorTest: initialise the validator in @BeforeEach instead of an empty constructor (S1186), name the XML constant in upper case (S115) and the local validator variable without digits (S117) - MarshalUnmarshalTest: remove an unused import (S1128) and a String.format with constant arguments (S9397) --- .../model/AbstractUnmarshalFrameTest.java | 2 +- .../netex2/model/MarshalUnmarshalTest.java | 3 +- .../UnmarshalResourceFrameExtendedTest.java | 141 ++--- .../model/UnmarshalResourceFrameTest.java | 141 ++--- .../UnmarshalServiceCalendarFrameTest.java | 172 +++--- .../UnmarshalServiceFrameChouetteTest.java | 493 +++++++++--------- .../UnmarshalServiceFrameExtendedTest.java | 239 ++++----- .../model/UnmarshalServiceFrameTest.java | 211 ++++---- .../netex2/model/UnmarshalSiteFrameTest.java | 197 +++---- .../UnmarshalTimetableFrameChouetteTest.java | 126 ++--- .../UnmarshalTimetableFrameExtendedTest.java | 106 ++-- .../model/UnmarshalTimetableFrameTest.java | 155 +++--- .../model/UnmarshalTransportSubModeTest.java | 122 ++--- ...rshalVehicleScheduleFrameChouetteTest.java | 69 +-- .../util/LocalTimeISO8601XmlAdapterTest.java | 45 +- .../netex2/util/VersionXmlAdapterTest.java | 10 +- .../netex2/validation/NeTExValidatorTest.java | 77 +-- 17 files changed, 1151 insertions(+), 1158 deletions(-) diff --git a/src/test/java/org/entur/netex2/model/AbstractUnmarshalFrameTest.java b/src/test/java/org/entur/netex2/model/AbstractUnmarshalFrameTest.java index 06400c2e..c1757755 100644 --- a/src/test/java/org/entur/netex2/model/AbstractUnmarshalFrameTest.java +++ b/src/test/java/org/entur/netex2/model/AbstractUnmarshalFrameTest.java @@ -25,7 +25,7 @@ abstract class AbstractUnmarshalFrameTest { @BeforeAll - public static void initContext() throws JAXBException { + static void initContext() throws JAXBException { jaxbContext = JAXBContext.newInstance(PublicationDeliveryStructure.class); } diff --git a/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java b/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java index bc14b7a7..5cd5b2d4 100644 --- a/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java +++ b/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java @@ -32,7 +32,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; -import java.time.Duration; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.Arrays; @@ -168,7 +167,7 @@ void dayTypeWithPropertiesOfDay() throws JAXBException { 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")) + DayType dayType = factory.createDayType().withVersion("any").withId("SK4488:dt:weekday") .withName(factory.createMultilingualString().withContent("Ukedager (mandag til fredag)")).withProperties(propertiesOfDay); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java index bf259b71..f6a7406e 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java @@ -30,28 +30,29 @@ class UnmarshalResourceFrameExtendedTest extends AbstractUnmarshalFrameTest { @Test void unmarshalAuthorityWithContactDetails() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.505\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Test Authority\n" + - " \n" + - " +47 99887766\n" + - " https://www.testauthority.no\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.505 + RB + + + + + + + Test Authority + + +47 99887766 + https://www.testauthority.no + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -73,32 +74,33 @@ void unmarshalAuthorityWithContactDetails() throws JAXBException { @Test void unmarshalOperatorWithBrandingRef() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.505\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Test Brand\n" + - " https://www.testbrand.no\n" + - " https://www.testbrand.no/logo.png\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Test Operator\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.505 + RB + + + + + + + Test Brand + https://www.testbrand.no + https://www.testbrand.no/logo.png + + + + + + Test Operator + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -125,27 +127,28 @@ void unmarshalOperatorWithBrandingRef() throws JAXBException { @Test void unmarshalResponsibilitySetWithAssociatedContract() throws JAXBException { - String xml = "\n" + - "\n" + - " 2026-09-10T10:00:00\n" + - " TST\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Contracted operation\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2026-09-10T10:00:00 + TST + + + + + Contracted operation + + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java index 83b9be5f..1e1e882d 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java @@ -29,76 +29,77 @@ class UnmarshalResourceFrameTest extends AbstractUnmarshalFrameTest { @Test void unmarshalResourceFrame() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.505\n" + - " RB\n" + - " Shared data used across line files\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 2023-07-31T00:00:00\n" + - " 2024-08-01T00:00:00\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " VYG\n" + - " http://www.rutebanken.org/ns/vyg\n" + - " \n" + - " \n" + - " PEN\n" + - " http://www.rutebanken.org/ns/pen\n" + - " \n" + - " \n" + - " NSR\n" + - " http://www.rutebanken.org/ns/nsr\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Europe/Oslo\n" + - " no\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Vy\n" + - " \n" + - " https://www.vy.no/\n" + - " \n" + - " authority\n" + - " \n" + - " \n" + - " Vy Tåg\n" + - " operator\n" + - " \n" + - " https://www.vy.no/\n" + - " \n" + - " \n" + - " \n" + - " Vy Tåg\n" + - " \n" + - " https://www.vy.no/\n" + - " \n" + - " authority\n" + - " \n" + - " \n" + - " Vy\n" + - " operator\n" + - " \n" + - " https://www.vy.no/\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.505 + RB + Shared data used across line files + + + + + 2023-07-31T00:00:00 + 2024-08-01T00:00:00 + + + + + VYG + http://www.rutebanken.org/ns/vyg + + + PEN + http://www.rutebanken.org/ns/pen + + + NSR + http://www.rutebanken.org/ns/nsr + + + + + Europe/Oslo + no + + + + + + + Vy + + https://www.vy.no/ + + authority + + + Vy Tåg + operator + + https://www.vy.no/ + + + + Vy Tåg + + https://www.vy.no/ + + authority + + + Vy + operator + + https://www.vy.no/ + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java index d1c61734..25b7d214 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java @@ -31,92 +31,92 @@ class UnmarshalServiceCalendarFrameTest extends AbstractUnmarshalFrameTest { @Test void unmarshalServiceCalendarFrame() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.505\n" + - " RB\n" + - " Shared data used across line files\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 2023-07-31T00:00:00\n" + - " 2024-08-01T00:00:00\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " VYG\n" + - " http://www.rutebanken.org/ns/vyg\n" + - " \n" + - " \n" + - " PEN\n" + - " http://www.rutebanken.org/ns/pen\n" + - " \n" + - " \n" + - " NSR\n" + - " http://www.rutebanken.org/ns/nsr\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Europe/Oslo\n" + - " no\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Tuesday Thursday Friday\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Tuesday Wednesday Thursday\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 2023-10-29\n" + - " \n" + - " \n" + - " 2023-10-30\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 2023-08-17T00:00:00\n" + - " 2024-06-24T00:00:00\n" + - " \n" + - " \n" + - " 2023-08-16T00:00:00\n" + - " 2024-06-23T00:00:00\n" + - " " + - " \n" + - " \n" + - " \n" + - " 2024-05-01\n" + - " \n" + - " false\n" + - " \n" + - " \n" + - " 2024-05-17\n" + - " \n" + - " false\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.505 + RB + Shared data used across line files + + + + + 2023-07-31T00:00:00 + 2024-08-01T00:00:00 + + + + + VYG + http://www.rutebanken.org/ns/vyg + + + PEN + http://www.rutebanken.org/ns/pen + + + NSR + http://www.rutebanken.org/ns/nsr + + + + + Europe/Oslo + no + + + + + + + + + Tuesday Thursday Friday + + + + + + + Tuesday Wednesday Thursday + + + + + + + 2023-10-29 + + + 2023-10-30 + + + + + 2023-08-17T00:00:00 + 2024-06-24T00:00:00 + + + 2023-08-16T00:00:00 + 2024-06-23T00:00:00 + + + + 2024-05-01 + + false + + + 2024-05-17 + + false + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java index fdd7878a..55200889 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java @@ -31,41 +31,42 @@ class UnmarshalServiceFrameChouetteTest extends AbstractUnmarshalFrameTest { @Test void unmarshalBookingArrangementsOnStopPointInJourneyPattern() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " public\n" + - " dayOfTravelOnly\n" + - " beforeBoarding\n" + - " callOffice online\n" + - " 14:00:00\n" + - " PT2H\n" + - " \n" + - " +47 55551234\n" + - " https://booking.example.com\n" + - " \n" + - " Call to book\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + + + + + public + dayOfTravelOnly + beforeBoarding + callOffice online + 14:00:00 + PT2H + + +47 55551234 + https://booking.example.com + + Call to book + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -100,32 +101,33 @@ void unmarshalBookingArrangementsOnStopPointInJourneyPattern() throws JAXBExcept @Test void unmarshalDestinationDisplayWithVias() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Bergen\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Bergen + + + + + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -151,42 +153,43 @@ void unmarshalDestinationDisplayWithVias() throws JAXBException { @Test void unmarshalDirectionAndRouteDirectionType() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Outbound\n" + - " outbound\n" + - " \n" + - " \n" + - " Inbound\n" + - " inbound\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Main Route\n" + - " outbound\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Outbound + outbound + + + Inbound + inbound + + + + + Main Route + outbound + + + + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -214,29 +217,30 @@ void unmarshalDirectionAndRouteDirectionType() throws JAXBException { @Test void unmarshalRoutePointWithProjection() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " true\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + + + + + + true + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -259,29 +263,30 @@ void unmarshalRoutePointWithProjection() throws JAXBException { @Test void unmarshalScheduledStopPointWithTimingPointStatus() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Timing Stop\n" + - " timingPoint\n" + - " \n" + - " \n" + - " Non-Timing Stop\n" + - " notTimingPoint\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Timing Stop + timingPoint + + + Non-Timing Stop + notTimingPoint + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -304,30 +309,31 @@ void unmarshalScheduledStopPointWithTimingPointStatus() throws JAXBException { @Test void unmarshalLinePresentationAndPrivateCode() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Line One\n" + - " bus\n" + - " PRIV001\n" + - " \n" + - " 0054A6\n" + - " FFFFFF\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Line One + bus + PRIV001 + + 0054A6 + FFFFFF + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -352,33 +358,34 @@ void unmarshalLinePresentationAndPrivateCode() throws JAXBException { @Test void unmarshalNoticeWithAlternativeTexts() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Stopper ikke alle holdeplasser\n" + - " A\n" + - " \n" + - " \n" + - " Does not stop at all stops\n" + - " \n" + - " \n" + - " Stannar inte vid alla hallplatser\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Stopper ikke alle holdeplasser + A + + + Does not stop at all stops + + + Stannar inte vid alla hallplatser + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -409,32 +416,33 @@ void unmarshalNoticeWithAlternativeTexts() throws JAXBException { @Test void unmarshalServiceLinkWithLinkSequenceProjection() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 59.91 10.75 59.92 10.76\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + + + + + + 59.91 10.75 59.92 10.76 + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -459,28 +467,29 @@ void unmarshalServiceLinkWithLinkSequenceProjection() throws JAXBException { @Test void unmarshalCodespace() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " TST\n" + - " http://www.rutebanken.org/ns/tst\n" + - " \n" + - " \n" + - " NSR\n" + - " http://www.rutebanken.org/ns/nsr\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + TST + http://www.rutebanken.org/ns/tst + + + NSR + http://www.rutebanken.org/ns/nsr + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java index 009e3f90..295010ed 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java @@ -31,23 +31,24 @@ class UnmarshalServiceFrameExtendedTest extends AbstractUnmarshalFrameTest { @Test void unmarshalNetworkWithAuthorityRef() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Test Network\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + Test Network + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -68,32 +69,33 @@ void unmarshalNetworkWithAuthorityRef() throws JAXBException { @Test void unmarshalDestinationDisplayAndScheduledStopPoint() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Oslo S\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Jernbanetorget\n" + - " \n" + - " \n" + - " Majorstuen\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Oslo S + + + + + Jernbanetorget + + + Majorstuen + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -119,26 +121,27 @@ void unmarshalDestinationDisplayAndScheduledStopPoint() throws JAXBException { @Test void unmarshalServiceLink() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 1234.5\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + 1234.5 + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -161,35 +164,36 @@ void unmarshalServiceLink() throws JAXBException { @Test void unmarshalFlexibleLineAndGroupOfLines() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Flex Route 1\n" + - " bus\n" + - " flexibleAreasOnly\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Line Group A\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Flex Route 1 + bus + flexibleAreasOnly + + + + + Line Group A + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -217,31 +221,32 @@ void unmarshalFlexibleLineAndGroupOfLines() throws JAXBException { @Test void unmarshalNoticeAndNoticeAssignment() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Does not stop at all stops\n" + - " A\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Does not stop at all stops + A + + + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java index 1b98b08c..a04b616a 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java @@ -30,111 +30,112 @@ class UnmarshalServiceFrameTest extends AbstractUnmarshalFrameTest{ @Test void unmarshalServiceFrame() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " Narvik-Riksgränsen (Sverige)\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 2023-07-31T00:00:00\n" + - " 2024-08-01T00:00:00\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " VYG\n" + - " http://www.rutebanken.org/ns/vyg\n" + - " \n" + - " \n" + - " PEN\n" + - " http://www.rutebanken.org/ns/pen\n" + - " \n" + - " \n" + - " NSR\n" + - " http://www.rutebanken.org/ns/nsr\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Europe/Oslo\n" + - " no\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Riksgränsen-Narvik Ofotbanen\n" + - " KJ-NK\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Narvik-Riksgränsen (Sverige)\n" + - " rail\n" + - " F8\n" + - " F8\n" + - " \n" + - " \n" + - " \n" + - " 0054A6\n" + - " FFFFFF\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " KMB-NK\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " false\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " false\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + Narvik-Riksgränsen (Sverige) + + + + + 2023-07-31T00:00:00 + 2024-08-01T00:00:00 + + + + + VYG + http://www.rutebanken.org/ns/vyg + + + PEN + http://www.rutebanken.org/ns/pen + + + NSR + http://www.rutebanken.org/ns/nsr + + + + + Europe/Oslo + no + + + + + + + Riksgränsen-Narvik Ofotbanen + KJ-NK + + + + + + + + + + + + + + + Narvik-Riksgränsen (Sverige) + rail + F8 + F8 + + + + 0054A6 + FFFFFF + + + + + + KMB-NK + + + + + false + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java index 7ab306a7..3b243cc7 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java @@ -31,122 +31,87 @@ class UnmarshalSiteFrameTest extends AbstractUnmarshalFrameTest { @Test void unmarshalSiteFrame() throws JAXBException { - String xml = "" - + "" - + " 2016-05-18T15:00:00.0+01:00" - + " NHR" - + " " - + " " + - " \n" + - " \n" + - " Lillehammer\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 10.461604\n" + - " 61.114889\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Narvik\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 17.434792\n" + - " 68.440156\n" + - " \n" + - " \n" + - " " + - " \n" - + " " - + " " - + " " - + " " - + " 10.8577903" - + " 59.910579" - + " " - + " " - + " Krokstien " - + " bus" - + " \n" + - " \n" + - " \n" + - " " - + " onstreetBus" - + " " - + " " - + " " - + " " - + " 10.8577903" - + " 59.910579" - + " " - + " " - + " outdoors" - + " wellLit" - + " busStop" - + " " - + " " - + " " - + " " + - " \n" + - " \n" + - " \n" + - " 2020-12-11T10:05:19.737\n" + - " \n" + - " \n" + - " \n" + - " zone_type\n" + - " external\n" + - " \n" + - " \n" + - " imported-id\n" + - " \n" + - " \n" + - " \n" + - " 1\n" + - " \n" + - " \n" + - " \n" + - "59.82905206496 10.76591487408 59.84434061779 10.77278128624 59.85878172188 10.7820510006 59.87257035803 10.77767363548 59.88506137242 10.76522818565 59.89664364788 10.75205321789 59.90553214085 10.75819013357 59.9071460207 10.75720308065 59.90858768703 10.75040099859 59.91232066638 10.75396297216 59.91342867802 10.75784674644 59.91263263624 10.76381202221 59.90413339229 10.77188010693 59.88867858273 10.78677168846 59.86171241467 10.79784358978 59.82424195011 10.78273768902 59.82672258934 10.77484126568 59.82523422797 10.77406878948 59.82299077502 10.77501292706 59.82260246975 10.77170844555 59.8253205116 10.77042098522 59.82905206496 10.76591487408\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 2022-02-01T12:14:14.239\n" + - " \n" + - " \n" + - " \n" + - " zone_type\n" + - " external\n" + - " \n" + - " \n" + - " Oslo\n" + - " \n" + - " \n" + - " \n" + - "59.91199795775 10.64158912182 59.91406329688 10.64070937872 59.91460113858 10.64007773233 59.9207425438 10.6681537199 59.92364614029 10.67858214855 59.92401176035 10.68300242901 59.92272131861 10.68866725445 59.91984989492 10.69587705374 59.91853778084 10.69527623892 59.91429994335 10.70132730246 59.91286928215 10.70604799032 59.91261111115 10.71173427343 59.91441826595 10.71802137136 59.91549390663 10.71857927084 59.91727939319 10.72229144812 59.92068876034 10.72806356192 59.91895723278 10.73186156988 59.91865608833 10.73209760427 59.91926912951 10.73379276037 59.91963479781 10.74001548529 59.91834418584 10.74057338476 59.91409556696 10.74834106207 59.91277246826 10.75859782934 59.91148158944 10.76353309393 59.9057688589 10.75793262005 59.90015198557 10.74398513317 59.90202438224 10.72875018597 59.9062853053 10.70458884716 59.90301434241 10.70518966198 59.89647147151 10.69398871422 59.8936515825 10.67596431255 59.89479249528 10.66935530663 59.90172308416 10.66115851879 59.90936229862 10.64764018536 59.91199795775 10.64158912182\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" - + " " - + " " - + ""; + String xml = """ + 2016-05-18T15:00:00.0+01:00 NHR + + Lillehammer + + + + + + + + + + 10.461604 + 61.114889 + + + + + Narvik + + + + + + + + + 17.434792 + 68.440156 + + + + 10.8577903 59.910579 Krokstien bus + + + onstreetBus 10.8577903 59.910579 outdoors wellLit busStop + + + 2020-12-11T10:05:19.737 + + + + zone_type + external + + + imported-id + + + + 1 + + + + 59.82905206496 10.76591487408 59.84434061779 10.77278128624 59.85878172188 10.7820510006 59.87257035803 10.77767363548 59.88506137242 10.76522818565 59.89664364788 10.75205321789 59.90553214085 10.75819013357 59.9071460207 10.75720308065 59.90858768703 10.75040099859 59.91232066638 10.75396297216 59.91342867802 10.75784674644 59.91263263624 10.76381202221 59.90413339229 10.77188010693 59.88867858273 10.78677168846 59.86171241467 10.79784358978 59.82424195011 10.78273768902 59.82672258934 10.77484126568 59.82523422797 10.77406878948 59.82299077502 10.77501292706 59.82260246975 10.77170844555 59.8253205116 10.77042098522 59.82905206496 10.76591487408 + + + + + + + 2022-02-01T12:14:14.239 + + + + zone_type + external + + + Oslo + + + + 59.91199795775 10.64158912182 59.91406329688 10.64070937872 59.91460113858 10.64007773233 59.9207425438 10.6681537199 59.92364614029 10.67858214855 59.92401176035 10.68300242901 59.92272131861 10.68866725445 59.91984989492 10.69587705374 59.91853778084 10.69527623892 59.91429994335 10.70132730246 59.91286928215 10.70604799032 59.91261111115 10.71173427343 59.91441826595 10.71802137136 59.91549390663 10.71857927084 59.91727939319 10.72229144812 59.92068876034 10.72806356192 59.91895723278 10.73186156988 59.91865608833 10.73209760427 59.91926912951 10.73379276037 59.91963479781 10.74001548529 59.91834418584 10.74057338476 59.91409556696 10.74834106207 59.91277246826 10.75859782934 59.91148158944 10.76353309393 59.9057688589 10.75793262005 59.90015198557 10.74398513317 59.90202438224 10.72875018597 59.9062853053 10.70458884716 59.90301434241 10.70518966198 59.89647147151 10.69398871422 59.8936515825 10.67596431255 59.89479249528 10.66935530663 59.90172308416 10.66115851879 59.90936229862 10.64764018536 59.91199795775 10.64158912182 + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java index b4db8e69..605b51cc 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java @@ -33,37 +33,38 @@ class UnmarshalTimetableFrameChouetteTest extends AbstractUnmarshalFrameTest { @Test void unmarshalDeadRun() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Dead Run to Depot\n" + - " bus\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 23:30:00\n" + - " \n" + - " \n" + - " 23:55:00\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Dead Run to Depot + bus + + + + + + + 23:30:00 + + + 23:55:00 + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -94,37 +95,38 @@ void unmarshalDeadRun() throws JAXBException { @Test void unmarshalFlexibleServicePropertiesExtended() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Flex Extended\n" + - " bus\n" + - " \n" + - " dynamicPassingTimes\n" + - " true\n" + - " false\n" + - " public\n" + - " untilPreviousDay\n" + - " beforeBoarding onBoarding\n" + - " Advanced booking required\n" + - " \n" + - " +47 99998888\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Flex Extended + bus + + dynamicPassingTimes + true + false + public + untilPreviousDay + beforeBoarding onBoarding + Advanced booking required + + +47 99998888 + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java index 2bc590b2..0b576625 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java @@ -32,30 +32,31 @@ class UnmarshalTimetableFrameExtendedTest extends AbstractUnmarshalFrameTest { @Test void unmarshalServiceJourneyInterchange() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " true\n" + - " true\n" + - " PT5M\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + true + true + PT5M + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -82,34 +83,35 @@ void unmarshalServiceJourneyInterchange() throws JAXBException { @Test void unmarshalServiceJourneyWithFlexibleServiceProperties() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Flex Service\n" + - " bus\n" + - " \n" + - " public\n" + - " dayOfTravelOnly\n" + - " 12:00:00\n" + - " \n" + - " +47 12345678\n" + - " https://booking.example.com\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Flex Service + bus + + public + dayOfTravelOnly + 12:00:00 + + +47 12345678 + https://booking.example.com + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java index ef6c3f3f..f0aceba8 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java @@ -30,84 +30,83 @@ class UnmarshalTimetableFrameTest extends AbstractUnmarshalFrameTest { @Test void unmarshalTimetableFrame() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " Narvik-Riksgränsen (Sverige)\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 2023-07-31T00:00:00\n" + - " 2024-08-01T00:00:00\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " VYG\n" + - " http://www.rutebanken.org/ns/vyg\n" + - " \n" + - " \n" + - " PEN\n" + - " http://www.rutebanken.org/ns/pen\n" + - " \n" + - " \n" + - " NSR\n" + - " http://www.rutebanken.org/ns/nsr\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Europe/Oslo\n" + - " no\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " ContentCheck\n" + - " 8357BD63\n" + - " \n" + - " \n" + - " 96\n" + - " 96\n" + - " rail\n" + - " \n" + - " regionalRail\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 14:55:00\n" + - " \n" + - " \n" + - " \n" + - " 17:43:00\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " cancellation" + - " \n" + - " \n" + - " " + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + Narvik-Riksgränsen (Sverige) + + + + + 2023-07-31T00:00:00 + 2024-08-01T00:00:00 + + + + + VYG + http://www.rutebanken.org/ns/vyg + + + PEN + http://www.rutebanken.org/ns/pen + + + NSR + http://www.rutebanken.org/ns/nsr + + + + + Europe/Oslo + no + + + + + \s + + + + ContentCheck + 8357BD63 + + + 96 + 96 + rail + + regionalRail + + + + + + + + 14:55:00 + + + + 17:43:00 + + + + \s + + cancellation + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java index b808ab0f..2d70ac99 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java @@ -105,42 +105,43 @@ void unmarshalStopPlaceWithBusSubmode() throws JAXBException { @Test void unmarshalServiceJourneyWithTransportSubmode() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Express Bus 100\n" + - " bus\n" + - " \n" + - " expressBus\n" + - " \n" + - " \n" + - " \n" + - " Regional Rail 200\n" + - " rail\n" + - " \n" + - " regionalRail\n" + - " \n" + - " \n" + - " \n" + - " Local Ferry\n" + - " water\n" + - " \n" + - " localPassengerFerry\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Express Bus 100 + bus + + expressBus + + + + Regional Rail 200 + rail + + regionalRail + + + + Local Ferry + water + + localPassengerFerry + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); @@ -177,30 +178,31 @@ void unmarshalServiceJourneyWithTransportSubmode() throws JAXBException { @Test void unmarshalRouteWithLineRef() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Main Route\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Main Route + + + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java index cb0411ed..201cf3d8 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java @@ -33,40 +33,41 @@ class UnmarshalVehicleScheduleFrameChouetteTest extends AbstractUnmarshalFrameTe @Test void unmarshalBlockInVehicleScheduleFrame() throws JAXBException { - String xml = "\n" + - "\n" + - " 2023-08-03T00:20:33.337\n" + - " RB\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Morning Block\n" + - " First block of the day\n" + - " BLK001\n" + - " 05:30:00\n" + - " 12:00:00\n" + - " 0\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + String xml = """ + + + 2023-08-03T00:20:33.337 + RB + + + + + + + Morning Block + First block of the day + BLK001 + 05:30:00 + 12:00:00 + 0 + + + + + + + + + + + + + + + + + + """; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); diff --git a/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java b/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java index 173174e1..0878b707 100644 --- a/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java +++ b/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java @@ -1,115 +1,114 @@ package org.entur.netex2.util; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import java.time.LocalTime; import static org.junit.jupiter.api.Assertions.*; -public class LocalTimeISO8601XmlAdapterTest { +class LocalTimeISO8601XmlAdapterTest { private final LocalTimeISO8601XmlAdapter adapter = new LocalTimeISO8601XmlAdapter(); @Test - public void testUnmarshalBasicTime() { + void testUnmarshalBasicTime() { LocalTime result = adapter.unmarshal("14:30:00"); assertEquals(LocalTime.of(14, 30, 0), result); } @Test - public void testUnmarshalTimeWithMilliseconds() { + void testUnmarshalTimeWithMilliseconds() { LocalTime result = adapter.unmarshal("14:30:00.123"); assertEquals(LocalTime.of(14, 30, 0, 123_000_000), result); } @Test - public void testUnmarshalTimeWithOffset() { + void testUnmarshalTimeWithOffset() { LocalTime result = adapter.unmarshal("14:30:00+02:00"); assertEquals(LocalTime.of(14, 30, 0), result); } @Test - public void testUnmarshalTimeWithMillisecondsAndOffset() { + void testUnmarshalTimeWithMillisecondsAndOffset() { LocalTime result = adapter.unmarshal("14:30:00.456+01:00"); assertEquals(LocalTime.of(14, 30, 0, 456_000_000), result); } @Test - public void testUnmarshalTimeWithMicroseconds() { + void testUnmarshalTimeWithMicroseconds() { LocalTime result = adapter.unmarshal("07:55:00.398629"); assertEquals(LocalTime.of(7, 55, 0, 398_629_000), result); } @Test - public void testUnmarshalTimeWithMicrosecondsAndOffset() { + void testUnmarshalTimeWithMicrosecondsAndOffset() { LocalTime result = adapter.unmarshal("07:55:00.398629+02:00"); assertEquals(LocalTime.of(7, 55, 0, 398_629_000), result); } @Test - public void testUnmarshalTimeWithNanoseconds() { + void testUnmarshalTimeWithNanoseconds() { LocalTime result = adapter.unmarshal("07:55:00.123456789+02:00"); assertEquals(LocalTime.of(7, 55, 0, 123_456_789), result); } @Test - public void testUnmarshalMidnight() { + void testUnmarshalMidnight() { LocalTime result = adapter.unmarshal("00:00:00"); assertEquals(LocalTime.MIDNIGHT, result); } @Test - public void testUnmarshalNoon() { + void testUnmarshalNoon() { LocalTime result = adapter.unmarshal("12:00:00"); assertEquals(LocalTime.NOON, result); } @Test - public void testUnmarshalEndOfDay() { + void testUnmarshalEndOfDay() { LocalTime result = adapter.unmarshal("23:59:59"); assertEquals(LocalTime.of(23, 59, 59), result); } @Test - public void testMarshalBasicTime() { + void testMarshalBasicTime() { String result = adapter.marshal(LocalTime.of(14, 30, 0)); assertEquals("14:30:00", result); } @Test - public void testMarshalTimeWithNanoseconds() { + void testMarshalTimeWithNanoseconds() { String result = adapter.marshal(LocalTime.of(14, 30, 0, 123_000_000)); assertEquals("14:30:00.123", result); } @Test - public void testMarshalTimeWithMicroseconds() { + void testMarshalTimeWithMicroseconds() { String result = adapter.marshal(LocalTime.of(7, 55, 0, 398_629_000)); assertEquals("07:55:00.398629", result); } @Test - public void testMarshalMidnight() { + void testMarshalMidnight() { String result = adapter.marshal(LocalTime.MIDNIGHT); assertEquals("00:00:00", result); } @Test - public void testMarshalNoon() { + void testMarshalNoon() { String result = adapter.marshal(LocalTime.NOON); assertEquals("12:00:00", result); } @Test - public void testMarshalNull() { + void testMarshalNull() { String result = adapter.marshal(null); assertNull(result); } @Test - public void testRoundTrip() { + void testRoundTrip() { LocalTime original = LocalTime.of(15, 45, 30, 500_000_000); String marshalled = adapter.marshal(original); LocalTime unmarshalled = adapter.unmarshal(marshalled); @@ -117,13 +116,13 @@ public void testRoundTrip() { } @Test - public void testRoundTripWithMicroseconds() { + void testRoundTripWithMicroseconds() { LocalTime original = LocalTime.of(7, 55, 0, 398_629_000); assertEquals(original, adapter.unmarshal(adapter.marshal(original))); } @Test - public void testCaching() { + void testCaching() { String timeString = "10:20:30"; LocalTime first = adapter.unmarshal(timeString); LocalTime second = adapter.unmarshal(timeString); @@ -131,7 +130,7 @@ public void testCaching() { } @Test - public void testCachingIdenticalValue() { + void testCachingIdenticalValue() { var equalInputs = List.of( "12:20:00", "12:20:00+02:00", @@ -141,7 +140,7 @@ public void testCachingIdenticalValue() { var parsed = equalInputs.stream() .map(adapter::unmarshal) - .collect(Collectors.toList()); + .toList(); var first = parsed.get(0); parsed.forEach(time -> assertSame(first, time, "Same time value should return same instance")); diff --git a/src/test/java/org/entur/netex2/util/VersionXmlAdapterTest.java b/src/test/java/org/entur/netex2/util/VersionXmlAdapterTest.java index 2c851ba9..05d48e6f 100644 --- a/src/test/java/org/entur/netex2/util/VersionXmlAdapterTest.java +++ b/src/test/java/org/entur/netex2/util/VersionXmlAdapterTest.java @@ -19,19 +19,19 @@ import static org.junit.jupiter.api.Assertions.*; -public class VersionXmlAdapterTest { +class VersionXmlAdapterTest { private final VersionXmlAdapter adapter = new VersionXmlAdapter(); @Test - public void testUnmarshalReturnsValue() { + void testUnmarshalReturnsValue() { String version = "1.0"; String result = adapter.unmarshal(version); assertEquals("1.0", result); } @Test - public void testUnmarshalDeduplicates() { + void testUnmarshalDeduplicates() { String version1 = new String("any"); String version2 = new String("any"); @@ -46,14 +46,14 @@ public void testUnmarshalDeduplicates() { } @Test - public void testMarshalReturnsInput() { + void testMarshalReturnsInput() { String version = "1.07:NO-NeTEx-networktimetable:1.0"; String result = adapter.marshal(version); assertEquals(version, result); } @Test - public void testMarshalNull() { + void testMarshalNull() { String result = adapter.marshal(null); assertNull(result); } diff --git a/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java b/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java index 96539069..18a5ce90 100644 --- a/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java +++ b/src/test/java/org/entur/netex2/validation/NeTExValidatorTest.java @@ -15,6 +15,7 @@ package org.entur.netex2.validation; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -28,29 +29,32 @@ class NeTExValidatorTest { - private final NeTExValidator neTExValidator = NeTExValidator.getNeTExValidator(); - - public NeTExValidatorTest() throws IOException, SAXException { } + private static final String MINIMAL_PUBLICATION_DELIVERY = """ + + + 2016-11-29T13:32:06.869+01:00 + NSR + """; - public static final String xml = "\n" + - "\n" + - " 2016-11-29T13:32:06.869+01:00\n" + - " NSR\n" + - ""; + private NeTExValidator neTExValidator; + + @BeforeEach + void setUp() throws IOException, SAXException { + neTExValidator = NeTExValidator.getNeTExValidator(); + } - @Test void validationFailsForInvalidXml() { - String xml = "\n" + - ""; + String xml = """ + + """; assertThatThrownBy(() -> neTExValidator.validate(new StreamSource(new StringReader(xml)))).isInstanceOf(SAXParseException.class); } @Test void validatePublicationDeliveryWithLatestVersion() throws IOException, SAXException { - neTExValidator.validate(new StreamSource(new StringReader(xml))); - + neTExValidator.validate(new StreamSource(new StringReader(MINIMAL_PUBLICATION_DELIVERY))); } /** @@ -59,27 +63,28 @@ void validatePublicationDeliveryWithLatestVersion() throws IOException, SAXExcep * It is not validated against 2.0 here: 2.0 enforces a key reference from ContractRef to a Contract * declared in the same document, which 1.16.1 has no place for in a ResourceFrame. */ - private static final String RESPONSIBILITY_SET_WITH_ASSOCIATED_CONTRACT = "\n" + - "\n" + - " 2026-09-10T10:00:00\n" + - " TST\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " Contracted operation\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; + private static final String RESPONSIBILITY_SET_WITH_ASSOCIATED_CONTRACT = """ + + + 2026-09-10T10:00:00 + TST + + + + + Contracted operation + + + + + + + + + + + + """; @Test void latestVersionIs2_0() { @@ -93,8 +98,8 @@ void version1_16IsNamed1_16() { @Test void validateResponsibilitySetWithAssociatedContractAgainstVersion1_16() throws IOException, SAXException { - NeTExValidator validator1_16 = NeTExValidator.getNeTExValidator(NeTExValidator.NetexVersion.v1_16); - validator1_16.validate(new StreamSource(new StringReader(RESPONSIBILITY_SET_WITH_ASSOCIATED_CONTRACT))); + NeTExValidator validator = NeTExValidator.getNeTExValidator(NeTExValidator.NetexVersion.v1_16); + validator.validate(new StreamSource(new StringReader(RESPONSIBILITY_SET_WITH_ASSOCIATED_CONTRACT))); } } From 151467f5ecaf2def87cad541b3c33b076275b7b5 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:45:41 +0200 Subject: [PATCH 24/27] Remove the dead offset default from the date-time and time adapters parseDefaulting(OFFSET_SECONDS, ) had no effect: LocalDateTime.from and LocalTime.from never read the offset, so an offset in the input is ignored whether it is present, absent or defaulted. Parsing and formatting results are unchanged. The adapters now document that behaviour, as LocalDateXmlAdapter already did. --- .../netex2/util/LocalDateTimeISO8601XmlAdapter.java | 13 +++++++------ .../netex2/util/LocalTimeISO8601XmlAdapter.java | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapter.java b/src/main/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapter.java index 8014388f..e7dbc237 100644 --- a/src/main/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapter.java +++ b/src/main/java/org/entur/netex2/util/LocalDateTimeISO8601XmlAdapter.java @@ -17,20 +17,21 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalDateTime; -import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; +/** + * Maps xs:dateTime to {@link LocalDateTime}. An optional trailing time zone offset (allowed by + * xs:dateTime) is accepted when unmarshalling and ignored: the wall-clock time is kept as written. + * Date-times are always marshalled without an offset. + */ public class LocalDateTimeISO8601XmlAdapter extends XmlAdapter { private static final DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd'T'HH:mm:ss") .optionalStart().appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true).optionalEnd() - .optionalStart().appendPattern("XXXXX") - .optionalEnd() - -// - .parseDefaulting(ChronoField.OFFSET_SECONDS,OffsetDateTime.now().getLong(ChronoField.OFFSET_SECONDS) ).toFormatter(); + .optionalStart().appendPattern("XXXXX").optionalEnd() + .toFormatter(); @Override public LocalDateTime unmarshal(String inputDate) { diff --git a/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java b/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java index df40b756..36fa3c76 100644 --- a/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java +++ b/src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java @@ -17,21 +17,22 @@ import jakarta.xml.bind.annotation.adapters.XmlAdapter; import java.time.LocalTime; -import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; import java.util.concurrent.ConcurrentHashMap; +/** + * Maps xs:time to {@link LocalTime}. An optional trailing time zone offset (allowed by xs:time) is + * accepted when unmarshalling and ignored: the wall-clock time is kept as written. Times are always + * marshalled without an offset. + */ public class LocalTimeISO8601XmlAdapter extends XmlAdapter { private static final DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendPattern("HH:mm:ss") .optionalStart().appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true).optionalEnd() - .optionalStart().appendPattern("XXXXX") - .optionalEnd() - -// - .parseDefaulting(ChronoField.OFFSET_SECONDS,OffsetDateTime.now().getLong(ChronoField.OFFSET_SECONDS) ).toFormatter(); + .optionalStart().appendPattern("XXXXX").optionalEnd() + .toFormatter(); /** * We store a cache of parsed LocalTime instances to avoid wasting memory in immutable value From 69e0e2d7f84a36a5b17f2618383d014bbeb7fa4a Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:52:09 +0200 Subject: [PATCH 25/27] Drop release-plugin and shade-plugin entries from .gitignore maven-release-plugin, buildnumber-maven-plugin and maven-shade-plugin are not used, so their backup and output files never appear. --- .gitignore | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.gitignore b/.gitignore index ddac564d..0d150fa9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,5 @@ target/ -pom.xml.tag -pom.xml.releaseBackup pom.xml.versionsBackup -pom.xml.next -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties profile .idea *.iml From f4788fe44a951c39bb7fbab1df8e7b3e99cb9b79 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Tue, 13 Oct 2026 13:52:32 +0200 Subject: [PATCH 26/27] Use getFirst() instead of get(0) in the tests Java 21 SequencedCollection accessor, as suggested by IntelliJ. --- .../netex2/model/MarshalUnmarshalTest.java | 16 ++--- .../UnmarshalResourceFrameExtendedTest.java | 20 +++--- .../model/UnmarshalResourceFrameTest.java | 6 +- .../UnmarshalServiceCalendarFrameTest.java | 14 ++-- .../UnmarshalServiceFrameChouetteTest.java | 68 +++++++++---------- .../UnmarshalServiceFrameExtendedTest.java | 36 +++++----- .../model/UnmarshalServiceFrameTest.java | 18 ++--- .../model/UnmarshalSiteFrameChouetteTest.java | 4 +- .../model/UnmarshalSiteFrameExtendedTest.java | 12 ++-- .../netex2/model/UnmarshalSiteFrameTest.java | 18 ++--- .../UnmarshalTimetableFrameChouetteTest.java | 18 ++--- .../UnmarshalTimetableFrameExtendedTest.java | 12 ++-- .../model/UnmarshalTimetableFrameTest.java | 10 +-- .../model/UnmarshalTransportSubModeTest.java | 20 +++--- ...rshalVehicleScheduleFrameChouetteTest.java | 10 +-- .../util/LocalTimeISO8601XmlAdapterTest.java | 2 +- 16 files changed, 142 insertions(+), 142 deletions(-) diff --git a/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java b/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java index 5cd5b2d4..6594d1d4 100644 --- a/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java +++ b/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java @@ -155,7 +155,7 @@ void timetableWithVehicleModes() throws JAXBException { assertThat(actual.getId()).isNotNull().isNotEmpty().isEqualTo(timetableFrame.getId()); assertThat(actual.getName().getContent()).isNotNull().isNotEmpty().isEqualTo(timetableFrame.getName().getContent()); assertThat(actual.getVehicleModes()).isNotNull().isNotEmpty().hasSize(1); - assertThat(actual.getVehicleModes().get(0)).isNotNull().isEqualTo(AllPublicTransportModesEnumeration.AIR); + assertThat(actual.getVehicleModes().getFirst()).isNotNull().isEqualTo(AllPublicTransportModesEnumeration.AIR); } @Test @@ -186,7 +186,7 @@ void dayTypeWithPropertiesOfDay() throws JAXBException { assertThat(actual.getVersion()).isNotNull().isNotEmpty().isEqualTo(dayType.getVersion()); assertThat(actual.getId()).isNotNull().isNotEmpty().isEqualTo(dayType.getId()); assertThat(actual.getName().getContent()).isNotNull().isNotEmpty().isEqualTo(dayType.getName().getContent()); - assertThat(actual.getProperties().getPropertyOfDay().get(0).getDaysOfWeek()).isNotNull().isNotEmpty().hasSize(5) + assertThat(actual.getProperties().getPropertyOfDay().getFirst().getDaysOfWeek()).isNotNull().isNotEmpty().hasSize(5) .hasOnlyElementsOfType(DayOfWeekEnumeration.class).hasSameElementsAs(daysOfWeek); } @@ -272,9 +272,9 @@ void unmarshalPublicationDeliveryAndVerifyValidBetween() throws JAXBException, I .unmarshal(Files.newInputStream(Paths.get("src/test/resources/date_time_examples.xml"))); PublicationDeliveryStructure actual = jaxbElement.getValue(); CompositeFrame compositeFrame = (CompositeFrame) actual.dataObjects.compositeFrameOrCommonFrame - .get(0).getValue(); + .getFirst().getValue(); ValidityConditions_RelStructure validityConditions = compositeFrame.getValidityConditions(); - ValidBetween validBetweenWithTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_Dummy().get(0); + ValidBetween validBetweenWithTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_Dummy().getFirst(); assertThat(validBetweenWithTimezone.getFromDate()).isNotNull(); assertThat(validBetweenWithTimezone.getToDate()).isNotNull(); assertThat(validBetweenWithTimezone.getToDate()).hasToString("2017-01-01T11:00"); @@ -287,12 +287,12 @@ void unmarshalPublicationDeliveryAndVerifyValidBetween() throws JAXBException, I Timetable_VersionFrameStructure timetableFrame = (Timetable_VersionFrameStructure) compositeFrame.getFrames().getCommonFrame().get(1).getValue(); ServiceJourney_VersionStructure serviceJourney = (ServiceJourney_VersionStructure) timetableFrame.getVehicleJourneys() - .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); + .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().getFirst(); assertThat(serviceJourney.getDepartureTime()).isNotNull(); // Specified as local time assertThat(serviceJourney.getDepartureTime()).hasToString("07:55"); - LocalTime departureTimeZulu = serviceJourney.getPassingTimes().getTimetabledPassingTime().get(0).getDepartureTime(); + LocalTime departureTimeZulu = serviceJourney.getPassingTimes().getTimetabledPassingTime().getFirst().getDepartureTime(); assertThat(departureTimeZulu).isNotNull().hasToString("07:55"); LocalTime departureTimeOffset = serviceJourney.getPassingTimes().getTimetabledPassingTime().get(1).getArrivalTime(); @@ -335,8 +335,8 @@ void networkWithAuthorityRefRoundTrip() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure actual = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) actual.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) actual.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); Network actualNetwork = serviceFrame.getNetwork(); assertThat(actualNetwork.getName().getContent()).isNotNull().isNotEmpty(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java index f6a7406e..3c6fd193 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java @@ -61,11 +61,11 @@ void unmarshalAuthorityWithContactDetails() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_Dummy().get(0).getValue(); + Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_Dummy().getFirst().getValue(); assertEquals("Test Authority", getStringValue(authority.getName())); assertEquals("+47 99887766", authority.getContactDetails().getPhone()); assertEquals("https://www.testauthority.no", authority.getContactDetails().getUrl()); @@ -109,16 +109,16 @@ void unmarshalOperatorWithBrandingRef() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Branding branding = (Branding) resourceFrame.getTypesOfValue().getValueSetOrTypeOfValue().get(0).getValue(); + Branding branding = (Branding) resourceFrame.getTypesOfValue().getValueSetOrTypeOfValue().getFirst().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_Dummy().get(0).getValue(); + Operator operator = (Operator) resourceFrame.getOrganisations().getOrganisation_Dummy().getFirst().getValue(); assertEquals("Test Operator", getStringValue(operator.getName())); assertNotNull(operator.getBrandingRef()); assertEquals("TST:Branding:1", operator.getBrandingRef().getRef()); @@ -157,12 +157,12 @@ void unmarshalResponsibilitySetWithAssociatedContract() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - ResourceFrame resourceFrame = (ResourceFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + ResourceFrame resourceFrame = (ResourceFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ResponsibilitySet responsibilitySet = resourceFrame.getResponsibilitySets().getResponsibilitySet().get(0); + ResponsibilitySet responsibilitySet = resourceFrame.getResponsibilitySets().getResponsibilitySet().getFirst(); assertEquals("Contracted operation", getStringValue(responsibilitySet.getName())); - ResponsibilityRoleAssignment_VersionedChildStructure roleAssignment = responsibilitySet.getRoles().getResponsibilityRoleAssignment().get(0); + ResponsibilityRoleAssignment_VersionedChildStructure roleAssignment = responsibilitySet.getRoles().getResponsibilityRoleAssignment().getFirst(); ContractRef_RelStructure associatedContract = roleAssignment.getAssociatedContract(); assertNotNull(associatedContract); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java index 1e1e882d..c80c50de 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java @@ -108,10 +108,10 @@ void unmarshalResourceFrame() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_Dummy().get(0).getValue(); + ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); + Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_Dummy().getFirst().getValue(); assertEquals("Vy", getStringValue(authority.getName())); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java index 25b7d214..d94c9528 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java @@ -125,20 +125,20 @@ void unmarshalServiceCalendarFrame() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ServiceCalendarFrame serviceCalendarFrame = (ServiceCalendarFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + ServiceCalendarFrame serviceCalendarFrame = (ServiceCalendarFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - DayType dayType = (DayType) serviceCalendarFrame.getDayTypes().getDayType_Dummy().get(0).getValue(); - assertEquals(DayOfWeekEnumeration.TUESDAY, dayType.getProperties().getPropertyOfDay().get(0).getDaysOfWeek().get(0)); + DayType dayType = (DayType) serviceCalendarFrame.getDayTypes().getDayType_Dummy().getFirst().getValue(); + assertEquals(DayOfWeekEnumeration.TUESDAY, dayType.getProperties().getPropertyOfDay().getFirst().getDaysOfWeek().getFirst()); - OperatingDay operatingDay = serviceCalendarFrame.getOperatingDays().getOperatingDay().get(0); + OperatingDay operatingDay = serviceCalendarFrame.getOperatingDays().getOperatingDay().getFirst(); assertEquals(LocalDate.of(2023, 10, 29), operatingDay.getCalendarDate()); - OperatingPeriod operatingPeriod = (OperatingPeriod) serviceCalendarFrame.getOperatingPeriods().getOperatingPeriodOrUicOperatingPeriod().get(0); + OperatingPeriod operatingPeriod = (OperatingPeriod) serviceCalendarFrame.getOperatingPeriods().getOperatingPeriodOrUicOperatingPeriod().getFirst(); assertEquals(LocalDateTime.of(2023,8,17,0,0), operatingPeriod.getFromDate()); - DayTypeAssignment dayTypeAssignment = serviceCalendarFrame.getDayTypeAssignments().getDayTypeAssignment().get(0); + DayTypeAssignment dayTypeAssignment = serviceCalendarFrame.getDayTypeAssignments().getDayTypeAssignment().getFirst(); assertEquals(LocalDate.of(2024, 5, 1), dayTypeAssignment.getDate()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java index 55200889..a9fe9199 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java @@ -75,26 +75,26 @@ void unmarshalBookingArrangementsOnStopPointInJourneyPattern() throws JAXBExcept .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_Dummy().get(0).getValue(); + JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_Dummy().getFirst().getValue(); StopPointInJourneyPattern stopPoint = (StopPointInJourneyPattern) journeyPattern.getPointsInSequence() - .getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern().get(0); + .getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern().getFirst(); BookingArrangementsStructure booking = stopPoint.getBookingArrangements(); assertNotNull(booking); assertEquals(BookingAccessEnumeration.PUBLIC, booking.getBookingAccess()); assertEquals(PurchaseWhenEnumeration.DAY_OF_TRAVEL_ONLY, booking.getBookWhen()); assertEquals(1, booking.getBuyWhen().size()); - assertEquals(PurchaseMomentEnumeration.BEFORE_BOARDING, booking.getBuyWhen().get(0)); + assertEquals(PurchaseMomentEnumeration.BEFORE_BOARDING, booking.getBuyWhen().getFirst()); assertEquals(java.time.LocalTime.of(14, 0), booking.getLatestBookingTime()); 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", getStringValue(booking.getBookingNote())); assertEquals(2, booking.getBookingMethods().size()); - assertEquals(BookingMethodEnumeration.CALL_OFFICE, booking.getBookingMethods().get(0)); + assertEquals(BookingMethodEnumeration.CALL_OFFICE, booking.getBookingMethods().getFirst()); assertEquals(BookingMethodEnumeration.ONLINE, booking.getBookingMethods().get(1)); } @@ -136,15 +136,15 @@ void unmarshalDestinationDisplayWithVias() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - DestinationDisplay dd = serviceFrame.getDestinationDisplays().getDestinationDisplay().get(0); + DestinationDisplay dd = serviceFrame.getDestinationDisplays().getDestinationDisplay().getFirst(); assertEquals("Bergen", getStringValue(dd.getFrontText())); assertNotNull(dd.getVias()); assertEquals(2, dd.getVias().getVia().size()); - Via_VersionedChildStructure via1 = dd.getVias().getVia().get(0); + Via_VersionedChildStructure via1 = dd.getVias().getVia().getFirst(); assertEquals("TST:DestinationDisplay:Via1", via1.getDestinationDisplayRef().getRef()); Via_VersionedChildStructure via2 = dd.getVias().getVia().get(1); assertEquals("TST:DestinationDisplay:Via2", via2.getDestinationDisplayRef().getRef()); @@ -198,17 +198,17 @@ void unmarshalDirectionAndRouteDirectionType() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); assertEquals(2, serviceFrame.getDirections().getDirection().size()); - Direction outbound = serviceFrame.getDirections().getDirection().get(0); + Direction outbound = serviceFrame.getDirections().getDirection().getFirst(); 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_Dummy().get(0).getValue(); + Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().getFirst().getValue(); assertEquals(DirectionTypeEnumeration.OUTBOUND, route.getDirectionType()); assertEquals("TST:Direction:Outbound", route.getDirectionRef().getRef()); assertEquals("TST:Route:2", route.getInverseRouteRef().getRef()); @@ -249,14 +249,14 @@ void unmarshalRoutePointWithProjection() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - RoutePoint routePoint = serviceFrame.getRoutePoints().getRoutePoint().get(0); + RoutePoint routePoint = serviceFrame.getRoutePoints().getRoutePoint().getFirst(); assertTrue(routePoint.isBorderCrossing()); assertNotNull(routePoint.getProjections()); - PointProjection projection = (PointProjection) routePoint.getProjections().getProjectionRefOrProjection().get(0).getValue(); + PointProjection projection = (PointProjection) routePoint.getProjections().getProjectionRefOrProjection().getFirst().getValue(); assertEquals("TST:ScheduledStopPoint:1", projection.getProjectToPointRef().getRef()); } @@ -295,10 +295,10 @@ void unmarshalScheduledStopPointWithTimingPointStatus() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - ScheduledStopPoint ssp1 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().get(0); + ScheduledStopPoint ssp1 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().getFirst(); assertEquals("Timing Stop", getStringValue(ssp1.getName())); assertEquals(TimingPointStatusEnumeration.TIMING_POINT, ssp1.getTimingPointStatus()); @@ -342,10 +342,10 @@ void unmarshalLinePresentationAndPrivateCode() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Line line = (Line) serviceFrame.getLines().getLine_Dummy().get(0).getValue(); + Line line = (Line) serviceFrame.getLines().getLine_Dummy().getFirst().getValue(); assertEquals("Line One", getStringValue(line.getName())); assertEquals("PRIV001", line.getPrivateCode().getValue()); @@ -394,17 +394,17 @@ void unmarshalNoticeWithAlternativeTexts() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Notice notice = serviceFrame.getNotices().getNotice().get(0); + Notice notice = serviceFrame.getNotices().getNotice().getFirst(); 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); + AlternativeText alt1 = notice.getAlternativeTexts().getAlternativeText().getFirst(); assertEquals("Does not stop at all stops", getStringValue(alt1.getText())); assertEquals("en", alt1.getText().getLang()); @@ -451,16 +451,16 @@ void unmarshalServiceLinkWithLinkSequenceProjection() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - ServiceLink serviceLink = serviceFrame.getServiceLinks().getServiceLink().get(0); + ServiceLink serviceLink = serviceFrame.getServiceLinks().getServiceLink().getFirst(); assertEquals("TST:ScheduledStopPoint:1", serviceLink.getFromPointRef().getRef()); assertEquals("TST:ScheduledStopPoint:2", serviceLink.getToPointRef().getRef()); assertNotNull(serviceLink.getProjections()); LinkSequenceProjection_VersionStructure projection = (LinkSequenceProjection_VersionStructure) - serviceLink.getProjections().getProjectionRefOrProjection().get(0).getValue(); + serviceLink.getProjections().getProjectionRefOrProjection().getFirst().getValue(); assertNotNull(projection.getLineString()); } @@ -498,10 +498,10 @@ void unmarshalCodespace() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); assertEquals(2, compositeFrame.getCodespaces().getCodespaceRefOrCodespace().size()); - Codespace codespace1 = (Codespace) compositeFrame.getCodespaces().getCodespaceRefOrCodespace().get(0); + Codespace codespace1 = (Codespace) compositeFrame.getCodespaces().getCodespaceRefOrCodespace().getFirst(); assertEquals("TST", codespace1.getXmlns()); assertEquals("http://www.rutebanken.org/ns/tst", codespace1.getXmlnsUrl()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java index 295010ed..ee1607e9 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java @@ -57,9 +57,9 @@ void unmarshalNetworkWithAuthorityRef() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); Network network = serviceFrame.getNetwork(); assertNotNull(network); assertEquals("Test Network", getStringValue(network.getName())); @@ -104,15 +104,15 @@ void unmarshalDestinationDisplayAndScheduledStopPoint() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - DestinationDisplay destinationDisplay = serviceFrame.getDestinationDisplays().getDestinationDisplay().get(0); + DestinationDisplay destinationDisplay = serviceFrame.getDestinationDisplays().getDestinationDisplay().getFirst(); assertEquals("Oslo S", getStringValue(destinationDisplay.getFrontText())); assertEquals(2, serviceFrame.getScheduledStopPoints().getScheduledStopPoint().size()); - ScheduledStopPoint ssp1 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().get(0); + ScheduledStopPoint ssp1 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().getFirst(); assertEquals("Jernbanetorget", getStringValue(ssp1.getName())); ScheduledStopPoint ssp2 = serviceFrame.getScheduledStopPoints().getScheduledStopPoint().get(1); assertEquals("Majorstuen", getStringValue(ssp2.getName())); @@ -150,12 +150,12 @@ void unmarshalServiceLink() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); assertEquals(1, serviceFrame.getServiceLinks().getServiceLink().size()); - ServiceLink serviceLink = serviceFrame.getServiceLinks().getServiceLink().get(0); + ServiceLink serviceLink = serviceFrame.getServiceLinks().getServiceLink().getFirst(); assertEquals("TST:ScheduledStopPoint:1", serviceLink.getFromPointRef().getRef()); assertEquals("TST:ScheduledStopPoint:2", serviceLink.getToPointRef().getRef()); assertEquals(new BigDecimal("1234.5"), serviceLink.getDistance()); @@ -202,19 +202,19 @@ void unmarshalFlexibleLineAndGroupOfLines() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - FlexibleLine flexibleLine = (FlexibleLine) serviceFrame.getLines().getLine_Dummy().get(0).getValue(); + FlexibleLine flexibleLine = (FlexibleLine) serviceFrame.getLines().getLine_Dummy().getFirst().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); + GroupOfLines groupOfLines = serviceFrame.getGroupsOfLines().getGroupOfLines().getFirst(); 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:1", groupOfLines.getMembers().getLineRef().getFirst().getValue().getRef()); assertEquals("TST:Line:2", groupOfLines.getMembers().getLineRef().get(1).getValue().getRef()); } @@ -255,16 +255,16 @@ void unmarshalNoticeAndNoticeAssignment() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); assertEquals(1, serviceFrame.getNotices().getNotice().size()); - Notice notice = serviceFrame.getNotices().getNotice().get(0); + Notice notice = serviceFrame.getNotices().getNotice().getFirst(); assertEquals("Does not stop at all stops", getStringValue(notice.getText())); assertEquals("A", notice.getPublicCode().getValue()); - NoticeAssignment noticeAssignment = (NoticeAssignment) serviceFrame.getNoticeAssignments().getNoticeAssignment_Dummy().get(0).getValue(); + NoticeAssignment noticeAssignment = (NoticeAssignment) serviceFrame.getNoticeAssignments().getNoticeAssignment_Dummy().getFirst().getValue(); assertEquals("TST:Notice:1", noticeAssignment.getNoticeRef().getRef()); assertEquals("TST:ServiceJourney:1", noticeAssignment.getNoticedObjectRef().getRef()); } diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java index a04b616a..ab509b65 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java @@ -144,35 +144,35 @@ void unmarshalServiceFrame() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - Line line = (Line) serviceFrame.getLines().getLine_Dummy().get(0).getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); + Line line = (Line) serviceFrame.getLines().getLine_Dummy().getFirst().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_Dummy().get(0).getValue(); + Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().getFirst().getValue(); assertEquals("Riksgränsen-Narvik Ofotbanen", getStringValue(route.getName())); assertEquals("KJ-NK", getStringValue(route.getShortName())); - PointOnRoute pointOnRoute = route.getPointsInSequence().getPointOnRoute().get(0); + PointOnRoute pointOnRoute = route.getPointsInSequence().getPointOnRoute().getFirst(); assertEquals("VYG:RoutePoint:KJ", pointOnRoute.getPointRef().getValue().getRef()); - JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_Dummy().get(0).getValue(); + JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_Dummy().getFirst().getValue(); assertEquals("KMB-NK", getStringValue(journeyPattern.getName())); assertEquals("VYG:Route:F8-R", journeyPattern.getRouteRef().getRef()); - StopPointInJourneyPattern stopPointInJourneyPattern = (StopPointInJourneyPattern) journeyPattern.getPointsInSequence().getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern().get(0); + StopPointInJourneyPattern stopPointInJourneyPattern = (StopPointInJourneyPattern) journeyPattern.getPointsInSequence().getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern().getFirst(); assertEquals("VYG:ScheduledStopPoint:KMB-1", stopPointInJourneyPattern.getScheduledStopPointRef().getValue().getRef()); assertFalse(stopPointInJourneyPattern.isForAlighting()); assertEquals("VYG:DestinationDisplay:F8-NK", stopPointInJourneyPattern.getDestinationDisplayRef().getRef()); - ServiceLinkInJourneyPattern_VersionedChildStructure serviceLinkInJourneyPattern = (ServiceLinkInJourneyPattern_VersionedChildStructure) journeyPattern.getLinksInSequence().getServiceLinkInJourneyPatternOrTimingLinkInJourneyPattern().get(0); + ServiceLinkInJourneyPattern_VersionedChildStructure serviceLinkInJourneyPattern = (ServiceLinkInJourneyPattern_VersionedChildStructure) journeyPattern.getLinksInSequence().getServiceLinkInJourneyPatternOrTimingLinkInJourneyPattern().getFirst(); assertEquals("VYG:ServiceLink:KMB-1_ABOe-1_NULL",serviceLinkInJourneyPattern.getServiceLinkRef().getRef()); - PassengerStopAssignment passengerStopAssignment = (PassengerStopAssignment) serviceFrame.getStopAssignments().getStopAssignment().get(0).getValue(); + PassengerStopAssignment passengerStopAssignment = (PassengerStopAssignment) serviceFrame.getStopAssignments().getStopAssignment().getFirst().getValue(); assertEquals("NSR:Quay:111", passengerStopAssignment.getQuayRef().getValue().getRef()); assertEquals("VYG:ScheduledStopPoint:HAL-1", passengerStopAssignment.getScheduledStopPointRef().getValue().getRef()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameChouetteTest.java index 7de67110..fdea7696 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameChouetteTest.java @@ -55,9 +55,9 @@ void unmarshalStopPlaceWithDescriptionAndLandmark() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().get(0); + StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().getFirst(); assertEquals("Oslo S", getStringValue(stopPlace.getName())); assertEquals("Main train station", getStringValue(stopPlace.getDescription())); assertEquals("Central Station Clock Tower", getStringValue(stopPlace.getLandmark())); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java index dabf72bd..23f84de0 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java @@ -63,9 +63,9 @@ void unmarshalStopPlaceWithAccessibilityAssessment() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().get(0); + StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().getFirst(); assertEquals("Accessible Stop", getStringValue(stopPlace.getName())); AccessibilityAssessment assessment = stopPlace.getAccessibilityAssessment(); @@ -103,9 +103,9 @@ void unmarshalFlexibleStopPlace() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - FlexibleStopPlace flexibleStopPlace = siteFrame.getFlexibleStopPlaces().getFlexibleStopPlace().get(0); + FlexibleStopPlace flexibleStopPlace = siteFrame.getFlexibleStopPlaces().getFlexibleStopPlace().getFirst(); assertEquals("Flexible Area North", getStringValue(flexibleStopPlace.getName())); assertEquals(AllPublicTransportModesEnumeration.BUS, flexibleStopPlace.getTransportMode()); } @@ -137,9 +137,9 @@ void unmarshalParking() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - Parking parking = (Parking) siteFrame.getParkings().getParking_Dummy().get(0).getValue(); + Parking parking = (Parking) siteFrame.getParkings().getParking_Dummy().getFirst().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/entur/netex2/model/UnmarshalSiteFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java index 3b243cc7..bd4817c9 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java @@ -120,22 +120,22 @@ void unmarshalSiteFrame() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().get(0); + StopPlace stopPlace = siteFrame.getStopPlaces().getStopPlace().getFirst(); assertEquals("Krokstien", getStringValue(stopPlace.getName())); assertEquals(AllPublicTransportModesEnumeration.BUS, stopPlace.getTransportMode()); assertEquals(StopTypeEnumeration.ONSTREET_BUS, stopPlace.getStopPlaceType()); - assertEquals("BRA:TariffZone:311", stopPlace.getTariffZones().getTariffZoneRef_Dummy().get(0).getValue().getRef()); + assertEquals("BRA:TariffZone:311", stopPlace.getTariffZones().getTariffZoneRef_Dummy().getFirst().getValue().getRef()); - Quay quay = (Quay) stopPlace.getQuays().getQuayRefOrQuay().get(0).getValue(); + Quay quay = (Quay) stopPlace.getQuays().getQuayRefOrQuay().getFirst().getValue(); assertEquals(BigDecimal.valueOf(59.910579), quay.getCentroid().getLocation().getLatitude()); - TariffZone tariffZone = (TariffZone) siteFrame.getTariffZones().getTariffZone().get(0).getValue(); + TariffZone tariffZone = (TariffZone) siteFrame.getTariffZones().getTariffZone().getFirst().getValue(); assertEquals("1", getStringValue(tariffZone.getName())); - GroupOfStopPlaces groupOfStopPlaces = siteFrame.getGroupsOfStopPlaces().getGroupOfStopPlaces().get(0); + GroupOfStopPlaces groupOfStopPlaces = siteFrame.getGroupsOfStopPlaces().getGroupOfStopPlaces().getFirst(); assertEquals("Lillehammer", getStringValue(groupOfStopPlaces.getName())); - assertEquals("NSR:StopPlace:420", groupOfStopPlaces.getMembers().getStopPlaceRef().get(0).getValue().getRef()); + assertEquals("NSR:StopPlace:420", groupOfStopPlaces.getMembers().getStopPlaceRef().getFirst().getValue().getRef()); } @Test @@ -173,9 +173,9 @@ void unmarshalTopographicPlaceWithPolygon() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - TopographicPlace topographicPlace = siteFrame.getTopographicPlaces().getTopographicPlace().get(0); + TopographicPlace topographicPlace = siteFrame.getTopographicPlaces().getTopographicPlace().getFirst(); assertEquals("Oslo", getStringValue(topographicPlace.getDescriptor().getName())); assertEquals(TopographicPlaceTypeEnumeration.MUNICIPALITY, topographicPlace.getTopographicPlaceType()); assertNotNull(topographicPlace.getPolygon()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java index 605b51cc..a2ce0ae7 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameChouetteTest.java @@ -73,22 +73,22 @@ void unmarshalDeadRun() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); DeadRun deadRun = (DeadRun) timetableFrame.getVehicleJourneys() - .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); + .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().getFirst(); 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()); + assertEquals("TST:DayType:Weekday", deadRun.getDayTypes().getDayTypeRef().getFirst().getValue().getRef()); assertEquals("TST:JourneyPattern:DR1", deadRun.getJourneyPatternRef().getValue().getRef()); assertNotNull(deadRun.getPassingTimes()); assertEquals(2, deadRun.getPassingTimes().getTimetabledPassingTime().size()); - assertEquals(LocalTime.of(23, 30), deadRun.getPassingTimes().getTimetabledPassingTime().get(0).getDepartureTime()); + assertEquals(LocalTime.of(23, 30), deadRun.getPassingTimes().getTimetabledPassingTime().getFirst().getDepartureTime()); assertEquals(LocalTime.of(23, 55), deadRun.getPassingTimes().getTimetabledPassingTime().get(1).getArrivalTime()); } @@ -135,11 +135,11 @@ void unmarshalFlexibleServicePropertiesExtended() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); ServiceJourney sj = (ServiceJourney) timetableFrame.getVehicleJourneys() - .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); + .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().getFirst(); FlexibleServiceProperties fsp = sj.getFlexibleServiceProperties(); assertNotNull(fsp); @@ -150,7 +150,7 @@ void unmarshalFlexibleServicePropertiesExtended() throws JAXBException { assertEquals(PurchaseWhenEnumeration.UNTIL_PREVIOUS_DAY, fsp.getBookWhen()); assertEquals(2, fsp.getBuyWhen().size()); - assertEquals(PurchaseMomentEnumeration.BEFORE_BOARDING, fsp.getBuyWhen().get(0)); + assertEquals(PurchaseMomentEnumeration.BEFORE_BOARDING, fsp.getBuyWhen().getFirst()); assertEquals(PurchaseMomentEnumeration.ON_BOARDING, fsp.getBuyWhen().get(1)); assertEquals("Advanced booking required", getStringValue(fsp.getBookingNote())); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java index 0b576625..42829596 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameExtendedTest.java @@ -65,12 +65,12 @@ void unmarshalServiceJourneyInterchange() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); ServiceJourneyInterchange interchange = (ServiceJourneyInterchange) timetableFrame.getJourneyInterchanges() - .getServiceJourneyPatternInterchangeOrServiceJourneyInterchange().get(0); + .getServiceJourneyPatternInterchangeOrServiceJourneyInterchange().getFirst(); assertEquals("TST:ScheduledStopPoint:1", interchange.getFromPointRef().getRef()); assertEquals("TST:ScheduledStopPoint:2", interchange.getToPointRef().getRef()); assertEquals("TST:ServiceJourney:1", interchange.getFromJourneyRef().getRef()); @@ -120,12 +120,12 @@ void unmarshalServiceJourneyWithFlexibleServiceProperties() throws JAXBException .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); ServiceJourney serviceJourney = (ServiceJourney) timetableFrame.getVehicleJourneys() - .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); + .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().getFirst(); assertEquals("Flex Service", getStringValue(serviceJourney.getName())); FlexibleServiceProperties flexProps = serviceJourney.getFlexibleServiceProperties(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java index f0aceba8..deba1556 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTimetableFrameTest.java @@ -115,21 +115,21 @@ void unmarshalTimetableFrame() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); - ServiceJourney serviceJourney = (ServiceJourney) timetableFrame.getVehicleJourneys().getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); + TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); + ServiceJourney serviceJourney = (ServiceJourney) timetableFrame.getVehicleJourneys().getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().getFirst(); assertEquals("96", getStringValue(serviceJourney.getName())); assertEquals("96", serviceJourney.getPrivateCode().getValue()); assertEquals("rail", serviceJourney.getTransportMode().value()); - TimetabledPassingTime timetabledPassingTime = serviceJourney.getPassingTimes().getTimetabledPassingTime().get(0); + TimetabledPassingTime timetabledPassingTime = serviceJourney.getPassingTimes().getTimetabledPassingTime().getFirst(); assertEquals(LocalTime.of(14,55), timetabledPassingTime.getDepartureTime()); DatedServiceJourney dsj = (DatedServiceJourney) timetableFrame.getVehicleJourneys().getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(1); assertEquals("VYG:OperatingDay:2023-12-09", dsj.getOperatingDayRef().getRef()); assertEquals("VYG:ServiceJourney:96-KMB_87815-R", dsj.getJourneyRef().getValue().getRef()); - assertEquals("VYG:DatedServiceJourney:8916_KVG-DEG_23-10-19", dsj.getReplacedJourneys().getDatedVehicleJourneyRefOrNormalDatedVehicleJourneyRef().get(0).getValue().getRef()); + assertEquals("VYG:DatedServiceJourney:8916_KVG-DEG_23-10-19", dsj.getReplacedJourneys().getDatedVehicleJourneyRefOrNormalDatedVehicleJourneyRef().getFirst().getValue().getRef()); assertEquals("cancellation", dsj.getServiceAlteration().value()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java index 2d70ac99..36329e37 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java @@ -74,9 +74,9 @@ void unmarshalStopPlaceWithBusSubmode() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - StopPlace busStop = siteFrame.getStopPlaces().getStopPlace().get(0); + StopPlace busStop = siteFrame.getStopPlaces().getStopPlace().getFirst(); assertEquals(AllPublicTransportModesEnumeration.BUS, busStop.getTransportMode()); assertEquals(BusSubmodeEnumeration.EXPRESS_BUS, busStop.getBusSubmode()); assertEquals("expressBus", busStop.getBusSubmode().value()); @@ -150,11 +150,11 @@ void unmarshalServiceJourneyWithTransportSubmode() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + TimetableFrame timetableFrame = (TimetableFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); ServiceJourney busSj = (ServiceJourney) timetableFrame.getVehicleJourneys() - .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().get(0); + .getVehicleJourneyOrDatedVehicleJourneyOrNormalDatedVehicleJourney().getFirst(); assertEquals(AllPublicTransportModesEnumeration.BUS, busSj.getTransportMode()); assertNotNull(busSj.getTransportSubmode()); assertEquals(BusSubmodeEnumeration.EXPRESS_BUS, busSj.getTransportSubmode().getBusSubmode()); @@ -211,10 +211,10 @@ void unmarshalRouteWithLineRef() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().get(0).getValue(); + Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().getFirst().getValue(); assertEquals("Main Route", getStringValue(route.getName())); assertNotNull(route.getLineRef()); assertEquals("TST:Line:100", route.getLineRef().getValue().getRef()); @@ -262,9 +262,9 @@ void unmarshalStopPlaceWithCoachFunicularAndTelecabinSubmodes() throws JAXBExcep .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - StopPlace coachStop = siteFrame.getStopPlaces().getStopPlace().get(0); + StopPlace coachStop = siteFrame.getStopPlaces().getStopPlace().getFirst(); assertEquals(AllPublicTransportModesEnumeration.COACH, coachStop.getTransportMode()); assertEquals(CoachSubmodeEnumeration.INTERNATIONAL_COACH, coachStop.getCoachSubmode()); assertEquals("internationalCoach", coachStop.getCoachSubmode().value()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java index 201cf3d8..4c0e9144 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalVehicleScheduleFrameChouetteTest.java @@ -76,13 +76,13 @@ void unmarshalBlockInVehicleScheduleFrame() throws JAXBException { .unmarshal(new ByteArrayInputStream(xml.getBytes())); PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); - CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); - VehicleScheduleFrame vsFrame = (VehicleScheduleFrame) compositeFrame.getFrames().getCommonFrame().get(0).getValue(); + CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); + VehicleScheduleFrame vsFrame = (VehicleScheduleFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); assertNotNull(vsFrame.getBlocks()); assertEquals(1, vsFrame.getBlocks().getBlockOrCompoundBlockOrTrainBlock().size()); - Block block = (Block) vsFrame.getBlocks().getBlockOrCompoundBlockOrTrainBlock().get(0); + Block block = (Block) vsFrame.getBlocks().getBlockOrCompoundBlockOrTrainBlock().getFirst(); assertEquals("Morning Block", getStringValue(block.getName())); assertEquals("First block of the day", getStringValue(block.getDescription())); assertEquals("BLK001", block.getPrivateCode().getValue()); @@ -93,12 +93,12 @@ void unmarshalBlockInVehicleScheduleFrame() throws JAXBException { assertEquals("TST:ScheduledStopPoint:Depot", block.getEndPointRef().getRef()); assertNotNull(block.getDayTypes()); - assertEquals("TST:DayType:Weekday", block.getDayTypes().getDayTypeRef().get(0).getValue().getRef()); + assertEquals("TST:DayType:Weekday", block.getDayTypes().getDayTypeRef().getFirst().getValue().getRef()); assertNotNull(block.getJourneys()); assertEquals(4, block.getJourneys().getJourneyRefOrJourneyDesignatorOrServiceDesignator().size()); - Object firstRef = block.getJourneys().getJourneyRefOrJourneyDesignatorOrServiceDesignator().get(0).getValue(); + Object firstRef = block.getJourneys().getJourneyRefOrJourneyDesignatorOrServiceDesignator().getFirst().getValue(); assertTrue(firstRef instanceof DeadRunRefStructure); assertEquals("TST:DeadRun:ToStart", ((DeadRunRefStructure) firstRef).getRef()); diff --git a/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java b/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java index 0878b707..ed025cf4 100644 --- a/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java +++ b/src/test/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapterTest.java @@ -141,7 +141,7 @@ void testCachingIdenticalValue() { var parsed = equalInputs.stream() .map(adapter::unmarshal) .toList(); - var first = parsed.get(0); + var first = parsed.getFirst(); parsed.forEach(time -> assertSame(first, time, "Same time value should return same instance")); } From 918e526f2f4c8795a71e42060e50cb382d79c174 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Wed, 14 Oct 2026 11:33:47 +0200 Subject: [PATCH 27/27] Hide the _Dummy suffix of the NeTEx 2.0 substitution-group heads NeTEx 2.0 names its abstract substitution-group heads with a _Dummy suffix (DayType_Dummy is the head of DayType), where 1.x used a trailing underscore. xjc leaked the suffix into the generated API as getDayType_Dummy(), getDayTypeRefOrDayType_Dummy(), createDayType_Dummy() and classes such as MediumAccessDevice_Dummy. Add bin/generate-dummy-bindings.py, which derives one JAXB binding per leak from the schema and writes them into a marked block of bindings.xjb: properties drop the suffix (getDayType(), getDayTypeRefOrDayType()), while factory methods and the few classes generated for heads keep a trailing underscore as in netex-java-model 2.x (createDayType_(), MediumAccessDevice_), since dropping it there collides with the factory method of the concrete element. The hand-written TariffZone binding is covered by the generated block. Tests and docs are updated accordingly. --- CLAUDE.md | 1 + README.md | 2 + bin/generate-dummy-bindings.py | 204 ++++++ bindings.xjb | 654 +++++++++++++++++- .../netex2/model/MarshalUnmarshalTest.java | 4 +- .../UnmarshalResourceFrameExtendedTest.java | 4 +- .../model/UnmarshalResourceFrameTest.java | 2 +- .../UnmarshalServiceCalendarFrameTest.java | 2 +- .../UnmarshalServiceFrameChouetteTest.java | 6 +- .../UnmarshalServiceFrameExtendedTest.java | 4 +- .../model/UnmarshalServiceFrameTest.java | 6 +- .../model/UnmarshalSiteFrameExtendedTest.java | 2 +- .../netex2/model/UnmarshalSiteFrameTest.java | 2 +- .../model/UnmarshalTransportSubModeTest.java | 2 +- 14 files changed, 871 insertions(+), 24 deletions(-) create mode 100755 bin/generate-dummy-bindings.py diff --git a/CLAUDE.md b/CLAUDE.md index 1a2f343e..9b84ddfe 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -52,6 +52,7 @@ mvn validate - Java 8 time type adapters (`LocalDateTime`, `LocalDate`, `LocalTime`, `Duration`) - Property name conflict resolution - Package naming (`org.entur.netex2.model`) + - A generated block (between `BEGIN/END generated _Dummy bindings` markers) that hides the `_Dummy` suffix of the abstract substitution-group heads: `getDayType()` instead of `getDayType_Dummy()`, `createDayType_(...)` in `ObjectFactory`. Do not edit the block by hand; rerun `bin/generate-dummy-bindings.py src/main/resources/xsd//NeTEx_publication.xsd bindings.xjb` after a schema upgrade. - **Generated Code**: Model classes are generated in `target/generated-sources/` during build. Do not manually edit generated code. diff --git a/README.md b/README.md index b9b5f999..0265b86e 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ The XSD files are downloaded from GitHub during the `generate-sources` phase and ├── bin/ │ ├── netex-download-extract.sh # Downloads NeTEx XSD from GitHub │ ├── annotation-replacer.sh # Post-processes generated Java files +│ ├── generate-dummy-bindings.py # Regenerates the bindings hiding the _Dummy suffix │ └── version_updater.sh # Updates version references in bindings ├── bindings.xjb # JAXB customization bindings ├── src/main/java/org/entur/ @@ -104,6 +105,7 @@ The XSD files are downloaded from GitHub during the `generate-sources` phase and - Fluent builder API (`withX()` methods) via `jaxb-fluent-api` - Property name conflict resolution - Package mapping to `org.entur.netex2.model` +- Hiding of the `_Dummy` suffix that NeTEx 2.0 puts on abstract substitution-group heads (`DayType_Dummy` is the head of `DayType`): containers expose `getDayType()` instead of `getDayType_Dummy()`, `ObjectFactory` exposes `createDayType_(...)` and the few classes generated for such heads keep a trailing underscore, as in `netex-java-model` 2.x. These bindings are generated by `bin/generate-dummy-bindings.py` and must be regenerated when the schema is upgraded. **Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.04beta through 2.0. A version is validated against its latest patch schema: documents declaring 1.16 are validated against the 1.16.1 schema, which is backward compatible with 1.16. diff --git a/bin/generate-dummy-bindings.py b/bin/generate-dummy-bindings.py new file mode 100755 index 00000000..89f84a0a --- /dev/null +++ b/bin/generate-dummy-bindings.py @@ -0,0 +1,204 @@ +#!/usr/bin/env python3 +""" +Generate the JAXB bindings that hide the NeTEx "_Dummy" naming convention. + +NeTEx 2.0 declares the abstract substitution-group heads with a "_Dummy" suffix +(for example DayType_Dummy, head of DayType). Without customisation, xjc leaks the +suffix into the generated API: getDayType_Dummy(), getDayTypeRefOrDayType_Dummy(), +createDayType_Dummy(...) and classes such as MediumAccessDevice_Dummy. + +This script walks the schema files and emits one binding per leak: + + * a property rename for every element referencing a _Dummy head + (getDayType_Dummy() -> getDayType()); when the reference sits in a repeated + model group, the group itself is renamed (getDayTypeRefOrDayType()) + * a factory-method rename for every _Dummy element declaration + (createDayType_Dummy(...) -> createDayType_(...)); dropping the suffix entirely + would collide with the factory method of the concrete element + * a class rename for the _Dummy elements with an inline type and for the + _Dummy complex types (MediumAccessDevice_Dummy -> MediumAccessDevice_) + +The generated block is written into the bindings file between the BEGIN/END +markers below (and appended before the closing tag if the markers are absent). +Re-run it after upgrading the NeTEx schema: + + bin/generate-dummy-bindings.py src/main/resources/xsd/2.0/NeTEx_publication.xsd bindings.xjb + +Only the schema files reachable from the entry point through xsd:include and +xsd:import are visited; xjc rejects bindings for files outside the compilation. +""" + +import pathlib +import sys +import xml.etree.ElementTree as ET + +XS = "http://www.w3.org/2001/XMLSchema" +SUFFIX = "_Dummy" +BEGIN = "" +END = "" +PARTICLES = {"element", "group", "choice", "sequence", "all", "any"} +MODEL_GROUPS = {"choice", "sequence", "all"} + + +def tag(node): + return node.tag.split("}")[1] + + +def is_particle(node): + return tag(node) in PARTICLES + + +def repeated(node): + max_occurs = node.get("maxOccurs", "1") + return max_occurs == "unbounded" or int(max_occurs) > 1 + + +def lower_first(name): + return name[0].lower() + name[1:] + + +def label(node): + """Mirror xjc's ParticleBinder.computeLabel for the default property name.""" + kind = tag(node) + if kind == "element": + return node.get("name") or node.get("ref") + if kind == "group": + return node.get("ref") + if kind == "any": + return "any" + # xjc only uses the first three particles of a model group for its name. + return "Or".join(label(c) for c in [c for c in node if is_particle(c)][:3]) + + +def xpath_step(node, parent): + """One XPath step, with a positional predicate only when siblings share the tag.""" + siblings = [c for c in parent if c.tag == node.tag] + step = "xsd:" + tag(node) + if len(siblings) > 1: + step += "[%d]" % (siblings.index(node) + 1) + return step + + +def xpath(node, parents, schema): + """Absolute path from the named top-level component down to node.""" + chain = [] + current = node + while parents[current] is not schema: + chain.append(current) + current = parents[current] + top = current + if top.get("name") is None: + raise SystemExit("top-level component without a name: %s" % top.tag) + path = "//xsd:%s[@name = '%s']" % (tag(top), top.get("name")) + for n in reversed(chain): + path += "/" + xpath_step(n, parents[n]) + return path + + +def property_target(ref_element, parents): + """The node xjc binds to a property for this reference: the outermost repeated + model group containing it, or the element itself when there is none.""" + target = ref_element + current = parents[ref_element] + while tag(current) in MODEL_GROUPS: + if repeated(current): + target = current + current = parents[current] + return target + + +def process_schema(xsd_path): + schema = ET.parse(xsd_path).getroot() + parents = {c: p for p in schema.iter() for c in p} + properties = [] # (xpath, new name, old name) + factories = [] # (element name, new name) + classes = [] # (xpath, new name) + for node in schema.iter(): + kind = tag(node) + if kind == "element" and (node.get("ref") or "").endswith(SUFFIX): + target = property_target(node, parents) + old = lower_first(label(target)) + new = old.replace(SUFFIX, "") + properties.append((xpath(target, parents, schema), new, old)) + elif kind == "element" and (node.get("name") or "").endswith(SUFFIX) and parents[node] is schema: + name = node.get("name") + bare = name[: -len(SUFFIX)] + if any(tag(c) == "complexType" for c in node): + classes.append((xpath(node, parents, schema), bare + "_")) + else: + factories.append((name, bare + "_")) + elif kind == "complexType" and (node.get("name") or "").endswith(SUFFIX) and parents[node] is schema: + bare = node.get("name")[: -len(SUFFIX)] + classes.append((xpath(node, parents, schema), bare + "_")) + # The same repeated group is reached once per _Dummy reference it contains. + properties = list(dict.fromkeys(properties)) + return properties, factories, classes + + +def reachable_schemas(entry): + """All schema files included or imported, directly or not, from the entry point.""" + seen = set() + todo = [entry] + while todo: + path = todo.pop().resolve() + if path in seen: + continue + seen.add(path) + for node in ET.parse(path).getroot(): + if tag(node) in ("include", "import") and node.get("schemaLocation"): + todo.append(path.parent / node.get("schemaLocation")) + return sorted(seen) + + +def render(entry, bindings_path): + lines = ["\t" + BEGIN] + old_names = [] + for xsd_path in reachable_schemas(entry): + properties, factories, classes = process_schema(xsd_path) + if not (properties or factories or classes): + continue + location = "./" + xsd_path.relative_to(bindings_path.parent).as_posix() + lines.append('\t' % location) + for path, new, old in properties: + old_names.append(old) + lines.append('\t\t' % path) + lines.append('\t\t\t' % new) + lines.append("\t\t") + for name, new in factories: + lines.append("\t\t" % name) + lines.append('\t\t\t' % new) + lines.append("\t\t") + for path, new in classes: + lines.append('\t\t' % path) + lines.append('\t\t\t' % new) + lines.append("\t\t") + lines.append("\t") + lines.append("\t" + END) + return "\n".join(lines) + "\n", old_names + + +def splice(bindings_path, block): + text = bindings_path.read_text() + begin = text.find("\t" + BEGIN) + end = text.find(END) + if begin >= 0 and end >= 0: + end = text.index("\n", end) + 1 + return text[:begin] + block + text[end:] + closing = text.rstrip().rfind("") + return text[:closing].rstrip() + "\n\n" + block + "\n\n" + + +def main(): + if len(sys.argv) != 3: + raise SystemExit("usage: generate-dummy-bindings.py ") + entry = pathlib.Path(sys.argv[1]).resolve() + bindings_path = pathlib.Path(sys.argv[2]).resolve() + block, old_names = render(entry, bindings_path) + bindings_path.write_text(splice(bindings_path, block)) + # Printed so the result can be checked against the names xjc generated before. + for name in old_names: + print(name) + + +if __name__ == "__main__": + main() diff --git a/bindings.xjb b/bindings.xjb index a8abb727..b813c6e8 100644 --- a/bindings.xjb +++ b/bindings.xjb @@ -63,13 +63,6 @@ - - - - - - @@ -102,5 +95,652 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java b/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java index 6594d1d4..9ab0ce01 100644 --- a/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java +++ b/src/test/java/org/entur/netex2/model/MarshalUnmarshalTest.java @@ -274,12 +274,12 @@ void unmarshalPublicationDeliveryAndVerifyValidBetween() throws JAXBException, I CompositeFrame compositeFrame = (CompositeFrame) actual.dataObjects.compositeFrameOrCommonFrame .getFirst().getValue(); ValidityConditions_RelStructure validityConditions = compositeFrame.getValidityConditions(); - ValidBetween validBetweenWithTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_Dummy().getFirst(); + ValidBetween validBetweenWithTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition().getFirst(); assertThat(validBetweenWithTimezone.getFromDate()).isNotNull(); assertThat(validBetweenWithTimezone.getToDate()).isNotNull(); assertThat(validBetweenWithTimezone.getToDate()).hasToString("2017-01-01T11:00"); - ValidBetween validBetweenWithoutTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition_Dummy().get(1); + ValidBetween validBetweenWithoutTimezone = (ValidBetween) validityConditions.getValidityConditionRefOrValidBetweenOrValidityCondition().get(1); assertThat(validBetweenWithoutTimezone.getFromDate()).isNotNull(); assertThat(validBetweenWithoutTimezone.getToDate()).isNotNull(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java index 3c6fd193..15b0e6ba 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameExtendedTest.java @@ -65,7 +65,7 @@ void unmarshalAuthorityWithContactDetails() throws JAXBException { ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_Dummy().getFirst().getValue(); + Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation().getFirst().getValue(); assertEquals("Test Authority", getStringValue(authority.getName())); assertEquals("+47 99887766", authority.getContactDetails().getPhone()); assertEquals("https://www.testauthority.no", authority.getContactDetails().getUrl()); @@ -118,7 +118,7 @@ void unmarshalOperatorWithBrandingRef() throws JAXBException { assertEquals("https://www.testbrand.no", branding.getUrl()); assertEquals("https://www.testbrand.no/logo.png", branding.getImage()); - Operator operator = (Operator) resourceFrame.getOrganisations().getOrganisation_Dummy().getFirst().getValue(); + Operator operator = (Operator) resourceFrame.getOrganisations().getOrganisation().getFirst().getValue(); assertEquals("Test Operator", getStringValue(operator.getName())); assertNotNull(operator.getBrandingRef()); assertEquals("TST:Branding:1", operator.getBrandingRef().getRef()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java index c80c50de..c3e4a21b 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalResourceFrameTest.java @@ -111,7 +111,7 @@ void unmarshalResourceFrame() throws JAXBException { CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); ResourceFrame resourceFrame = (ResourceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation_Dummy().getFirst().getValue(); + Authority authority = (Authority) resourceFrame.getOrganisations().getOrganisation().getFirst().getValue(); assertEquals("Vy", getStringValue(authority.getName())); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java index d94c9528..279380b4 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceCalendarFrameTest.java @@ -129,7 +129,7 @@ void unmarshalServiceCalendarFrame() throws JAXBException { ServiceCalendarFrame serviceCalendarFrame = (ServiceCalendarFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - DayType dayType = (DayType) serviceCalendarFrame.getDayTypes().getDayType_Dummy().getFirst().getValue(); + DayType dayType = (DayType) serviceCalendarFrame.getDayTypes().getDayType().getFirst().getValue(); assertEquals(DayOfWeekEnumeration.TUESDAY, dayType.getProperties().getPropertyOfDay().getFirst().getDaysOfWeek().getFirst()); OperatingDay operatingDay = serviceCalendarFrame.getOperatingDays().getOperatingDay().getFirst(); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java index a9fe9199..38c8df21 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameChouetteTest.java @@ -78,7 +78,7 @@ void unmarshalBookingArrangementsOnStopPointInJourneyPattern() throws JAXBExcept CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_Dummy().getFirst().getValue(); + JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern().getFirst().getValue(); StopPointInJourneyPattern stopPoint = (StopPointInJourneyPattern) journeyPattern.getPointsInSequence() .getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern().getFirst(); @@ -208,7 +208,7 @@ void unmarshalDirectionAndRouteDirectionType() throws JAXBException { Direction inbound = serviceFrame.getDirections().getDirection().get(1); assertEquals(DirectionTypeEnumeration.INBOUND, inbound.getDirectionType()); - Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().getFirst().getValue(); + Route route = (Route) serviceFrame.getRoutes().getRoute().getFirst().getValue(); assertEquals(DirectionTypeEnumeration.OUTBOUND, route.getDirectionType()); assertEquals("TST:Direction:Outbound", route.getDirectionRef().getRef()); assertEquals("TST:Route:2", route.getInverseRouteRef().getRef()); @@ -345,7 +345,7 @@ void unmarshalLinePresentationAndPrivateCode() throws JAXBException { CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Line line = (Line) serviceFrame.getLines().getLine_Dummy().getFirst().getValue(); + Line line = (Line) serviceFrame.getLines().getLine().getFirst().getValue(); assertEquals("Line One", getStringValue(line.getName())); assertEquals("PRIV001", line.getPrivateCode().getValue()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java index ee1607e9..9946c760 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameExtendedTest.java @@ -206,7 +206,7 @@ void unmarshalFlexibleLineAndGroupOfLines() throws JAXBException { ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - FlexibleLine flexibleLine = (FlexibleLine) serviceFrame.getLines().getLine_Dummy().getFirst().getValue(); + FlexibleLine flexibleLine = (FlexibleLine) serviceFrame.getLines().getLine().getFirst().getValue(); assertEquals("Flex Route 1", getStringValue(flexibleLine.getName())); assertEquals(AllPublicTransportModesEnumeration.BUS, flexibleLine.getTransportMode()); assertEquals(FlexibleLineTypeEnumeration.FLEXIBLE_AREAS_ONLY, flexibleLine.getFlexibleLineType()); @@ -264,7 +264,7 @@ void unmarshalNoticeAndNoticeAssignment() throws JAXBException { assertEquals("Does not stop at all stops", getStringValue(notice.getText())); assertEquals("A", notice.getPublicCode().getValue()); - NoticeAssignment noticeAssignment = (NoticeAssignment) serviceFrame.getNoticeAssignments().getNoticeAssignment_Dummy().getFirst().getValue(); + NoticeAssignment noticeAssignment = (NoticeAssignment) serviceFrame.getNoticeAssignments().getNoticeAssignment().getFirst().getValue(); assertEquals("TST:Notice:1", noticeAssignment.getNoticeRef().getRef()); assertEquals("TST:ServiceJourney:1", noticeAssignment.getNoticedObjectRef().getRef()); } diff --git a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java index ab509b65..0992b7c1 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalServiceFrameTest.java @@ -147,20 +147,20 @@ void unmarshalServiceFrame() throws JAXBException { CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Line line = (Line) serviceFrame.getLines().getLine_Dummy().getFirst().getValue(); + Line line = (Line) serviceFrame.getLines().getLine().getFirst().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_Dummy().getFirst().getValue(); + Route route = (Route) serviceFrame.getRoutes().getRoute().getFirst().getValue(); assertEquals("Riksgränsen-Narvik Ofotbanen", getStringValue(route.getName())); assertEquals("KJ-NK", getStringValue(route.getShortName())); PointOnRoute pointOnRoute = route.getPointsInSequence().getPointOnRoute().getFirst(); assertEquals("VYG:RoutePoint:KJ", pointOnRoute.getPointRef().getValue().getRef()); - JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern_Dummy().getFirst().getValue(); + JourneyPattern journeyPattern = (JourneyPattern) serviceFrame.getJourneyPatterns().getJourneyPattern().getFirst().getValue(); assertEquals("KMB-NK", getStringValue(journeyPattern.getName())); assertEquals("VYG:Route:F8-R", journeyPattern.getRouteRef().getRef()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java index 23f84de0..c5abef1c 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameExtendedTest.java @@ -139,7 +139,7 @@ void unmarshalParking() throws JAXBException { PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); - Parking parking = (Parking) siteFrame.getParkings().getParking_Dummy().getFirst().getValue(); + Parking parking = (Parking) siteFrame.getParkings().getParking().getFirst().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/entur/netex2/model/UnmarshalSiteFrameTest.java b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java index bd4817c9..64303f7c 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalSiteFrameTest.java @@ -126,7 +126,7 @@ void unmarshalSiteFrame() throws JAXBException { assertEquals("Krokstien", getStringValue(stopPlace.getName())); assertEquals(AllPublicTransportModesEnumeration.BUS, stopPlace.getTransportMode()); assertEquals(StopTypeEnumeration.ONSTREET_BUS, stopPlace.getStopPlaceType()); - assertEquals("BRA:TariffZone:311", stopPlace.getTariffZones().getTariffZoneRef_Dummy().getFirst().getValue().getRef()); + assertEquals("BRA:TariffZone:311", stopPlace.getTariffZones().getTariffZoneRef().getFirst().getValue().getRef()); Quay quay = (Quay) stopPlace.getQuays().getQuayRefOrQuay().getFirst().getValue(); assertEquals(BigDecimal.valueOf(59.910579), quay.getCentroid().getLocation().getLatitude()); diff --git a/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java b/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java index 36329e37..88ace847 100644 --- a/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java +++ b/src/test/java/org/entur/netex2/model/UnmarshalTransportSubModeTest.java @@ -214,7 +214,7 @@ void unmarshalRouteWithLineRef() throws JAXBException { CompositeFrame compositeFrame = (CompositeFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().getFirst().getValue(); ServiceFrame serviceFrame = (ServiceFrame) compositeFrame.getFrames().getCommonFrame().getFirst().getValue(); - Route route = (Route) serviceFrame.getRoutes().getRoute_Dummy().getFirst().getValue(); + Route route = (Route) serviceFrame.getRoutes().getRoute().getFirst().getValue(); assertEquals("Main Route", getStringValue(route.getName())); assertNotNull(route.getLineRef()); assertEquals("TST:Line:100", route.getLineRef().getValue().getRef());