Skip to content

Commit

Permalink
Merge branch 'entur:TIS-938/road_geometry_in_export' into TIS-938/roa…
Browse files Browse the repository at this point in the history
…d_geometry_in_export
  • Loading branch information
solita-sabinaf authored Dec 11, 2024
2 parents 56f4eba + 46ad6a7 commit 5494a67
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.rutebanken.netex.model.EntityInVersionStructure;
import org.rutebanken.netex.model.EntityStructure;
import org.rutebanken.netex.model.VersionOfObjectRefStructure;
import org.rutebanken.netex.model.VersionedChildStructure;

public class NetexIdProducer {

Expand All @@ -42,7 +43,7 @@ public static Ref replaceEntityName(Ref ref, String newEntityName) {
public static <N extends EntityInVersionStructure> String getId(N netex, Ref ref) {
return getId(
NetexIdProducer.getObjectIdPrefix(ref.id),
netex.getClass().getSimpleName(),
getEntityName(netex),
NetexIdProducer.getObjectIdSuffix(ref.id)
);
}
Expand Down Expand Up @@ -123,6 +124,10 @@ public static <E> String getEntityName(E entity) {
if (localPart.endsWith("Structure")) {
localPart = localPart.substring(0, localPart.lastIndexOf("Structure"));
}
} else if (entity instanceof VersionedChildStructure) {
if (localPart.endsWith("VersionedChildStructure")) {
localPart = localPart.substring(0, localPart.lastIndexOf("_VersionedChildStructure"));
}
}
return localPart;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package no.entur.uttu.export.netex.producer;

import no.entur.uttu.config.ExportTimeZone;
import no.entur.uttu.model.Ref;
import no.entur.uttu.util.DateUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.rutebanken.netex.model.ServiceLinkInJourneyPattern_VersionedChildStructure;

public class NetexObjectFactoryTest {

@Test
void populateIdReturnsValidIdForVersionedChildStructureElements() {
NetexObjectFactory factory = new NetexObjectFactory(
new DateUtils(),
new ExportTimeZone()
);

Assertions.assertEquals(
"ENT:ServiceLinkInJourneyPattern:1",
factory.populateId(
new ServiceLinkInJourneyPattern_VersionedChildStructure(),
new Ref("ENT:ServiceLink:1", "1")
).getId()
);
}
}

0 comments on commit 5494a67

Please sign in to comment.