Search in sources :

Example 1 with ProviderCollection

use of org.folio.rest.jaxrs.model.ProviderCollection in project mod-kb-ebsco-java by folio-org.

the class EholdingsProvidersImplTest method shouldReturnProvidersOnSearchByTagsOnly.

@Test
public void shouldReturnProvidersOnSearchByTagsOnly() {
    saveTag(vertx, STUB_VENDOR_ID, PROVIDER, STUB_TAG_VALUE);
    saveTag(vertx, STUB_VENDOR_ID_2, PROVIDER, STUB_TAG_VALUE);
    saveTag(vertx, STUB_VENDOR_ID_2, PROVIDER, STUB_TAG_VALUE_2);
    saveTag(vertx, STUB_VENDOR_ID_3, PROVIDER, STUB_TAG_VALUE_3);
    setUpTaggedProviders();
    ProviderCollection providerCollection = getWithOk(PROVIDER_PATH + "?filter[tags]=" + STUB_TAG_VALUE + "&filter[tags]=" + STUB_TAG_VALUE_2, STUB_TOKEN_HEADER).as(ProviderCollection.class);
    List<Providers> providers = providerCollection.getData();
    assertEquals(2, (int) providerCollection.getMeta().getTotalResults());
    assertEquals(2, providers.size());
    assertEquals(STUB_VENDOR_NAME, providers.get(0).getAttributes().getName());
    assertEquals(STUB_VENDOR_NAME_2, providers.get(1).getAttributes().getName());
}
Also used : ProviderCollection(org.folio.rest.jaxrs.model.ProviderCollection) Providers(org.folio.rest.jaxrs.model.Providers) Test(org.junit.Test)

Example 2 with ProviderCollection

use of org.folio.rest.jaxrs.model.ProviderCollection in project mod-kb-ebsco-java by folio-org.

the class EholdingsProvidersImplTest method shouldReturnEmptyResponseWhenProvidersReturnedWithErrorOnSearchByTags.

@Test
public void shouldReturnEmptyResponseWhenProvidersReturnedWithErrorOnSearchByTags() {
    String credentialsId = configuration.getId();
    ProvidersTestUtil.saveProvider(buildDbProvider(STUB_VENDOR_ID, credentialsId, STUB_VENDOR_NAME), vertx);
    ProvidersTestUtil.saveProvider(buildDbProvider(STUB_VENDOR_ID_2, credentialsId, STUB_VENDOR_NAME_2), vertx);
    saveTag(vertx, STUB_VENDOR_ID, PROVIDER, STUB_TAG_VALUE);
    saveTag(vertx, STUB_VENDOR_ID_2, PROVIDER, STUB_TAG_VALUE);
    mockGet(new RegexPattern(".*vendors/.*"), SC_INTERNAL_SERVER_ERROR);
    ProviderCollection providerCollection = getWithOk(PROVIDER_PATH + "?filter[tags]=" + STUB_TAG_VALUE, STUB_TOKEN_HEADER).as(ProviderCollection.class);
    List<Providers> providers = providerCollection.getData();
    assertEquals(2, (int) providerCollection.getMeta().getTotalResults());
    assertEquals(0, providers.size());
}
Also used : RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) ProviderCollection(org.folio.rest.jaxrs.model.ProviderCollection) Matchers.containsString(org.hamcrest.Matchers.containsString) Providers(org.folio.rest.jaxrs.model.Providers) Test(org.junit.Test)

Example 3 with ProviderCollection

use of org.folio.rest.jaxrs.model.ProviderCollection in project mod-kb-ebsco-java by folio-org.

the class EholdingsProvidersImplTest method shouldReturnProvidersOnSearchWithTagsAndPagination.

@Test
public void shouldReturnProvidersOnSearchWithTagsAndPagination() {
    saveTag(vertx, STUB_VENDOR_ID, PROVIDER, STUB_TAG_VALUE);
    saveTag(vertx, STUB_VENDOR_ID_2, PROVIDER, STUB_TAG_VALUE);
    saveTag(vertx, STUB_VENDOR_ID_3, PROVIDER, STUB_TAG_VALUE);
    setUpTaggedProviders();
    ProviderCollection providerCollection = getWithOk(PROVIDER_PATH + "?page=2&count=1&filter[tags]=" + STUB_TAG_VALUE, STUB_TOKEN_HEADER).as(ProviderCollection.class);
    List<Providers> providers = providerCollection.getData();
    assertEquals(3, (int) providerCollection.getMeta().getTotalResults());
    assertEquals(1, providers.size());
    assertEquals(STUB_VENDOR_NAME_2, providers.get(0).getAttributes().getName());
}
Also used : ProviderCollection(org.folio.rest.jaxrs.model.ProviderCollection) Providers(org.folio.rest.jaxrs.model.Providers) Test(org.junit.Test)

Aggregations

ProviderCollection (org.folio.rest.jaxrs.model.ProviderCollection)3 Providers (org.folio.rest.jaxrs.model.Providers)3 Test (org.junit.Test)3 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1