use of org.folio.rest.jaxrs.model.PackagePutRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldPassIsFullPackageAttributeToRMAPI.
@Test
public void shouldPassIsFullPackageAttributeToRMAPI() throws URISyntaxException, IOException {
PackageByIdData updatedPackage = mapper.readValue(getFile(PACKAGE_STUB_FILE), PackageByIdData.class).toByIdBuilder().isSelected(true).build();
mockUpdateScenario(readFile(PACKAGE_STUB_FILE), mapper.writeValueAsString(updatedPackage));
PackagePutRequest request = mapper.readValue(readFile("requests/kb-ebsco/package/put-package-selected.json"), PackagePutRequest.class);
request.getData().getAttributes().setIsFullPackage(false);
putWithOk(PACKAGES_PATH, mapper.writeValueAsString(request), STUB_TOKEN_HEADER).as(Package.class);
PackagePut rmApiPutRequest = mapper.readValue(readFile("requests/rmapi/packages/put-package-is-selected.json"), PackagePut.class).toBuilder().isFullPackage(false).build();
verify(putRequestedFor(PACKAGE_URL_PATTERN).withRequestBody(new EqualToJsonPattern(mapper.writeValueAsString(rmApiPutRequest), true, true)));
}
use of org.folio.rest.jaxrs.model.PackagePutRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesImpl method putEholdingsPackagesByPackageId.
@Override
@HandleValidationErrors
public void putEholdingsPackagesByPackageId(String packageId, String contentType, PackagePutRequest entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
PackageId parsedPackageId = parsePackageId(packageId);
templateFactory.createTemplate(okapiHeaders, asyncResultHandler).requestAction(context -> context.getPackagesService().retrievePackage(parsedPackageId).thenCompose(packageByIdData -> fetchAccessType(entity, context).thenCompose(accessType -> processUpdateRequest(entity, packageByIdData, context).thenCompose(voidEntity -> {
CompletableFuture<PackageByIdData> future = context.getPackagesService().retrievePackage(parsedPackageId);
return handleDeletedPackage(future, parsedPackageId, context);
}).thenApply(packageById -> new PackageResult(packageById, null, null)).thenCompose(packageResult -> updateAccessTypeMapping(accessType, packageResult, context))))).addErrorMapper(NotFoundException.class, error400NotFoundMapper()).addErrorMapper(InputValidationException.class, error422InputValidationMapper()).executeWithResult(Package.class);
}
use of org.folio.rest.jaxrs.model.PackagePutRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method sendPut.
private Package sendPut(String mockUpdatedPackage) throws IOException, URISyntaxException {
mockUpdateScenario(readFile(PACKAGE_STUB_FILE), mockUpdatedPackage);
PackagePutRequest packageToBeUpdated = mapper.readValue(getFile("requests/kb-ebsco/package/put-package-selected.json"), PackagePutRequest.class);
return putWithOk(PACKAGES_PATH, mapper.writeValueAsString(packageToBeUpdated), STUB_TOKEN_HEADER).as(Package.class);
}
Aggregations