Search in sources :

Example 1 with PackageCollection

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

the class EholdingsPackagesTest method shouldReturnEmptyResponseWhenPackagesReturnedWithErrorOnSearchByTags.

@Test
public void shouldReturnEmptyResponseWhenPackagesReturnedWithErrorOnSearchByTags() {
    savePackage(buildDbPackage(FULL_PACKAGE_ID, configuration.getId(), STUB_PACKAGE_NAME), vertx);
    savePackage(buildDbPackage(FULL_PACKAGE_ID_2, configuration.getId(), STUB_PACKAGE_NAME_2), vertx);
    saveTag(vertx, FULL_PACKAGE_ID, PACKAGE, STUB_TAG_VALUE);
    saveTag(vertx, FULL_PACKAGE_ID_2, PACKAGE, STUB_TAG_VALUE);
    mockGet(new RegexPattern(".*vendors/.*/packages/.*"), HttpStatus.SC_INTERNAL_SERVER_ERROR);
    PackageCollection packageCollection = getWithOk(PACKAGES_ENDPOINT + "?filter[tags]=" + STUB_TAG_VALUE, STUB_TOKEN_HEADER).as(PackageCollection.class);
    List<PackageCollectionItem> packages = packageCollection.getData();
    assertEquals(2, (int) packageCollection.getMeta().getTotalResults());
    assertEquals(0, packages.size());
}
Also used : PackageCollectionItem(org.folio.rest.jaxrs.model.PackageCollectionItem) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) Test(org.junit.Test)

Example 2 with PackageCollection

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

the class EholdingsProvidersImplTest method shouldReturnEmptyPackageListWhenNoProviderPackagesAreFound.

@Test
public void shouldReturnEmptyPackageListWhenNoProviderPackagesAreFound() throws IOException, URISyntaxException {
    String packageStubResponseFile = "responses/rmapi/packages/get-packages-by-provider-id-empty.json";
    mockGet(new RegexPattern(PROVIDER_PACKAGES_RM_API_PATH), packageStubResponseFile);
    PackageCollection packages = getWithOk(PROVIDER_PACKAGES, STUB_TOKEN_HEADER).as(PackageCollection.class);
    assertThat(packages.getData(), empty());
    assertEquals(0, (int) packages.getMeta().getTotalResults());
}
Also used : RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) Matchers.containsString(org.hamcrest.Matchers.containsString) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) Test(org.junit.Test)

Example 3 with PackageCollection

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

the class EholdingsProvidersImplTest method shouldReturnEmptyResponseWhenPackagesReturnedWithErrorOnSearchByAccessType.

@Test
public void shouldReturnEmptyResponseWhenPackagesReturnedWithErrorOnSearchByAccessType() {
    List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
    insertAccessTypeMapping(FULL_PACKAGE_ID, PACKAGE, accessTypes.get(0).getId(), vertx);
    insertAccessTypeMapping(FULL_PACKAGE_ID_4, PACKAGE, accessTypes.get(0).getId(), vertx);
    mockGet(new RegexPattern(".*vendors/.*/packages/.*"), SC_INTERNAL_SERVER_ERROR);
    String resourcePath = PROVIDER_PACKAGES + "?filter[access-type]=" + STUB_ACCESS_TYPE_NAME;
    PackageCollection packageCollection = getWithOk(resourcePath, STUB_TOKEN_HEADER).as(PackageCollection.class);
    List<PackageCollectionItem> packages = packageCollection.getData();
    assertEquals(2, (int) packageCollection.getMeta().getTotalResults());
    assertEquals(0, packages.size());
}
Also used : PackageCollectionItem(org.folio.rest.jaxrs.model.PackageCollectionItem) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) Matchers.containsString(org.hamcrest.Matchers.containsString) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) AccessType(org.folio.rest.jaxrs.model.AccessType) Test(org.junit.Test)

Example 4 with PackageCollection

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

the class EholdingsProvidersImplTest method shouldReturnPackagesOnSearchByProviderIdAndAccessTypeWithPagination.

