use of org.rutebanken.netex.model.SimplePoint_VersionStructure in project tiamat by entur.
the class ImportResourceTest method publicationDeliveriesWithBusStationStopAndOnStreetBus.
@Test
public void publicationDeliveriesWithBusStationStopAndOnStreetBus() throws Exception {
StopPlace stopPlace = new StopPlace().withId("RUT:StopPlace:123123").withStopPlaceType(StopTypeEnumeration.BUS_STATION).withVersion("1").withName(new MultilingualString().withValue("somewhere")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71"))));
StopPlace stopPlace2 = new StopPlace().withId("RUT:StopPlace:987654321").withVersion("1").withStopPlaceType(StopTypeEnumeration.ONSTREET_BUS).withName(new MultilingualString().withValue("somewhere")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71"))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
PublicationDeliveryStructure publicationDelivery2 = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace2);
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery2);
List<StopPlace> result = publicationDeliveryTestHelper.extractStopPlaces(response);
assertThat(result).as("Expecting one stop place in return, as stops imported has onstreet bus and bus station as type").hasSize(1);
publicationDeliveryTestHelper.hasOriginalId("RUT:StopPlace:123123", result.get(0));
publicationDeliveryTestHelper.hasOriginalId("RUT:StopPlace:987654321", result.get(0));
}
use of org.rutebanken.netex.model.SimplePoint_VersionStructure in project tiamat by entur.
the class ImportResourceTest method importPublicationDeliveryAndExpectMappedIdInReturn.
@Test
public void importPublicationDeliveryAndExpectMappedIdInReturn() throws Exception {
String originalQuayId = "XYZ:Quay:321321";
StopPlace stopPlace = new StopPlace().withId("XYZ:StopPlace:123123").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71")))).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withId(originalQuayId).withVersion("1").withName(new MultilingualString().withValue("quay")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9.1")).withLongitude(new BigDecimal("71.2"))))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
PublicationDeliveryStructure firstResponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
StopPlace actualStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(firstResponse);
publicationDeliveryTestHelper.hasOriginalId(stopPlace.getId(), actualStopPlace);
Quay quay = actualStopPlace.getQuays().getQuayRefOrQuay().stream().peek(object -> System.out.println(object)).filter(object -> object instanceof Quay).map(object -> ((Quay) object)).peek(q -> System.out.println(q)).findFirst().get();
publicationDeliveryTestHelper.hasOriginalId(originalQuayId, quay);
}
use of org.rutebanken.netex.model.SimplePoint_VersionStructure in project tiamat by entur.
the class ImportResourceTest method publicationDeliveryWithStopPlaceAndQuay.
@Test
public void publicationDeliveryWithStopPlaceAndQuay() throws Exception {
StopPlace stopPlace = new StopPlace().withId("NSR:StopPlace:123123").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71")))).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withId("XYZ:Quay:4").withVersion("1").withPrivateCode(new PrivateCodeStructure().withValue("B02").withType("type")).withName(new MultilingualString().withValue("quay")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9.1")).withLongitude(new BigDecimal("71.2"))))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
PublicationDeliveryStructure firstResponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
StopPlace actualStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(firstResponse);
assertThat(actualStopPlace.getQuays()).isNotNull().as("quays should not be null");
Quay quay = actualStopPlace.getQuays().getQuayRefOrQuay().stream().filter(object -> object instanceof Quay).map(object -> ((Quay) object)).findFirst().get();
assertThat(quay.getName().getValue()).isEqualTo("quay");
assertThat(quay.getId()).isNotNull();
assertThat(quay.getPrivateCode().getValue()).isEqualTo("B02");
assertThat(quay.getPrivateCode().getType()).isEqualTo("type");
}
use of org.rutebanken.netex.model.SimplePoint_VersionStructure in project tiamat by entur.
the class ImportResourceTest method allowOtherWhenMatchingExistingStopPlacesWithImportTypeMATCH.
@Test
public void allowOtherWhenMatchingExistingStopPlacesWithImportTypeMATCH() throws Exception {
StopPlace stopPlaceToBeMatched = new StopPlace().withId("RUT:StopPlace:987978").withStopPlaceType(StopTypeEnumeration.BUS_STATION).withVersion("1").withName(new MultilingualString().withValue("somewhere")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71"))));
StopPlace incomingStopPlace = new StopPlace().withId("RUT:StopPlace:123546789").withVersion("1").withStopPlaceType(StopTypeEnumeration.OTHER).withName(new MultilingualString().withValue("somewhere")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71"))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlaceToBeMatched);
publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
PublicationDeliveryStructure publicationDelivery2 = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(incomingStopPlace);
ImportParams importParams = new ImportParams();
importParams.importType = ImportType.MATCH;
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery2, importParams);
List<StopPlace> result = publicationDeliveryTestHelper.extractStopPlaces(response);
assertThat(result).as("Expecting one stop place in return, as stops imported has onstreet bus and bus station as type").hasSize(1);
publicationDeliveryTestHelper.hasOriginalId(stopPlaceToBeMatched.getId(), result.get(0));
publicationDeliveryTestHelper.hasOriginalId(incomingStopPlace.getId(), result.get(0));
}
use of org.rutebanken.netex.model.SimplePoint_VersionStructure in project tiamat by entur.
the class ImportResourceTest method publicationDeliveryWithDuplicateStopPlaceWithDifferentId.
/**
* Real life example: Two stops with different IDs should be merged into one, and their quays should be added.
*
* @throws Exception
*/
@Test
public void publicationDeliveryWithDuplicateStopPlaceWithDifferentId() throws Exception {
String name = "Varnaveien bensin";
StopPlace stopPlace = new StopPlace().withName(new MultilingualString().withValue(name)).withId("OST:StopArea:01360680").withVersion("1").withStopPlaceType(StopTypeEnumeration.ONSTREET_BUS).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("59.4172358106178")).withLongitude(new BigDecimal("10.66847409589632")))).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withId("OST:StopArea:0136068001").withVersion("1").withName(new MultilingualString().withValue(name)).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLongitude(new BigDecimal("10.6684740958963200085918288095854222774505615234375")).withLatitude(new BigDecimal("59.41723581061779668743838556110858917236328125"))))));
StopPlace stopPlace2 = new StopPlace().withName(new MultilingualString().withValue(name)).withId("OST:StopArea:01040720").withVersion("1").withStopPlaceType(StopTypeEnumeration.ONSTREET_BUS).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("59.41727956639375")).withLongitude(new BigDecimal("10.66866436373097")))).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withId("OST:StopArea:0104072001").withVersion("1").withName(new MultilingualString().withValue(name)).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLongitude(new BigDecimal("10.6686643637309706122096031322143971920013427734375")).withLatitude(new BigDecimal("59.41727956639375207714692805893719196319580078125"))))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace, stopPlace2);
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
List<StopPlace> result = publicationDeliveryTestHelper.extractStopPlaces(response);
assertThat(result).as("Expecting one stop place in return, as there is no need to return the same matching stop place twice").hasSize(1);
String importedIds = result.get(0).getKeyList().getKeyValue().stream().filter(kv -> "imported-id".equals(kv.getKey())).map(KeyValueStructure::getValue).findFirst().get();
assertThat(importedIds).contains(stopPlace.getId());
assertThat(importedIds).contains(stopPlace2.getId());
assertThat(result.get(0).getQuays().getQuayRefOrQuay()).hasSize(2);
}
Aggregations