use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronNoticePoliciesApiTest method canGetPatronNoticePolicy.
@Test
public void canGetPatronNoticePolicy() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonObject noticePolicy = new JsonObject().put("name", "sample policy");
String id = postPatronNoticePolicy(noticePolicy).getJson().getString("id");
CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
client.get(patronNoticePoliciesStorageUrl("/" + id), TENANT_ID, ResponseHandler.json(getCompleted));
JsonResponse response = getCompleted.get(5, TimeUnit.SECONDS);
assertThat(response.getStatusCode(), is(200));
assertThat(response.getJson().getString("id"), is(id));
assertThat(response.getJson().getString("name"), is(noticePolicy.getString("name")));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronNoticePoliciesApiTest method cannotUpdatePatronNoticePolicyWithNotValidSendHow.
@Test
public void cannotUpdatePatronNoticePolicyWithNotValidSendHow() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
JsonObject sendOptions = new JsonObject().put("sendWhen", "Renewed").put("sendHow", "Before");
JsonObject loanNotice = new JsonObject().put("templateId", UUID.randomUUID().toString()).put("format", "Email").put("realTime", "true").put("sendOptions", sendOptions);
JsonObject noticePolicy = createNoticePolicyWithLoanNotice(loanNotice);
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"));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestBatchAPITest method cannotInjectSqlThroughRequestId.
@Test
public void cannotInjectSqlThroughRequestId() throws Exception {
UUID itemId = UUID.randomUUID();
JsonObject firstRequest = createRequestForItemAtPosition(itemId, 1);
JsonObject firstRequestCopy = firstRequest.copy();
firstRequestCopy.put("id", "1'; DELETE FROM request where id::text is not '1");
JsonResponse reorderResponse = attemptReorderRequests(ResponseHandler::json, new ReorderRequest(firstRequestCopy, 3));
assertValidationError(reorderResponse, containsString("must match"));
assertRequestsNotUpdated(itemId, firstRequest);
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class LoanPoliciesApiTest method cannotCreateALoanPolicyWithAdditionalPropertiesInLoanPolicy.
@Test
public void cannotCreateALoanPolicyWithAdditionalPropertiesInLoanPolicy() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
UUID id = UUID.randomUUID();
JsonObject loanPolicyRequest = defaultRollingPolicy().withId(id).withName("Example Loan Policy").withDescription("An example loan policy").create();
loanPolicyRequest.getJsonObject("loansPolicy").put("anAdditionalProperty", "blah");
client.post(loanPolicyStorageUrl(), loanPolicyRequest, StorageTestSuite.TENANT_ID, ResponseHandler.json(createCompleted));
JsonResponse response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(String.format("Should fail to create loan policy: %s", response.getBody()), response, matchesUnprocessableEntity());
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class LoanPoliciesApiTest method createFixedDueDateSchedule.
private IndividualResource createFixedDueDateSchedule(String name, DateTime from, DateTime to, DateTime dueDate) throws Exception {
UUID fddId = UUID.randomUUID();
JsonObject fdd = FixedDueDateApiTest.createFixedDueDate(fddId.toString(), name, "desc");
JsonObject fddSchedule = FixedDueDateApiTest.createSchedule(from.toString(), to.toString(), dueDate.toString());
fdd.put(FixedDueDateApiTest.SCHEDULE_SECTION, new JsonArray().add(fddSchedule));
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
client.post(FixedDueDateApiTest.dueDateURL(), fdd, StorageTestSuite.TENANT_ID, ResponseHandler.json(createCompleted));
JsonResponse response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(String.format("Failed to create due date: %s", response.getBody()), response, matchesCreated());
return new IndividualResource(response);
}
Aggregations