use of org.folio.rest.support.builders.RequestRequestBuilder in project mod-circulation-storage by folio-org.
the class RequestsApiTest method canCreateMultipleRequestsForDifferentItemsWithSamePosition.
@Test
public void canCreateMultipleRequestsForDifferentItemsWithSamePosition() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID firstItemId = UUID.randomUUID();
UUID secondItemId = UUID.randomUUID();
JsonObject representation = createEntity(new RequestRequestBuilder().withItemId(firstItemId).withPosition(1).create(), requestStorageUrl()).getJson();
assertThat(representation.getString("id"), is(notNullValue()));
JsonObject representation2 = createEntity(new RequestRequestBuilder().withItemId(firstItemId).withPosition(2).create(), requestStorageUrl()).getJson();
assertThat(representation2.getString("id"), is(notNullValue()));
JsonObject representation3 = createEntity(new RequestRequestBuilder().withItemId(secondItemId).withPosition(1).create(), requestStorageUrl()).getJson();
assertThat(representation3.getString("id"), is(notNullValue()));
JsonObject representation4 = createEntity(new RequestRequestBuilder().withItemId(secondItemId).withPosition(2).create(), requestStorageUrl()).getJson();
assertThat(representation4.getString("id"), is(notNullValue()));
}
use of org.folio.rest.support.builders.RequestRequestBuilder in project mod-circulation-storage by folio-org.
the class RequestsApiTest method canCreateARequestWithPatronComments.
@Test
public void canCreateARequestWithPatronComments() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
JsonObject representation = createEntity(new RequestRequestBuilder().withPatronComments(PATRON_COMMENTS).create(), requestStorageUrl()).getJson();
assertThat(representation.getString("patronComments"), is(PATRON_COMMENTS));
}
use of org.folio.rest.support.builders.RequestRequestBuilder in project mod-circulation-storage by folio-org.
the class RequestsApiTest method cannotCreateARequestWithInvalidStatus.
@Test
@Parameters({ "Non-existent status", "" })
public void cannotCreateARequestWithInvalidStatus(String status) throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
JsonObject requestRequest = new RequestRequestBuilder().withStatus(status).create();
client.post(requestStorageUrl(), requestRequest, TENANT_ID, ResponseHandler.json(createCompleted));
JsonResponse response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(String.format("Should not create request: %s", response.getBody()), response.getStatusCode(), is(HttpURLConnection.HTTP_BAD_REQUEST));
}
use of org.folio.rest.support.builders.RequestRequestBuilder in project mod-circulation-storage by folio-org.
the class RequestsApiTest method awaitingPickupRequestClosedDateIsNotPresentAfterStatusUpdateFromOpenNotYetFilledToClosedCancelled.
@Test
public void awaitingPickupRequestClosedDateIsNotPresentAfterStatusUpdateFromOpenNotYetFilledToClosedCancelled() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonObject request = new RequestRequestBuilder().withStatus(OPEN_NOT_YET_FILLED).create();
String requestId = createEntity(request, requestStorageUrl()).getJson().getString("id");
request.put("status", CLOSED_CANCELLED);
CompletableFuture<Response> putCompleted = new CompletableFuture<>();
client.put(requestStorageUrl("/" + requestId), request, TENANT_ID, ResponseHandler.empty(putCompleted));
putCompleted.get(5, TimeUnit.SECONDS);
JsonObject updatedRequest = getById(requestStorageUrl("/" + requestId));
assertThat(updatedRequest.getString("awaitingPickupRequestClosedDate"), is(nullValue()));
}
use of org.folio.rest.support.builders.RequestRequestBuilder in project mod-circulation-storage by folio-org.
the class RequestsApiTest method canCreateARequestAtASpecificLocation.
@Test
public void canCreateARequestAtASpecificLocation() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID id = UUID.randomUUID();
UUID itemId = UUID.randomUUID();
UUID requesterId = UUID.randomUUID();
DateTime requestDate = new DateTime(2017, 7, 22, 10, 22, 54, DateTimeZone.UTC);
DateTime requestExpirationDate = new DateTime(2017, 7, 30, 0, 0, DateTimeZone.UTC);
DateTime holdShelfExpirationDate = new DateTime(2017, 8, 31, 0, 0, DateTimeZone.UTC);
createEntity(new RequestRequestBuilder().recall().withId(id).withRequestDate(requestDate).withItemId(itemId).withRequesterId(requesterId).toHoldShelf().withRequestExpirationDate(requestExpirationDate).withHoldShelfExpirationDate(holdShelfExpirationDate).withItem("Nod", "565578437802").withRequester("Smith", "Jessica", "721076398251").create(), requestStorageUrl());
JsonObject representation = getById(requestStorageUrl(String.format("/%s", id)));
assertThat(representation.getString("id"), is(id.toString()));
assertThat(representation.getString("requestType"), is("Recall"));
assertThat(representation.getString("requestDate"), is(equivalentTo(requestDate)));
assertThat(representation.getString("itemId"), is(itemId.toString()));
assertThat(representation.getString("requesterId"), is(requesterId.toString()));
assertThat(representation.getString("fulfilmentPreference"), is("Hold Shelf"));
assertThat(representation.getString("requestExpirationDate"), is(equivalentTo(requestExpirationDate)));
assertThat(representation.getString("holdShelfExpirationDate"), is(equivalentTo(holdShelfExpirationDate)));
assertThat(representation.containsKey("item"), is(true));
assertThat(representation.getJsonObject("item").getString("barcode"), is("565578437802"));
assertThat(representation.containsKey("instance"), is(true));
assertThat(representation.getJsonObject("instance").getString("title"), is("Nod"));
assertThat(representation.containsKey("requester"), is(true));
assertThat(representation.getJsonObject("requester").getString("lastName"), is("Smith"));
assertThat(representation.getJsonObject("requester").getString("firstName"), is("Jessica"));
assertThat(representation.getJsonObject("requester").containsKey("middleName"), is(false));
assertThat(representation.getJsonObject("requester").getString("barcode"), is("721076398251"));
}
Aggregations