Search in sources :

Example 11 with SimplePoint_VersionStructure

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));
}
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)

Example 12 with SimplePoint_VersionStructure

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);
}
Also used : Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) Quay(org.rutebanken.netex.model.Quay) KeyValueStructure(org.rutebanken.netex.model.KeyValueStructure) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PublicationDeliveryHelper(org.rutebanken.tiamat.netex.mapping.PublicationDeliveryHelper) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) StopPlace(org.rutebanken.netex.model.StopPlace) ArrayList(java.util.ArrayList) Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) BigDecimal(java.math.BigDecimal) ValidBetween(org.rutebanken.netex.model.ValidBetween) ByteArrayInputStream(java.io.ByteArrayInputStream) MultilingualString(org.rutebanken.netex.model.MultilingualString) ImportType(org.rutebanken.tiamat.importer.ImportType) ImportParams(org.rutebanken.tiamat.importer.ImportParams) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) Set(java.util.Set) Test(org.junit.Test) StreamingOutput(javax.ws.rs.core.StreamingOutput) IOException(java.io.IOException) StopTypeEnumeration(org.rutebanken.netex.model.StopTypeEnumeration) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest) LocationStructure(org.rutebanken.netex.model.LocationStructure) JAXBException(javax.xml.bind.JAXBException) Sets(com.google.common.collect.Sets) StandardCharsets(java.nio.charset.StandardCharsets) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) SAXException(org.xml.sax.SAXException) Assert(org.junit.Assert) PrivateCodeStructure(org.rutebanken.netex.model.PrivateCodeStructure) InputStream(java.io.InputStream) 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) 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 13 with SimplePoint_VersionStructure

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");
}
Also used : Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) Quay(org.rutebanken.netex.model.Quay) KeyValueStructure(org.rutebanken.netex.model.KeyValueStructure) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PublicationDeliveryHelper(org.rutebanken.tiamat.netex.mapping.PublicationDeliveryHelper) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) StopPlace(org.rutebanken.netex.model.StopPlace) ArrayList(java.util.ArrayList) Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) BigDecimal(java.math.BigDecimal) ValidBetween(org.rutebanken.netex.model.ValidBetween) ByteArrayInputStream(java.io.ByteArrayInputStream) MultilingualString(org.rutebanken.netex.model.MultilingualString) ImportType(org.rutebanken.tiamat.importer.ImportType) ImportParams(org.rutebanken.tiamat.importer.ImportParams) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) Set(java.util.Set) Test(org.junit.Test) StreamingOutput(javax.ws.rs.core.StreamingOutput) IOException(java.io.IOException) StopTypeEnumeration(org.rutebanken.netex.model.StopTypeEnumeration) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest) LocationStructure(org.rutebanken.netex.model.LocationStructure) JAXBException(javax.xml.bind.JAXBException) Sets(com.google.common.collect.Sets) StandardCharsets(java.nio.charset.StandardCharsets) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) SAXException(org.xml.sax.SAXException) Assert(org.junit.Assert) PrivateCodeStructure(org.rutebanken.netex.model.PrivateCodeStructure) InputStream(java.io.InputStream) StopPlace(org.rutebanken.netex.model.StopPlace) PrivateCodeStructure(org.rutebanken.netex.model.PrivateCodeStructure) 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 14 with SimplePoint_VersionStructure

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));
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) ImportParams(org.rutebanken.tiamat.importer.ImportParams) 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)

Example 15 with SimplePoint_VersionStructure

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);
}
Also used : Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) Quay(org.rutebanken.netex.model.Quay) KeyValueStructure(org.rutebanken.netex.model.KeyValueStructure) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PublicationDeliveryHelper(org.rutebanken.tiamat.netex.mapping.PublicationDeliveryHelper) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) StopPlace(org.rutebanken.netex.model.StopPlace) ArrayList(java.util.ArrayList) Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) BigDecimal(java.math.BigDecimal) ValidBetween(org.rutebanken.netex.model.ValidBetween) ByteArrayInputStream(java.io.ByteArrayInputStream) MultilingualString(org.rutebanken.netex.model.MultilingualString) ImportType(org.rutebanken.tiamat.importer.ImportType) ImportParams(org.rutebanken.tiamat.importer.ImportParams) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) Set(java.util.Set) Test(org.junit.Test) StreamingOutput(javax.ws.rs.core.StreamingOutput) IOException(java.io.IOException) StopTypeEnumeration(org.rutebanken.netex.model.StopTypeEnumeration) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest) LocationStructure(org.rutebanken.netex.model.LocationStructure) JAXBException(javax.xml.bind.JAXBException) Sets(com.google.common.collect.Sets) StandardCharsets(java.nio.charset.StandardCharsets) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) SAXException(org.xml.sax.SAXException) Assert(org.junit.Assert) PrivateCodeStructure(org.rutebanken.netex.model.PrivateCodeStructure) InputStream(java.io.InputStream) 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) MultilingualString(org.rutebanken.netex.model.MultilingualString) KeyValueStructure(org.rutebanken.netex.model.KeyValueStructure) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Aggregations

SimplePoint_VersionStructure (org.rutebanken.netex.model.SimplePoint_VersionStructure)52 Test (org.junit.Test)49 LocationStructure (org.rutebanken.netex.model.LocationStructure)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