use of org.rutebanken.tiamat.exporter.params.TariffZoneSearch 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.exporter.params.TariffZoneSearch 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.exporter.params.TariffZoneSearch 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.exporter.params.TariffZoneSearch in project tiamat by entur.
the class TariffZoneRepositoryImplTest method findTariffZonesByIdSuffix.
@Test
public void findTariffZonesByIdSuffix() 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(tariffZone2V.getName().getValue()).build();
List<TariffZone> tariffZoneList = tariffZoneRepository.findTariffZones(search);
assertThat(tariffZoneList).hasSize(1).extracting(TariffZone::getNetexId).containsOnly(tariffZone2V.getNetexId());
}
use of org.rutebanken.tiamat.exporter.params.TariffZoneSearch in project tiamat by entur.
the class TariffZonesFetcher method get.
@Override
@Transactional
public Page<TariffZone> get(DataFetchingEnvironment environment) {
TariffZoneSearch tariffZoneSearch = TariffZoneSearch.newTariffZoneSearchBuilder().query(environment.getArgument(QUERY)).build();
List<TariffZone> tariffZones = tariffZoneRepository.findTariffZones(tariffZoneSearch);
return new PageImpl<>(tariffZones, PageRequest.of(environment.getArgument(PAGE), environment.getArgument(SIZE)), tariffZones.size());
}
Aggregations