Search in sources :

Example 31 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.

the class ImportResourceTest method importPublicationDeliveryAndExpectCertainWordsToBeRemovedFromNames.

@Test
public void importPublicationDeliveryAndExpectCertainWordsToBeRemovedFromNames() throws Exception {
    StopPlace stopPlace = new StopPlace().withId("XYZ:stoparea:1").withVersion("1").withName(new MultilingualString().withValue("Steinerskolen Moss (Buss)")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71")))).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withId("XYZ:boardingpos:2").withVersion("1").withName(new MultilingualString().withValue("Steinerskolen [tog]")).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);
    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();
    assertThat(actualStopPlace.getName().getValue()).isEqualTo("Steinerskolen Moss");
    assertThat(quay.getName().getValue()).isEqualTo("Steinerskolen");
}
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) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 32 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.

the class ImportResourceTest method createdAndChangedTimestampsMustBeSetOnStopPlaceAndQuays.

@Test
public void createdAndChangedTimestampsMustBeSetOnStopPlaceAndQuays() throws Exception {
    StopPlace stopPlace = new StopPlace().withId("XYZ:StopPlace:4").withVersion("1").withName(new MultilingualString().withValue("new")).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withVersion("1").withId("XYZ:Quay:5").withName(new MultilingualString().withValue("new quay")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("62.799557598196465")).withLongitude(new BigDecimal("7.328336965528884"))))));
    PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
    PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
    StopPlace actualStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(response);
    assertThat(actualStopPlace.getCreated()).as("The imported stop place's created date must not be null").isNotNull();
    List<Quay> actualQuays = publicationDeliveryTestHelper.extractQuays(actualStopPlace);
    assertThat(actualQuays.get(0).getCreated()).as("The imported quay's created date must not be null").isNotNull();
}
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 33 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.

the class ImportResourceTest method updateStopPlaceShouldHaveItsDateChanged.

@Test
public void updateStopPlaceShouldHaveItsDateChanged() throws Exception {
    StopPlace stopPlace = new StopPlace().withId("XYZ:StopPlace:123").withVersion("1").withName(new MultilingualString().withValue("new"));
    PublicationDeliveryStructure firstPublicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
    PublicationDeliveryStructure firstResponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(firstPublicationDelivery);
    StopPlace actualStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(firstResponse);
    LocalDateTime changedDate = actualStopPlace.getChanged();
    // Add a Quay to the stop place so that it will be updated.
    stopPlace.withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withVersion("1").withId("XYZ:Quay:321").withName(new MultilingualString().withValue("new quay")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("62.799557598196465")).withLongitude(new BigDecimal("7.328336965528884"))))));
    PublicationDeliveryStructure secondPublicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
    PublicationDeliveryStructure secondResponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(secondPublicationDelivery);
    StopPlace changedStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(secondResponse);
    assertThat(changedDate).as("The changed date for stop should not be the same as the first time it was imported").isNotEqualTo(changedStopPlace.getChanged());
}
Also used : LocalDateTime(java.time.LocalDateTime) 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 34 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.

the class ImportResourceTest method expectQuayNameToBeRemovedIfSameAsParentStopPlaceName.

@Test
public void expectQuayNameToBeRemovedIfSameAsParentStopPlaceName() throws Exception {
    StopPlace stopPlace = new StopPlace().withId("XYZ:stoparea:2").withVersion("1").withName(new MultilingualString().withValue("Fleskeby sentrum")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9")).withLongitude(new BigDecimal("71")))).withQuays(new Quays_RelStructure().withQuayRefOrQuay(new Quay().withId("XYZ:boardingpos:2").withVersion("1").withName(new MultilingualString().withValue("Fleskeby sentrum")).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);
    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();
    assertThat(actualStopPlace.getName().getValue()).isEqualTo("Fleskeby sentrum");
    assertThat(quay.getName()).isNull();
}
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) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 35 with LocationStructure

use of org.rutebanken.netex.model.LocationStructure in project tiamat by entur.

the class ImportResourceTest method initialImportThenMergeShouldNotMergeNearbyQuays.

/**
 * When importing a stop place witch is a direct match with import type MERGE. No changes should be made to the stop place.
 * <p>
 * https://rutebanken.atlassian.net/browse/NRP-1587
 */
@Test
public void initialImportThenMergeShouldNotMergeNearbyQuays() throws Exception {
    // Quays with different original ID
    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("XYZ:Quay:4").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9.1")).withLongitude(new BigDecimal("71.2"))))).withQuayRefOrQuay(new Quay().withId("XYZ:Quay:5").withVersion("1").withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("9.1")).withLongitude(new BigDecimal("71.2"))))));
    PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
    ImportParams importParams = new ImportParams();
    importParams.importType = ImportType.INITIAL;
    publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery, importParams);
    importParams.importType = ImportType.MERGE;
    PublicationDeliveryStructure mergeResponse = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery, importParams);
    StopPlace actualStopPlace = publicationDeliveryTestHelper.findFirstStopPlace(mergeResponse);
    assertThat(actualStopPlace.getQuays()).isNotNull().as("quays should not be null");
    List<Quay> quays = publicationDeliveryTestHelper.extractQuays(actualStopPlace);
    assertThat(quays).hasSize(2);
    quays.forEach(quay -> {
        Set<String> importedIds = publicationDeliveryHelper.getImportedIds(quay);
        assertThat(importedIds).hasSize(1);
    });
}
Also used : Quays_RelStructure(org.rutebanken.netex.model.Quays_RelStructure) 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) 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)

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