use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class AssertingRecordClient method getAll.
public MultipleRecords<JsonObject> getAll() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
final CompletableFuture<JsonResponse> fetchManyCompleted = new CompletableFuture<>();
this.client.get(urlMaker.combine(""), StorageTestSuite.TENANT_ID, ResponseHandler.json(fetchManyCompleted));
final JsonResponse fetchedLoansResponse = fetchManyCompleted.get(5, TimeUnit.SECONDS);
assertThat(fetchedLoansResponse, isOk());
return MultipleRecords.fromJson(fetchedLoansResponse.getJson(), collectionPropertyName);
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class ValidationResponseMatchers method isValidationResponseWhich.
public static TypeSafeDiagnosingMatcher<JsonResponse> isValidationResponseWhich(Matcher<JsonObject> errorMatcher) {
return new TypeSafeDiagnosingMatcher<JsonResponse>() {
@Override
public void describeTo(Description description) {
description.appendText("A response with status code 422 and an error which ").appendDescriptionOf(errorMatcher);
}
@Override
protected boolean matchesSafely(JsonResponse response, Description description) {
final Matcher<TextResponse> statusCodeMatcher = isUnprocessableEntity();
if (!statusCodeMatcher.matches(response)) {
statusCodeMatcher.describeMismatch(response, description);
return false;
}
final TypeSafeDiagnosingMatcher<JsonObject> validationErrorsMatcher = hasErrorWith(errorMatcher);
final JsonObject body = response.getJson();
validationErrorsMatcher.describeMismatch(body, description);
return validationErrorsMatcher.matches(body);
}
};
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method cannotDeleteRequestPreferenceByNotExistingId.
@Test
public void cannotDeleteRequestPreferenceByNotExistingId() {
JsonResponse response = deletePreference(UUID.randomUUID().toString());
assertThat(response, isNotFound());
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method cannotUpdateRequestPreferenceWithDuplicateUserId.
@Test
public void cannotUpdateRequestPreferenceWithDuplicateUserId() {
createRequestPreference(USER_ID);
RequestPreference secondPreference = createRequestPreference(USER_ID2).getJson().mapTo(RequestPreference.class);
JsonResponse response = updatePreference(constructDefaultPreference(USER_ID).withId(secondPreference.getId()));
assertThat(response, isUnprocessableEntity());
assertThat(response.getJson().toString(), containsString("Request preference for specified user already exists"));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method cannotUpdateRequestPreferenceWithNotExistingId.
@Test
public void cannotUpdateRequestPreferenceWithNotExistingId() {
RequestPreference preference = constructDefaultPreference(USER_ID).withId(UUID.randomUUID().toString());
JsonResponse response = updatePreference(preference);
assertThat(response, isNotFound());
}
Aggregations