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");
}
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();
}
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());
}
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();
}
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);
});
}
Aggregations