use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestsApiTest method canSearchForRequestsForAnItem.
@Test
public void canSearchForRequestsForAnItem() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
UUID itemId = UUID.randomUUID();
UUID otherItemId = UUID.randomUUID();
createEntity(new RequestRequestBuilder().withItemId(itemId).withPosition(1).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(itemId).withPosition(2).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(otherItemId).withPosition(1).create(), requestStorageUrl());
CompletableFuture<JsonResponse> getRequestsCompleted = new CompletableFuture<>();
client.get(requestStorageUrl() + String.format("?query=itemId==%s", itemId), TENANT_ID, ResponseHandler.json(getRequestsCompleted));
JsonResponse getRequestsResponse = getRequestsCompleted.get(5, TimeUnit.SECONDS);
assertThat(String.format("Failed to get requests: %s", getRequestsResponse.getBody()), getRequestsResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject wrappedRequests = getRequestsResponse.getJson();
assertThat(wrappedRequests.getJsonArray("requests").size(), is(2));
assertThat(wrappedRequests.getInteger("totalRecords"), is(2));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestsApiTest method canSearchForRequestsByRequesterId.
@Test
public void canSearchForRequestsByRequesterId() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
UUID firstRequester = UUID.randomUUID();
UUID secondRequester = UUID.randomUUID();
createEntity(new RequestRequestBuilder().withRequesterId(firstRequester).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withRequesterId(firstRequester).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withRequesterId(secondRequester).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withRequesterId(firstRequester).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withRequesterId(firstRequester).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withRequesterId(secondRequester).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withRequesterId(secondRequester).create(), requestStorageUrl());
CompletableFuture<JsonResponse> getRequestsCompleted = new CompletableFuture<>();
client.get(requestStorageUrl() + String.format("?query=requesterId=%s", secondRequester), TENANT_ID, ResponseHandler.json(getRequestsCompleted));
JsonResponse getRequestsResponse = getRequestsCompleted.get(5, TimeUnit.SECONDS);
assertThat(String.format("Failed to get requests: %s", getRequestsResponse.getBody()), getRequestsResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject wrappedRequests = getRequestsResponse.getJson();
assertThat(wrappedRequests.getJsonArray("requests").size(), is(3));
assertThat(wrappedRequests.getInteger("totalRecords"), is(3));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronActionSessionAPITest method getExpiredPatronSessions.
private JsonArray getExpiredPatronSessions(String actionType, int limit, DateTime lastActionDateLimit) throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
String actionTypeFilter = actionType != null ? actionType : "";
URL url = StorageTestSuite.storageUrl("/patron-action-session-storage/expired-session-patron-ids", "action_type", actionTypeFilter, "session_inactivity_time_limit", lastActionDateLimit.toString(ISODateTimeFormat.dateTime()), "limit", Integer.toString(limit));
JsonResponse response = get(url);
assertThat(response, isOk());
return response.getJson().getJsonArray("expiredSessions");
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronActionSessionAPITest method get.
private JsonResponse get(URL url) throws InterruptedException, ExecutionException, TimeoutException {
final CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
this.client.get(url, StorageTestSuite.TENANT_ID, ResponseHandler.json(getCompleted));
final JsonResponse response = getCompleted.get(5, TimeUnit.SECONDS);
return response;
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronActionSessionAPITest method canUpdatePatronActiveSession.
@Test
public void canUpdatePatronActiveSession() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
JsonObject request = createPatronActionSession("Check-out");
String id = assertRecordClient.create(request).getJson().getString("id");
request.put("loanId", existingLoanId).put("actionType", "Check-in");
JsonResponse response = assertRecordClient.attemptPutById(request);
assertThat("Failed to update patron active session", response.getStatusCode(), is(204));
IndividualResource updatedPatronActionSession = assertRecordClient.getById(id);
assertThat(updatedPatronActionSession.getJson().getString("loanId"), is(existingLoanId));
assertThat(updatedPatronActionSession.getJson().getString("actionType"), is("Check-in"));
}
Aggregations