@Test
public void shouldReturnPackagesOnSearchByProviderIdAndAccessTypeWithPagination() throws IOException, URISyntaxException {
    List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
    insertAccessTypeMapping(FULL_PACKAGE_ID, PACKAGE, accessTypes.get(0).getId(), vertx);
    insertAccessTypeMapping(FULL_PACKAGE_ID_4, PACKAGE, accessTypes.get(1).getId(), vertx);
    String credentialsId = configuration.getId();
    setUpPackage(vertx, credentialsId, STUB_PACKAGE_ID, STUB_VENDOR_ID, STUB_PACKAGE_NAME);
    setUpPackage(vertx, credentialsId, STUB_PACKAGE_ID_2, STUB_VENDOR_ID, STUB_PACKAGE_NAME_2);
    setUpPackage(vertx, credentialsId, STUB_PACKAGE_ID_3, STUB_VENDOR_ID, STUB_PACKAGE_NAME_3);
    String resourcePath = PROVIDER_PACKAGES + "?page=2&count=1&filter[access-type]=" + STUB_ACCESS_TYPE_NAME + "&filter[access-type]=" + STUB_ACCESS_TYPE_NAME_2;
    PackageCollection packageCollection = getWithOk(resourcePath, STUB_TOKEN_HEADER).as(PackageCollection.class);
    List<PackageCollectionItem> packages = packageCollection.getData();
    assertEquals(2, (int) packageCollection.getMeta().getTotalResults());
    assertEquals(1, packages.size());
    assertEquals(STUB_PACKAGE_NAME, packages.get(0).getAttributes().getName());
}
Also used : PackageCollectionItem(org.folio.rest.jaxrs.model.PackageCollectionItem) Matchers.containsString(org.hamcrest.Matchers.containsString) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) AccessType(org.folio.rest.jaxrs.model.AccessType) Test(org.junit.Test)

Example 5 with PackageCollection

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

the class EholdingsPackagesTest method shouldReturnPackagesOnSearchWithPagination.

@Test
public void shouldReturnPackagesOnSearchWithPagination() throws IOException, URISyntaxException {
    saveTag(vertx, FULL_PACKAGE_ID, PACKAGE, STUB_TAG_VALUE);
    saveTag(vertx, FULL_PACKAGE_ID_2, PACKAGE, STUB_TAG_VALUE);
    saveTag(vertx, FULL_PACKAGE_ID_3, PACKAGE, STUB_TAG_VALUE);
    setUpPackages(vertx, configuration.getId());
    PackageCollection packageCollection = getWithOk(PACKAGES_ENDPOINT + "?page=2&count=1&filter[tags]=" + STUB_TAG_VALUE, STUB_TOKEN_HEADER).as(PackageCollection.class);
    List<PackageCollectionItem> packages = packageCollection.getData();
    assertEquals(3, (int) packageCollection.getMeta().getTotalResults());
    assertEquals(1, packages.size());
    assertEquals(STUB_PACKAGE_NAME_2, packages.get(0).getAttributes().getName());
}
Also used : PackageCollectionItem(org.folio.rest.jaxrs.model.PackageCollectionItem) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) Test(org.junit.Test)

Aggregations

PackageCollection (org.folio.rest.jaxrs.model.PackageCollection)11 PackageCollectionItem (org.folio.rest.jaxrs.model.PackageCollectionItem)10 Test (org.junit.Test)10 Matchers.containsString (org.hamcrest.Matchers.containsString)7 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)4 AccessType (org.folio.rest.jaxrs.model.AccessType)4 AccessTypesTestUtil.insertAccessType (org.folio.util.AccessTypesTestUtil.insertAccessType)2 Packages (org.folio.holdingsiq.model.Packages)1 DbPackage (org.folio.repository.packages.DbPackage)1 MetaTotalResults (org.folio.rest.jaxrs.model.MetaTotalResults)1 Tags (org.folio.rest.jaxrs.model.Tags)1