Search in sources :

Example 31 with JsonResponse

use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.

the class CirculationRulesApiTest method get.

/**
 * @return the JSON of the get response, asserts an HTTP_OK=200 response
 */
private JsonObject get() throws Exception {
    JsonResponse response = getResponse();
    assertThat(response, matchesOk());
    return response.getJson();
}
Also used : JsonResponse(org.folio.rest.support.JsonResponse)

Example 32 with JsonResponse

use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.

the class PatronNoticePoliciesApiTest method cannotUpdatePatronNoticePolicyWithNotValidSendEvery.

@Test
public void cannotUpdatePatronNoticePolicyWithNotValidSendEvery() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    JsonObject sendEvery = new JsonObject().put("duration", "2").put("intervalId", "Hours");
    JsonObject sendOptions = new JsonObject().put("sendWhen", "Renewed").put("sendEvery", sendEvery);
    JsonObject noticePolicy = createNoticePolicyWithSendOptions(sendOptions);
    JsonResponse response = putPatronNoticePolicy(noticePolicy);
    assertThat(response.getStatusCode(), is(422));
    assertThat(response.getJson().getJsonArray("errors").getJsonObject(0).getString("message"), is("This option is not valid for selected Triggering event"));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 33 with JsonResponse

use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.

the class PatronNoticePoliciesApiTest method canDeletePatronNoticePolicy.

@Test
public void canDeletePatronNoticePolicy() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    JsonObject noticePolicy = new JsonObject().put("name", "sample policy");
    String id = postPatronNoticePolicy(noticePolicy).getJson().getString("id");
    JsonResponse response = deletePatronNoticePolicy(id);
    assertThat(response.getStatusCode(), is(204));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 34 with JsonResponse

use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.

the class PatronNoticePoliciesApiTest method cannotUpdatePatronNoticePolicyWithNotUniqueName.

@Test
public void cannotUpdatePatronNoticePolicyWithNotUniqueName() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    JsonObject firstPolicy = new JsonObject().put("name", "first policy");
    JsonObject secondPolicy = new JsonObject().put("name", "second policy");
    postPatronNoticePolicy(firstPolicy);
    String id = postPatronNoticePolicy(secondPolicy).getJson().getString("id");
    JsonResponse response = putPatronNoticePolicy(secondPolicy.put("id", id).put("name", firstPolicy.getString("name")));
    String code = response.getJson().getJsonArray("errors").getJsonObject(0).getString("code");
    assertThat(response.getStatusCode(), is(422));
    assertThat(code, is(STATUS_CODE_DUPLICATE_NAME));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 35 with JsonResponse

use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.

the class AnonymizeLoansApiTest method anonymizeLoans.

private AnonymizeStorageLoansResponse anonymizeLoans(String... loanIds) throws MalformedURLException {
    final JsonResponse response = attemptAnonymizeLoans(loanIds);
    assertThat(response.getStatusCode(), is(200));
    return response.getJson().mapTo(AnonymizeStorageLoansResponse.class);
}
Also used : JsonResponse(org.folio.rest.support.JsonResponse)

Aggregations

JsonResponse (org.folio.rest.support.JsonResponse)156 Test (org.junit.Test)133 JsonObject (io.vertx.core.json.JsonObject)91 CompletableFuture (java.util.concurrent.CompletableFuture)91 UUID (java.util.UUID)52 RequestRequestBuilder (org.folio.rest.support.builders.RequestRequestBuilder)20 JsonArray (io.vertx.core.json.JsonArray)19 RequestPolicy (org.folio.rest.jaxrs.model.RequestPolicy)18 IndividualResource (org.folio.rest.support.IndividualResource)15 LoanRequestBuilder (org.folio.rest.support.builders.LoanRequestBuilder)12 URL (java.net.URL)11 RequestType (org.folio.rest.jaxrs.model.RequestType)10 RequestPreference (org.folio.rest.jaxrs.model.RequestPreference)9 StaffSlipRequestBuilder (org.folio.rest.support.builders.StaffSlipRequestBuilder)9 Response (org.folio.rest.support.Response)8 ResponseHandler (org.folio.rest.support.ResponseHandler)8 DateTime (org.joda.time.DateTime)7 MalformedURLException (java.net.MalformedURLException)6 ExecutionException (java.util.concurrent.ExecutionException)6 TimeoutException (java.util.concurrent.TimeoutException)6