use of org.rutebanken.netex.model.PlaceRefStructure 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);
}
Aggregations