use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method canUpdateRequestPreference.
@Test
public void canUpdateRequestPreference() {
RequestPreference preference = createRequestPreference().getJson().mapTo(RequestPreference.class);
preference.setDelivery(false);
preference.setDefaultDeliveryAddressTypeId(null);
JsonResponse response = updatePreference(preference);
assertThat(response, isNoContent());
RequestPreference updatedPreference = getPreference(preference.getId()).getJson().mapTo(RequestPreference.class);
assertPreferenceEquals(preference, updatedPreference);
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method canGetRequestPreferenceByUserIdUsingQuery.
@Test
public void canGetRequestPreferenceByUserIdUsingQuery() {
RequestPreference createdPreference = createRequestPreference().getJson().mapTo(RequestPreference.class);
JsonResponse response = getPreferences("query=userId=" + USER_ID);
RequestPreferences preferences = response.getJson().mapTo(RequestPreferences.class);
assertThat(preferences.getTotalRecords(), is(1));
RequestPreference foundPreference = preferences.getRequestPreferences().get(0);
assertPreferenceEquals(createdPreference, foundPreference);
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method canCreateARequestPreference.
@Test
public void canCreateARequestPreference() {
JsonResponse response = createRequestPreference();
RequestPreference preference = response.getJson().mapTo(RequestPreference.class);
assertThat(response, isCreated());
assertThat(preference.getDefaultServicePointId(), is(SERVICE_POINT_ID));
assertThat(preference.getUserId(), is(USER_ID));
assertThat(preference.getDefaultDeliveryAddressTypeId(), is(ADDRESS_TYPE_ID));
assertThat(preference.getHoldShelf(), is(HOLD_SHELF));
assertThat(preference.getDelivery(), is(DELIVERY));
assertThat(preference.getFulfillment(), is(FULFILLMENT));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestsApiTest method cannotCreateItemLevelRequestIfItemIdAndHoldingsRecordIdAreNull.
@Test
public void cannotCreateItemLevelRequestIfItemIdAndHoldingsRecordIdAreNull() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
JsonObject request = new RequestRequestBuilder().recall().toHoldShelf().create();
request.remove("holdingsRecordId");
request.remove("itemId");
client.post(requestStorageUrl(), request, TENANT_ID, ResponseHandler.json(createCompleted));
JsonObject response = createCompleted.get(5, TimeUnit.SECONDS).getJson();
assertThat(response, hasErrorWith(hasMessageContaining("Item ID in item level request should not be absent")));
assertThat(response, hasErrorWith(hasMessageContaining("Holdings record ID in item level request should not be absent")));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestsApiTest method canFilterByRequestStatus.
@Test
public void canFilterByRequestStatus() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException, UnsupportedEncodingException {
UUID itemId = UUID.randomUUID();
UUID otherItemId = UUID.randomUUID();
createEntity(new RequestRequestBuilder().withItemId(itemId).withPosition(1).withStatus(OPEN_NOT_YET_FILLED).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(itemId).withPosition(2).withStatus(OPEN_AWAITING_PICKUP).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(itemId).withPosition(3).withStatus(OPEN_AWAITING_DELIVERY).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(itemId).withNoPosition().withStatus(CLOSED_FILLED).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(otherItemId).withPosition(1).withStatus(OPEN_NOT_YET_FILLED).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(otherItemId).withPosition(2).withStatus(OPEN_AWAITING_PICKUP).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(itemId).withPosition(4).withStatus(OPEN_IN_TRANSIT).create(), requestStorageUrl());
createEntity(new RequestRequestBuilder().withItemId(otherItemId).withNoPosition().withStatus(CLOSED_FILLED).create(), requestStorageUrl());
CompletableFuture<JsonResponse> getRequestsCompleted = new CompletableFuture<>();
String query = URLEncoder.encode(String.format("status=\"%s\"", OPEN_NOT_YET_FILLED), UTF_8);
client.get(requestStorageUrl() + String.format("?query=%s", query), 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));
}
Aggregations