use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.
the class ImportResourceTest method publicationDeliveriesWithDuplicateStopPlace.
/**
* When sending a stop place with the same ID twice, the same stop place must be returned.
* When importing multiple stop places and those exists, make sure no Lazy Initialization Exception is thrown.
*/
@Test
public void publicationDeliveriesWithDuplicateStopPlace() throws Exception {
StopPlace stopPlace = new StopPlace().withId("RUT:StopPlace:123123").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71"))));
StopPlace stopPlace2 = new StopPlace().withId("RUT:StopPlace:123123").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("10")).withLongitude(new BigDecimal("72"))));
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 there is no need to return duplicates").hasSize(1);
}
use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.
the class ImportResourceTest method computeStopPlaceCentroid.
@Test
public void computeStopPlaceCentroid() throws Exception {
StopPlace stopPlace = new StopPlace().withId("XYZ:StopPlace:9").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("1")).withLongitude(new BigDecimal("2")))).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withId("XYZ:Quay:9").withVersion("1").withName(new MultilingualString().withValue("quay number one")).withCentroid(new SimplePoint_VersionStructure().withId("12").withVersion("1").withLocation(new LocationStructure().withLatitude(new BigDecimal("10")).withLongitude(new BigDecimal("20")))), new Quay().withId("XYZ:Quay:133").withVersion("1").withName(new MultilingualString().withValue("quay number two")).withCentroid(new SimplePoint_VersionStructure().withId("30").withVersion("1").withLocation(new LocationStructure().withLatitude(new BigDecimal("10.0002")).withLongitude(new BigDecimal("20.0002"))))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
PublicationDeliveryStructure firstResponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
StopPlace actualStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(firstResponse);
assertThat(actualStopPlace.getCentroid().getLocation().getLongitude().doubleValue()).isEqualTo(20.0001);
assertThat(actualStopPlace.getCentroid().getLocation().getLatitude().doubleValue()).isEqualTo(10.0001);
}
use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.
the class ImportResourceTest method importStopPlaceWithMultipleValidBetweenPeriodsIgnoresAllButFirst.
@Test
public void importStopPlaceWithMultipleValidBetweenPeriodsIgnoresAllButFirst() throws Exception {
LocalDateTime firstValidFrom = now.plusSeconds(1);
LocalDateTime secondValidFrom = now.plusSeconds(2);
StopPlace stopPlace1 = new StopPlace().withId("XYZ:Stopplace:1").withVersion("1").withName(new MultilingualString().withValue("New stop1")).withValidBetween(new ValidBetween().withFromDate(firstValidFrom).withToDate(secondValidFrom), new ValidBetween().withFromDate(secondValidFrom)).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("59.914353")).withLongitude(new BigDecimal("10.806387"))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace1);
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
List<StopPlace> changedStopPlaces = publicationDeliveryTestHelper.extractStopPlaces(response);
Assert.assertEquals(1, changedStopPlaces.size());
StopPlace stopPlace = changedStopPlaces.get(0);
List<ValidBetween> actualValidBetween = stopPlace.getValidBetween();
assertThat(actualValidBetween).as("Stop Place should have actualValidBetween set").isNotNull().isNotEmpty().hasSize(1);
assertThat(actualValidBetween.get(0).getFromDate()).isEqualTo(firstValidFrom);
}
use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.
the class ImportResourceTest method importStopWithoutCoordinatesWithQuays1.
/**
* Import stop place StopPlace{name=Skaret (no), quays=
* [Quay{name=Skaret (no), centroid=POINT (7.328336965528884 62.799557598196465), keyValues={imported-id=Value{id=0, items=[MOR:StopArea:1548612801]}}},
* Quay{name=Skaret (no), keyValues={imported-id=Value{id=0, items=[MOR:StopArea:1548575301]}}}],
* keyValues={imported-id=Value{id=0, items=[MOR:StopArea:15485753]}}}
*/
@Test
public void importStopWithoutCoordinatesWithQuays1() throws Exception {
StopPlace stopPlace = new StopPlace().withId("MOR:StopArea:15485753").withVersion("1").withName(new MultilingualString().withValue("Skaret").withLang("no")).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withVersion("1").withId("MOR:StopArea:1548612801").withName(new MultilingualString().withValue("Skaret").withLang("no")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("62.799557598196465")).withLongitude(new BigDecimal("7.328336965528884")))), new Quay().withId("MOR:StopArea:1548575301").withVersion("1").withName(new MultilingualString().withValue("Skaret").withLang("no"))));
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
// Exception should not have been thrown
StopPlace actualStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(response);
List<Quay> actualQuays = publicationDeliveryTestHelper.extractQuays(actualStopPlace);
assertThat(actualQuays).isNotNull().as("quays should not be null");
}
use of org.rutebanken.netex.model.LocationStructure 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));
}
Aggregations