Search in sources :

Example 11 with RequestType

use of org.folio.rest.jaxrs.model.RequestType in project mod-circulation-storage by folio-org.

the class RequestPoliciesApiTest method cannotUpdateRequestPolicyToExistingPolicyName.

@Test
public void cannotUpdateRequestPolicyToExistingPolicyName() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    CompletableFuture<JsonResponse> updateCompleted = new CompletableFuture<>();
    String policy1Name = "Policy 1";
    String policy2Name = "Policy 2";
    List<RequestType> requestTypes = Arrays.asList(RequestType.HOLD, RequestType.PAGE);
    createDefaultRequestPolicy(UUID.randomUUID(), policy1Name, "plain description", requestTypes);
    RequestPolicy requestPolicy2 = createDefaultRequestPolicy(UUID.randomUUID(), policy2Name, "plain description", requestTypes);
    // update: set the name of requestPolicy2 to be of policy1's.
    requestPolicy2.setDescription("new description for policy 2");
    requestPolicy2.setName(policy1Name);
    requestPolicy2.setRequestTypes(Arrays.asList(RequestType.RECALL, RequestType.HOLD));
    client.put(requestPolicyStorageUrl("/" + requestPolicy2.getId()), requestPolicy2, StorageTestSuite.TENANT_ID, ResponseHandler.json(updateCompleted));
    JsonResponse response = updateCompleted.get(CONNECTION_TIMEOUT, TimeUnit.SECONDS);
    assertThat("Failed to update request-policy", response, isBadRequest());
    assertThat("Error message does not contain keyword 'already existed'", response.getBody(), containsString("already exists"));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) StringContains.containsString(org.hamcrest.core.StringContains.containsString) JsonResponse(org.folio.rest.support.JsonResponse) RequestType(org.folio.rest.jaxrs.model.RequestType) RequestPolicy(org.folio.rest.jaxrs.model.RequestPolicy) Test(org.junit.Test)

Aggregations

RequestType (org.folio.rest.jaxrs.model.RequestType)11 CompletableFuture (java.util.concurrent.CompletableFuture)10 RequestPolicy (org.folio.rest.jaxrs.model.RequestPolicy)10 JsonResponse (org.folio.rest.support.JsonResponse)10 Test (org.junit.Test)10 StringContains.containsString (org.hamcrest.core.StringContains.containsString)6 JsonObject (io.vertx.core.json.JsonObject)5 UUID (java.util.UUID)3 DateTime (org.joda.time.DateTime)1