use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronActionSessionAPITest method cannotGetPatronActionSessionStorageExpiredSessionPatronIds.
@Test
public void cannotGetPatronActionSessionStorageExpiredSessionPatronIds() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
URL url = StorageTestSuite.storageUrl("/patron-action-session-storage/expired-session-patron-ids", "action_type", "Check-out", "session_inactivity_time_limit", "wrong date", "limit", Integer.toString(10));
JsonResponse response = get(url);
assertThat(response.getStatusCode(), is(422));
assertThat(response.getJson().getJsonArray("errors").getJsonObject(0).getString("message"), is("Date cannot be parsed"));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronActionSessionAPITest method cannotUpdateNonExistentActionSession.
@Test
public void cannotUpdateNonExistentActionSession() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
JsonObject nonExistPatronActionSession = createPatronActionSession("Check-out");
JsonResponse response = assertRecordClient.attemptPutById(nonExistPatronActionSession);
assertThat(response.getStatusCode(), is(404));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronActionSessionAPITest method cannotGetPatronActionSessionStorageExpiredSessionPatronIdsWithWrongActionType.
@Test
public void cannotGetPatronActionSessionStorageExpiredSessionPatronIdsWithWrongActionType() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
String firstPatronId = UUID.randomUUID().toString();
createPatronActionSessionRecords(firstPatronId, "Check-in", DateTime.now().minusDays(2));
URL url = StorageTestSuite.storageUrl("/patron-action-session-storage/expired-session-patron-ids", "action_type", "WrongType", "session_inactivity_time_limit", DateTime.now().minusDays(2).toString(ISODateTimeFormat.dateTime()), "limit", "10");
JsonResponse response = get(url);
assertThat(response.getStatusCode(), is(422));
assertThat(response.getJson().getJsonArray("errors").getJsonObject(0).getString("message"), is("Invalid action type value"));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronNoticePoliciesApiTest method canGetAllPatronNoticePolicies.
@Test
public void canGetAllPatronNoticePolicies() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonObject firstPolicy = new JsonObject().put("name", "first policy");
JsonObject secondPolicy = new JsonObject().put("name", "second policy");
postPatronNoticePolicy(firstPolicy);
postPatronNoticePolicy(secondPolicy);
CompletableFuture<JsonResponse> getAllCompleted = new CompletableFuture<>();
client.get(patronNoticePoliciesStorageUrl(), TENANT_ID, ResponseHandler.json(getAllCompleted));
JsonResponse response = getAllCompleted.get(5, TimeUnit.SECONDS);
assertThat("Failed to get all patron notice policies", response.getStatusCode(), is(200));
JsonArray policies = response.getJson().getJsonArray("patronNoticePolicies");
assertThat(policies.size(), is(2));
assertThat(response.getJson().getInteger("totalRecords"), is(2));
String[] names = policies.stream().map(JsonObject.class::cast).map(json -> json.getString("name")).toArray(String[]::new);
assertThat(names, arrayContainingInAnyOrder(firstPolicy.getString("name"), secondPolicy.getString("name")));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class PatronNoticePoliciesApiTest method canUpdatePatronNoticePolicy.
@Test
public void canUpdatePatronNoticePolicy() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonObject noticePolicy = new JsonObject().put("name", "sample policy");
String id = postPatronNoticePolicy(noticePolicy).getJson().getString("id");
JsonObject sendOptions = new JsonObject().put("sendWhen", "Request expiration");
String templateId = UUID.randomUUID().toString();
JsonObject requestNotice = new JsonObject().put("templateId", templateId).put("format", "Email").put("realTime", "true").put("sendOptions", sendOptions);
noticePolicy.put("id", id).put("description", "new description").put("requestNotices", new JsonArray().add(requestNotice));
JsonResponse response = putPatronNoticePolicy(noticePolicy);
assertThat("Failed to update patron notice policy", response.getStatusCode(), is(204));
JsonObject updatedPolicy = getPatronNoticePolicyById(id).getJson();
JsonObject updatedRequestNotice = updatedPolicy.getJsonArray("requestNotices").getJsonObject(0);
JsonObject updatedSendOptions = updatedRequestNotice.getJsonObject("sendOptions");
assertThat(updatedPolicy.getString("description"), is("new description"));
assertThat(updatedRequestNotice.getString("templateId"), is(templateId));
assertThat(updatedRequestNotice.getString("format"), is("Email"));
assertThat(updatedRequestNotice.getBoolean("realTime"), is(true));
assertThat(updatedSendOptions.getString("sendWhen"), is("Request expiration"));
}
Aggregations