use of org.folio.rest.jaxrs.model.AccessType in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldUpdateAllAttributesInCustomPackageAndCreateNewAccessTypeMapping.
@Test
public void shouldUpdateAllAttributesInCustomPackageAndCreateNewAccessTypeMapping() throws URISyntaxException, IOException {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
String accessTypeId = accessTypes.get(0).getId();
boolean updatedSelected = true;
boolean updatedHidden = true;
String updatedBeginCoverage = "2003-01-01";
String updatedEndCoverage = "2004-01-01";
String updatedPackageName = "name of the ages forever and ever";
EqualToJsonPattern putBodyPattern = new EqualToJsonPattern(readFile("requests/rmapi/packages/put-package-custom.json"), true, true);
PackageByIdData packageData = mapper.readValue(getFile(CUSTOM_PACKAGE_STUB_FILE), PackageByIdData.class);
packageData = packageData.toByIdBuilder().isSelected(updatedSelected).visibilityData(packageData.getVisibilityData().toBuilder().isHidden(updatedHidden).build()).customCoverage(CoverageDates.builder().beginCoverage(updatedBeginCoverage).endCoverage(updatedEndCoverage).build()).packageName(updatedPackageName).contentType("streamingmedia").build();
String updatedPackageValue = mapper.writeValueAsString(packageData);
mockUpdateScenario(readFile(CUSTOM_PACKAGE_STUB_FILE), updatedPackageValue);
String putBody = String.format(readFile("requests/kb-ebsco/package/put-package-custom-with-access-type.json"), accessTypeId);
Package aPackage = putWithOk(PACKAGES_PATH, putBody, STUB_TOKEN_HEADER).as(Package.class);
verify(putRequestedFor(PACKAGE_URL_PATTERN).withRequestBody(putBodyPattern));
assertEquals(updatedSelected, aPackage.getData().getAttributes().getIsSelected());
assertEquals(updatedHidden, aPackage.getData().getAttributes().getVisibilityData().getIsHidden());
assertEquals(updatedBeginCoverage, aPackage.getData().getAttributes().getCustomCoverage().getBeginCoverage());
assertEquals(updatedEndCoverage, aPackage.getData().getAttributes().getCustomCoverage().getEndCoverage());
assertEquals(updatedPackageName, aPackage.getData().getAttributes().getName());
assertEquals(ContentType.STREAMING_MEDIA, aPackage.getData().getAttributes().getContentType());
List<AccessTypeMapping> accessTypeMappingsInDB = getAccessTypeMappings(vertx);
assertEquals(1, accessTypeMappingsInDB.size());
assertEquals(aPackage.getData().getId(), accessTypeMappingsInDB.get(0).getRecordId());
assertEqualsUUID(accessTypeId, accessTypeMappingsInDB.get(0).getAccessTypeId());
assertEquals(PACKAGE, accessTypeMappingsInDB.get(0).getRecordType());
assertNotNull(aPackage.getIncluded());
assertEquals(accessTypeId, aPackage.getData().getRelationships().getAccessType().getData().getId());
assertEquals(accessTypeId, ((LinkedHashMap<?, ?>) aPackage.getIncluded().get(0)).get("id"));
}
use of org.folio.rest.jaxrs.model.AccessType in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturnPackageWithAccessTypeOnGetById.
@Test
public void shouldReturnPackageWithAccessTypeOnGetById() throws IOException, URISyntaxException {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
String expectedAccessTypeId = accessTypes.get(0).getId();
insertAccessTypeMapping(FULL_PACKAGE_ID, PACKAGE, expectedAccessTypeId, vertx);
mockGet(new RegexPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
Package packageData = getWithOk(PACKAGES_ENDPOINT + "/" + FULL_PACKAGE_ID, STUB_TOKEN_HEADER).as(Package.class);
assertNotNull(packageData.getIncluded());
assertEquals(expectedAccessTypeId, packageData.getData().getRelationships().getAccessType().getData().getId());
assertEquals(expectedAccessTypeId, ((LinkedHashMap<?, ?>) packageData.getIncluded().get(0)).get("id"));
}
use of org.folio.rest.jaxrs.model.AccessType in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesTest method shouldReturnEmptyTitlesOnSearchByAccessTypesThatIsNotExist.
@Test
public void shouldReturnEmptyTitlesOnSearchByAccessTypesThatIsNotExist() throws IOException, URISyntaxException {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID, RESOURCE, accessTypes.get(0).getId(), vertx);
insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID_2, RESOURCE, accessTypes.get(1).getId(), vertx);
mockGetTitles();
String resourcePath = EHOLDINGS_TITLES_PATH + "?filter[access-type]=Not Exist";
TitleCollection titleCollection = getWithOk(resourcePath, STUB_TOKEN_HEADER).as(TitleCollection.class);
List<TitleCollectionItem> titles = titleCollection.getData();
assertThat(titles, hasSize(0));
assertEquals(0, (int) titleCollection.getMeta().getTotalResults());
}
use of org.folio.rest.jaxrs.model.AccessType 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.AccessType 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());
}
Aggregations