use of org.folio.rest.jaxrs.model.RequestType in project mod-circulation-storage by folio-org.
the class RequestPoliciesApiTest method canGetRequestPolicyById.
@Test
public void canGetRequestPolicyById() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
List<RequestType> requestTypes = Arrays.asList(RequestType.HOLD, RequestType.RECALL);
createDefaultRequestPolicy();
RequestPolicy req2 = createDefaultRequestPolicy(UUID.randomUUID(), "request2 name", "request policy 2 descr", requestTypes);
// Get the newly created request policies
client.get(requestPolicyStorageUrl("/" + req2.getId()), StorageTestSuite.TENANT_ID, ResponseHandler.json(getCompleted));
JsonResponse responseGet = getCompleted.get(CONNECTION_TIMEOUT, TimeUnit.SECONDS);
JsonObject aPolicy = responseGet.getJson();
validateRequestPolicy(req2, aPolicy);
}
use of org.folio.rest.jaxrs.model.RequestType in project mod-circulation-storage by folio-org.
the class RequestPoliciesApiTest method cannotUpdateRequestPolicyWithoutName.
@Test
public void cannotUpdateRequestPolicyWithoutName() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
CompletableFuture<JsonResponse> failedCompleted = new CompletableFuture<>();
List<RequestType> requestTypes = Collections.singletonList(RequestType.HOLD);
RequestPolicy requestPolicy = createDefaultRequestPolicy();
// update requestPolicy
requestPolicy.setDescription("new description!!!");
requestPolicy.setName(null);
requestPolicy.setRequestTypes(requestTypes);
client.put(requestPolicyStorageUrl("/" + requestPolicy.getId()), requestPolicy, StorageTestSuite.TENANT_ID, ResponseHandler.json(failedCompleted));
JsonResponse response2 = failedCompleted.get(CONNECTION_TIMEOUT, TimeUnit.SECONDS);
assertThat(response2, isUnprocessableEntity());
JsonObject error = extractErrorObject(response2);
assertThat("unexpected error message", error, // any server language
anyOf(hasMessage("must not be null"), hasMessage("darf nicht null sein")));
}
use of org.folio.rest.jaxrs.model.RequestType in project mod-circulation-storage by folio-org.
the class RequestPoliciesApiTest method canUpdateRequestPolicyWithNewId.
@Test
public void canUpdateRequestPolicyWithNewId() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
CompletableFuture<JsonResponse> updateCompleted = new CompletableFuture<>();
List<RequestType> requestTypes = Arrays.asList(RequestType.HOLD, RequestType.PAGE);
RequestPolicy requestPolicy = createDefaultRequestPolicy(UUID.randomUUID(), "old name", "plain description", requestTypes);
// update requestPolicy
String newUid = UUID.randomUUID().toString();
requestPolicy.setDescription("new description");
requestPolicy.setName("new name");
requestPolicy.setId(newUid);
client.put(requestPolicyStorageUrl("/" + newUid), requestPolicy, StorageTestSuite.TENANT_ID, ResponseHandler.json(updateCompleted));
JsonResponse response = updateCompleted.get(CONNECTION_TIMEOUT, TimeUnit.SECONDS);
assertThat("Failed to update request-policy", response.getStatusCode(), is(HttpURLConnection.HTTP_NO_CONTENT));
}
use of org.folio.rest.jaxrs.model.RequestType in project mod-circulation-storage by folio-org.
the class RequestPoliciesApiTest method cannotUpdateRequestPolicyWithWrongId.
@Test
public void cannotUpdateRequestPolicyWithWrongId() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
CompletableFuture<JsonResponse> updateCompleted = new CompletableFuture<>();
List<RequestType> requestTypes = Arrays.asList(RequestType.HOLD, RequestType.PAGE);
RequestPolicy requestPolicy = createDefaultRequestPolicy(UUID.randomUUID(), "sample request policy", "plain description", requestTypes);
// update
String newUid = UUID.randomUUID().toString();
requestPolicy.setDescription("new description");
client.put(requestPolicyStorageUrl("/" + newUid), requestPolicy, StorageTestSuite.TENANT_ID, ResponseHandler.json(updateCompleted));
// Because of the unique name constraint, instead of getting an error message about a nonexistent object, the message
// is about duplicate name. This happens because PUT can also be used to add a new record to the database.
JsonResponse response = updateCompleted.get(CONNECTION_TIMEOUT, TimeUnit.SECONDS);
assertThat(response, isBadRequest());
assertThat(response.getBody(), containsString("already exists"));
}
use of org.folio.rest.jaxrs.model.RequestType in project mod-circulation-storage by folio-org.
the class RequestPoliciesApiTest method createDefaultRequestPolicy.
private RequestPolicy createDefaultRequestPolicy() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
List<RequestType> requestTypes = Arrays.asList(RequestType.HOLD, RequestType.PAGE);
UUID id1 = UUID.randomUUID();
REQ_POLICY_NAME_INCR++;
return createDefaultRequestPolicy(id1, DEFAULT_REQUEST_POLICY_NAME + REQ_POLICY_NAME_INCR, "test policy", requestTypes);
}
Aggregations