Search in sources :

Example 1 with TariffZoneSearch

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());
}
Also used : TariffZone(org.rutebanken.tiamat.model.TariffZone) TariffZoneSearch(org.rutebanken.tiamat.exporter.params.TariffZoneSearch) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 2 with TariffZoneSearch

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());
}
Also used : TariffZone(org.rutebanken.tiamat.model.TariffZone) TariffZoneSearch(org.rutebanken.tiamat.exporter.params.TariffZoneSearch) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 3 with TariffZoneSearch

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());
}
Also used : TariffZone(org.rutebanken.tiamat.model.TariffZone) TariffZoneSearch(org.rutebanken.tiamat.exporter.params.TariffZoneSearch) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 4 with TariffZoneSearch

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());
}
Also used : TariffZone(org.rutebanken.tiamat.model.TariffZone) TariffZoneSearch(org.rutebanken.tiamat.exporter.params.TariffZoneSearch) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 5 with TariffZoneSearch

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());
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) TariffZone(org.rutebanken.tiamat.model.TariffZone) TariffZoneSearch(org.rutebanken.tiamat.exporter.params.TariffZoneSearch) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TariffZoneSearch (org.rutebanken.tiamat.exporter.params.TariffZoneSearch)5 TariffZone (org.rutebanken.tiamat.model.TariffZone)5 Test (org.junit.Test)4 TiamatIntegrationTest (org.rutebanken.tiamat.TiamatIntegrationTest)4 EmbeddableMultilingualString (org.rutebanken.tiamat.model.EmbeddableMultilingualString)4 PageImpl (org.springframework.data.domain.PageImpl)1 Transactional (org.springframework.transaction.annotation.Transactional)1