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