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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations