Search in sources :

Example 1 with SiteRefStructure

use of org.rutebanken.tiamat.model.SiteRefStructure in project tiamat by entur.

the class StopPlaceTerminatorTest method testCannotDeactivateChild.

@Transactional
@Test
public void testCannotDeactivateChild() {
    StopPlace savedStopPlace = stopPlaceVersionedSaverService.saveNewVersion(new StopPlace(new EmbeddableMultilingualString("Name")));
    savedStopPlace.setParentSiteRef(new SiteRefStructure("x", "2"));
    stopPlaceRepository.save(savedStopPlace);
    String stopPlaceNetexId = savedStopPlace.getNetexId();
    assertThatThrownBy(() -> stopPlaceTerminator.terminateStopPlace(stopPlaceNetexId, Instant.now(), "Deactivating Stop", null)).isInstanceOf(IllegalArgumentException.class);
}
Also used : StopPlace(org.rutebanken.tiamat.model.StopPlace) SiteRefStructure(org.rutebanken.tiamat.model.SiteRefStructure) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest) Transactional(javax.transaction.Transactional)

Example 2 with SiteRefStructure

use of org.rutebanken.tiamat.model.SiteRefStructure in project tiamat by entur.

the class VersionCreatorTest method createCopyOfStopPlaceWithChildren.

@Test
public void createCopyOfStopPlaceWithChildren() {
    StopPlace parent = new StopPlace();
    parent.setVersion(1L);
    parent.setParentStopPlace(true);
    stopPlaceRepository.save(parent);
    StopPlace child1 = new StopPlace();
    child1.setCreated(Instant.now());
    child1.setVersion(1L);
    child1.setParentSiteRef(new SiteRefStructure(parent.getNetexId(), String.valueOf(parent.getVersion())));
    stopPlaceRepository.save(child1);
    StopPlace child2 = new StopPlace();
    child2.setVersion(1L);
    child2.setParentSiteRef(new SiteRefStructure(parent.getNetexId(), String.valueOf(parent.getVersion())));
    stopPlaceRepository.save(child2);
    parent.getChildren().add(child1);
    parent.getChildren().add(child2);
    stopPlaceRepository.save(parent);
    StopPlace parentCopy = versionCreator.createCopy(parent, StopPlace.class);
    assertThat(parentCopy.getChildren()).hasSize(2);
}
Also used : StopPlace(org.rutebanken.tiamat.model.StopPlace) SiteRefStructure(org.rutebanken.tiamat.model.SiteRefStructure) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 3 with SiteRefStructure

use of org.rutebanken.tiamat.model.SiteRefStructure in project tiamat by entur.

the class GroupOfStopPlacesSaverServiceTest method saveNewVersionDoesNotAcceptChildStopPlaceRefs.

@Test
public void saveNewVersionDoesNotAcceptChildStopPlaceRefs() throws Exception {
    StopPlace stopPlace = new StopPlace();
    stopPlace.setParentSiteRef(new SiteRefStructure("NSR:StopPlace:99999"));
    stopPlaceRepository.save(stopPlace);
    GroupOfStopPlaces groupOfStopPlaces = new GroupOfStopPlaces();
    groupOfStopPlaces.setName(new EmbeddableMultilingualString("name"));
    groupOfStopPlaces.getMembers().add(new StopPlaceReference(stopPlace.getNetexId()));
    assertThatThrownBy(() -> groupOfStopPlacesSaverService.saveNewVersion(groupOfStopPlaces)).isInstanceOf(IllegalArgumentException.class);
}
Also used : StopPlace(org.rutebanken.tiamat.model.StopPlace) GroupOfStopPlaces(org.rutebanken.tiamat.model.GroupOfStopPlaces) StopPlaceReference(org.rutebanken.tiamat.model.StopPlaceReference) SiteRefStructure(org.rutebanken.tiamat.model.SiteRefStructure) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 4 with SiteRefStructure

use of org.rutebanken.tiamat.model.SiteRefStructure in project tiamat by entur.

