use of org.folio.rest.jaxrs.model.ResourcePutRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldDeselectManagedResourceOnPutWithSelectedFalse.
@Test
public void shouldDeselectManagedResourceOnPutWithSelectedFalse() throws IOException, URISyntaxException, JSONException {
String stubResponseFile = "responses/rmapi/resources/get-managed-resource-updated-response-is-selected-false.json";
String expectedResourceFile = "responses/kb-ebsco/resources/expected-managed-resource.json";
ResourcePutRequest request = readJsonFile("requests/kb-ebsco/resource/put-managed-resource-is-not-selected.json", ResourcePutRequest.class);
request.getData().getAttributes().setIsSelected(false);
String actualResponse = mockUpdateResourceScenario(stubResponseFile, MANAGED_RESOURCE_ENDPOINT, STUB_MANAGED_RESOURCE_ID, Json.encode(request));
Resource expectedResource = readJsonFile(expectedResourceFile, Resource.class);
expectedResource.getData().getAttributes().setIsSelected(false);
JSONAssert.assertEquals(Json.encode(expectedResource), actualResponse, false);
verify(1, putRequestedFor(new UrlPathPattern(new RegexPattern(MANAGED_RESOURCE_ENDPOINT), true)).withRequestBody(new EqualToJsonPattern(readFile("requests/rmapi/resources/put-managed-resource-is-not-selected.json"), true, true)));
}
use of org.folio.rest.jaxrs.model.ResourcePutRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImpl method putEholdingsResourcesByResourceId.
@Override
@HandleValidationErrors
public void putEholdingsResourcesByResourceId(String resourceId, String contentType, ResourcePutRequest entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
ResourceId parsedResourceId = parseResourceId(resourceId);
templateFactory.createTemplate(okapiHeaders, asyncResultHandler).requestAction(context -> fetchAccessType(entity, context).thenCompose(accessType -> processResourceUpdate(entity, parsedResourceId, context).thenCompose(resourceResult -> {
context.getTitlesService().updateCache(resourceResult);
return updateAccessType(resourceId, resourceResult, accessType, context);
}))).addErrorMapper(InputValidationException.class, error422InputValidationMapper()).addErrorMapper(ResourceNotFoundException.class, error404ResourceNotFoundMapper()).addErrorMapper(NotFoundException.class, error400NotFoundMapper()).executeWithResult(Resource.class);
}
Aggregations