Search in sources :

Example 6 with LocationStructure

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);
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 7 with LocationStructure

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);
}
Also used : Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) Quay(org.rutebanken.netex.model.Quay) MultilingualString(org.rutebanken.netex.model.MultilingualString) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 8 with LocationStructure

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) MultilingualString(org.rutebanken.netex.model.MultilingualString) ValidBetween(org.rutebanken.netex.model.ValidBetween) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 9 with LocationStructure

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");
}
Also used : Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) Quay(org.rutebanken.netex.model.Quay) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) MultilingualString(org.rutebanken.netex.model.MultilingualString) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 10 with LocationStructure

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));
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) MultilingualString(org.rutebanken.netex.model.MultilingualString) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Aggregations

LocationStructure (org.rutebanken.netex.model.LocationStructure)50 SimplePoint_VersionStructure (org.rutebanken.netex.model.SimplePoint_VersionStructure)50 Test (org.junit.Test)47 BigDecimal (java.math.BigDecimal)37 PublicationDeliveryStructure (org.rutebanken.netex.model.PublicationDeliveryStructure)36 StopPlace (org.rutebanken.netex.model.StopPlace)36 TiamatIntegrationTest (org.rutebanken.tiamat.TiamatIntegrationTest)35 MultilingualString (org.rutebanken.netex.model.MultilingualString)31 ImportParams (org.rutebanken.tiamat.importer.ImportParams)21 Quay (org.rutebanken.netex.model.Quay)16 Quays_RelStructure (org.rutebanken.netex.model.Quays_RelStructure)16 ArrayList (java.util.ArrayList)11 LocalDateTime (java.time.LocalDateTime)9 ValidBetween (org.rutebanken.netex.model.ValidBetween)8 Response (javax.ws.rs.core.Response)7 KeyValueStructure (org.rutebanken.netex.model.KeyValueStructure)7 Sets (com.google.common.collect.Sets)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 IOException (java.io.IOException)6