use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.
the class TariffZoneSaverServiceTest method saveNewTariffZone.
@Test
public void saveNewTariffZone() {
TariffZone newVersion = new TariffZone();
Geometry geometry = geometryFactory.createPoint(new Coordinate(9.84, 59.26)).buffer(20);
LinearRing linearRing = new LinearRing(new CoordinateArraySequence(geometry.getCoordinates()), geometryFactory);
newVersion.setPolygon(geometryFactory.createPolygon(linearRing, null));
TariffZone actual = tariffZoneSaverService.saveNewVersion(newVersion);
assertThat(actual.getPolygon()).isNotNull();
assertThat(actual.getVersion()).isEqualTo(1L);
}
use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.
the class TariffZoneRepositoryImplTest method findTariffZonesByIdPrefix.
@Test
public void findTariffZonesByIdPrefix() throws Exception {
TariffZone tariffZone2V = new TariffZone();
tariffZone2V.setName(new EmbeddableMultilingualString("2V"));
tariffZone2V.setNetexId("RUT:TariffZone:2V");
TariffZone tariffZone412 = new TariffZone();
tariffZone412.setNetexId("BRA:TariffZone:412");
tariffZone412.setName(new EmbeddableMultilingualString("Kongsberg"));
tariffZoneRepository.save(tariffZone2V);
tariffZoneRepository.save(tariffZone412);
TariffZoneSearch search = TariffZoneSearch.newTariffZoneSearchBuilder().query("RUT").build();
List<TariffZone> tariffZoneList = tariffZoneRepository.findTariffZones(search);
assertThat(tariffZoneList).hasSize(1).extracting(TariffZone::getNetexId).containsOnly(tariffZone2V.getNetexId());
}
use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.
the class TariffZoneRepositoryImplTest method findTariffZonesByName.
@Test
public void findTariffZonesByName() throws Exception {
TariffZone tariffZone2V = new TariffZone();
tariffZone2V.setName(new EmbeddableMultilingualString("2V"));
tariffZone2V.setNetexId("RUT:TariffZone:2V");
TariffZone tariffZone412 = new TariffZone();
tariffZone412.setNetexId("BRA:TariffZone:412");
tariffZone412.setName(new EmbeddableMultilingualString("Kongsberg"));
tariffZoneRepository.save(tariffZone2V);
tariffZoneRepository.save(tariffZone412);
TariffZoneSearch search = TariffZoneSearch.newTariffZoneSearchBuilder().query("Kongsberg").build();
List<TariffZone> tariffZoneList = tariffZoneRepository.findTariffZones(search);
assertThat(tariffZoneList).hasSize(1).extracting(TariffZone::getNetexId).containsOnly(tariffZone412.getNetexId());
}
use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.
the class TariffZoneRepositoryImplTest method findTariffZonesById.
@Test
public void findTariffZonesById() throws Exception {
TariffZone tariffZone2V = new TariffZone();
tariffZone2V.setName(new EmbeddableMultilingualString("2V"));
tariffZone2V.setNetexId("RUT:TariffZone:2V");
TariffZone tariffZone412 = new TariffZone();
tariffZone412.setNetexId("BRA:TariffZone:412");
tariffZone412.setName(new EmbeddableMultilingualString("Kongsberg"));
tariffZoneRepository.save(tariffZone2V);
tariffZoneRepository.save(tariffZone412);
TariffZoneSearch search = TariffZoneSearch.newTariffZoneSearchBuilder().query(tariffZone412.getNetexId()).build();
List<TariffZone> tariffZoneList = tariffZoneRepository.findTariffZones(search);
assertThat(tariffZoneList).hasSize(1).extracting(TariffZone::getNetexId).containsOnly(tariffZone412.getNetexId());
}
use of org.rutebanken.tiamat.model.TariffZone in project tiamat by entur.
the class StopPlaceRefUpdaterServiceTest method setup.
@Transactional(propagation = Propagation.REQUIRES_NEW)
public StopPlace setup() {
TariffZone tariffZone = new TariffZone();
tariffZone.setVersion(1L);
Point point = geometryFactory.createPoint(new Coordinate(9.84, 59.26));
Geometry bufferedPoint = point.buffer(20);
LinearRing tariffZoneLinearRing = new LinearRing(new CoordinateArraySequence(bufferedPoint.getCoordinates()), geometryFactory);
tariffZone.setPolygon(geometryFactory.createPolygon(tariffZoneLinearRing, null));
tariffZoneRepository.saveAndFlush(tariffZone);
TopographicPlace topographicPlace = new TopographicPlace();
topographicPlace.setVersion(1L);
topographicPlace.setTopographicPlaceType(TopographicPlaceTypeEnumeration.MUNICIPALITY);
LinearRing topographicPlaceLinearRing = new LinearRing(new CoordinateArraySequence(bufferedPoint.getCoordinates()), geometryFactory);
topographicPlace.setPolygon(geometryFactory.createPolygon(topographicPlaceLinearRing, null));
topographicPlaceRepository.saveAndFlush(topographicPlace);
StopPlace stopPlace = new StopPlace();
stopPlace.setName(new EmbeddableMultilingualString("some stop place"));
stopPlace.setCentroid(point);
stopPlace.setVersion(1L);
stopPlaceRepository.saveAndFlush(stopPlace);
return stopPlace;
}
Aggregations