the class ParkingVersionedSaverServiceTest method saveNewParking.

@Test
public void saveNewParking() {
    Parking newVersion = new Parking();
    Point point = geometryFactory.createPoint(new Coordinate(9.84, 59.26));
    newVersion.setCentroid(point);
    newVersion.setParentSiteRef(new SiteRefStructure(stopPlaceRepository.save(new StopPlace()).getNetexId()));
    Parking actual = parkingVersionedSaverService.saveNewVersion(newVersion);
    assertThat(actual.getVersion()).isOne();
}
Also used : StopPlace(org.rutebanken.tiamat.model.StopPlace) Coordinate(org.locationtech.jts.geom.Coordinate) Parking(org.rutebanken.tiamat.model.Parking) SiteRefStructure(org.rutebanken.tiamat.model.SiteRefStructure) Point(org.locationtech.jts.geom.Point) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 5 with SiteRefStructure

use of org.rutebanken.tiamat.model.SiteRefStructure in project tiamat by entur.

the class ParkingVersionedSaverServiceTest method saveExistingParking.

@Test
public void saveExistingParking() {
    StopPlace stopPlace = new StopPlace();
    stopPlaceRepository.save(stopPlace);
    Parking existingParking = new Parking();
    Point point = geometryFactory.createPoint(new Coordinate(9.84, 59.26));
    existingParking.setCentroid(point);
    existingParking.setVersion(2L);
    existingParking.setCreated(Instant.now());
    existingParking.setParentSiteRef(new SiteRefStructure(stopPlace.getNetexId()));
    parkingRepository.save(existingParking);
    Parking newParking = new Parking();
    newParking.setNetexId(existingParking.getNetexId());
    newParking.setName(new EmbeddableMultilingualString("name"));
    newParking.setCentroid(null);
    newParking.setParentSiteRef(new SiteRefStructure(stopPlace.getNetexId()));
    Parking actual = parkingVersionedSaverService.saveNewVersion(newParking);
    assertThat(actual.getCentroid()).isNull();
    assertThat(actual.getVersion()).isEqualTo(3L);
    assertThat(actual.getName().getValue()).isEqualTo(newParking.getName().getValue());
    assertThat(actual.getChanged()).as("changed").isNotNull();
    assertThat(actual.getCreated()).as("created").isNotNull();
}
Also used : StopPlace(org.rutebanken.tiamat.model.StopPlace) Coordinate(org.locationtech.jts.geom.Coordinate) Parking(org.rutebanken.tiamat.model.Parking) SiteRefStructure(org.rutebanken.tiamat.model.SiteRefStructure) Point(org.locationtech.jts.geom.Point) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Aggregations

SiteRefStructure (org.rutebanken.tiamat.model.SiteRefStructure)36 Test (org.junit.Test)33 TiamatIntegrationTest (org.rutebanken.tiamat.TiamatIntegrationTest)31 StopPlace (org.rutebanken.tiamat.model.StopPlace)31 EmbeddableMultilingualString (org.rutebanken.tiamat.model.EmbeddableMultilingualString)20 ValidBetween (org.rutebanken.tiamat.model.ValidBetween)12 Parking (org.rutebanken.tiamat.model.Parking)11 Quay (org.rutebanken.tiamat.model.Quay)8 ChangedStopPlaceSearch (org.rutebanken.tiamat.repository.search.ChangedStopPlaceSearch)7 Instant (java.time.Instant)6 List (java.util.List)6 Pageable (org.springframework.data.domain.Pageable)6 Map (java.util.Map)5 Coordinate (org.locationtech.jts.geom.Coordinate)5 IdMappingDto (org.rutebanken.tiamat.dtoassembling.dto.IdMappingDto)5 ExportParams (org.rutebanken.tiamat.exporter.params.ExportParams)5 StopPlaceSearch (org.rutebanken.tiamat.exporter.params.StopPlaceSearch)5 Sets (com.google.common.collect.Sets)4 ChronoUnit (java.time.temporal.ChronoUnit)4 ArrayList (java.util.ArrayList)4