Search in sources :

Example 1 with TransferDurationStructure

use of org.rutebanken.netex.model.TransferDurationStructure in project tiamat by entur.

the class PathLinkImportTest method publicationDeliveryWithPathLink.

@Test
public void publicationDeliveryWithPathLink() throws Exception {
    StopPlace fromStopPlace = new StopPlace().withId("RUT:StopPlace:123123").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71"))));
    StopPlace toStopPlace = new StopPlace().withId("RUT:StopPlace:321654").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9.6")).withLongitude(new BigDecimal("76"))));
    LineStringType lineStringType = new LineStringType().withId("LineString").withPosList(new DirectPositionListType().withSrsDimension(BigInteger.valueOf(new GeometryFactoryConfig().geometryFactory().getSRID())).withValue(9.1, 71.1, 9.5, 74.1));
    Duration duration = Duration.ofMillis(10000);
    PathLink netexPathLink = new PathLink().withId("NRI:ConnectionLink:762130479_762130479").withVersion("1").withAllowedUse(PathDirectionEnumeration.TWO_WAY).withTransferDuration(new TransferDurationStructure().withDefaultDuration(duration)).withLineString(lineStringType).withFrom(new PathLinkEndStructure().withPlaceRef(new PlaceRefStructure().withRef(fromStopPlace.getId()))).withTo(new PathLinkEndStructure().withPlaceRef(new PlaceRefStructure().withRef(toStopPlace.getId()).withVersion("1")));
    PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(fromStopPlace, toStopPlace);
    publicationDeliveryTestHelper.addPathLinks(publicationDelivery, netexPathLink);
    PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
    List<PathLink> result = publicationDeliveryTestHelper.extractPathLinks(response);
    assertThat(result).as("Expecting path link in return").hasSize(1);
    PathLink importedPathLink = result.get(0);
    assertThat(importedPathLink.getAllowedUse()).isEqualTo(netexPathLink.getAllowedUse());
    assertThat(importedPathLink.getFrom().getPlaceRef().getRef()).contains(fromStopPlace.getClass().getSimpleName());
    assertThat(importedPathLink.getTo().getPlaceRef().getRef()).contains(toStopPlace.getClass().getSimpleName());
    assertThat(importedPathLink.getTransferDuration().getDefaultDuration()).isEqualTo(duration);
    assertThat(importedPathLink.getLineString()).isNotNull();
    assertThat(importedPathLink.getLineString().getPosList()).isNotNull();
    assertThat(importedPathLink.getLineString().getPosList().getValue()).hasSize(4);
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) DirectPositionListType(net.opengis.gml._3.DirectPositionListType) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) Duration(java.time.Duration) PlaceRefStructure(org.rutebanken.netex.model.PlaceRefStructure) LineStringType(net.opengis.gml._3.LineStringType) TransferDurationStructure(org.rutebanken.netex.model.TransferDurationStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) GeometryFactoryConfig(org.rutebanken.tiamat.config.GeometryFactoryConfig) PathLink(org.rutebanken.netex.model.PathLink) PathLinkEndStructure(org.rutebanken.netex.model.PathLinkEndStructure) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Aggregations

BigDecimal (java.math.BigDecimal)1 Duration (java.time.Duration)1 DirectPositionListType (net.opengis.gml._3.DirectPositionListType)1 LineStringType (net.opengis.gml._3.LineStringType)1 Test (org.junit.Test)1 LocationStructure (org.rutebanken.netex.model.LocationStructure)1 PathLink (org.rutebanken.netex.model.PathLink)1 PathLinkEndStructure (org.rutebanken.netex.model.PathLinkEndStructure)1 PlaceRefStructure (org.rutebanken.netex.model.PlaceRefStructure)1 PublicationDeliveryStructure (org.rutebanken.netex.model.PublicationDeliveryStructure)1 SimplePoint_VersionStructure (org.rutebanken.netex.model.SimplePoint_VersionStructure)1 StopPlace (org.rutebanken.netex.model.StopPlace)1 TransferDurationStructure (org.rutebanken.netex.model.TransferDurationStructure)1 TiamatIntegrationTest (org.rutebanken.tiamat.TiamatIntegrationTest)1 GeometryFactoryConfig (org.rutebanken.tiamat.config.GeometryFactoryConfig)1