use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class LoansAnonymizationApiTest method shouldRejectInvalidUUID.
@Test
public void shouldRejectInvalidUUID() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
final CompletableFuture<JsonResponse> postCompleted = new CompletableFuture<>();
client.post(loanStorageUrl("/anonymize/" + "foo"), StorageTestSuite.TENANT_ID, ResponseHandler.json(postCompleted));
final JsonResponse postResponse = postCompleted.get(5, TimeUnit.SECONDS);
assertThat(postResponse, isValidationResponseWhich(allOf(hasMessage("Invalid user ID, should be a UUID"), hasParameter("userId", "foo"))));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class StaffSlipsHoldTransitMigrationScriptTest method canMigrateStaffSlips.
@Test
public void canMigrateStaffSlips() throws Exception {
executeMultipleSqlStatements(MIGRATION_SCRIPT);
CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
client.get(staffSlipsStorageUrl(""), StorageTestSuite.TENANT_ID, ResponseHandler.json(getCompleted));
JsonResponse getResponse = getCompleted.get(5, TimeUnit.SECONDS);
assertThat(getResponse.getStatusCode(), Is.is(HttpURLConnection.HTTP_OK));
JsonArray slipsJsonArray = getResponse.getJson().getJsonArray("staffSlips");
JsonObject hold = getRecordById(slipsJsonArray, HOLD_ID);
JsonObject transit = getRecordById(slipsJsonArray, TRANSIT_ID);
assertStaffSlip(hold, HOLD_ID, "Hold");
assertStaffSlip(transit, TRANSIT_ID, "Transit");
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class StaffSlipsPickRequestMigrationScriptTest method canMigrateStaffSlips.
@Test
public void canMigrateStaffSlips() throws Exception {
executeMultipleSqlStatements(MIGRATION_SCRIPT);
CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
client.get(staffSlipsStorageUrl(""), StorageTestSuite.TENANT_ID, ResponseHandler.json(getCompleted));
JsonResponse getResponse = getCompleted.get(5, TimeUnit.SECONDS);
assertThat(getResponse.getStatusCode(), Is.is(HttpURLConnection.HTTP_OK));
JsonArray slipsJsonArray = getResponse.getJson().getJsonArray("staffSlips");
JsonObject pickSlips = getRecordById(slipsJsonArray, PICK_SLIPS_ID);
JsonObject requestDelivery = getRecordById(slipsJsonArray, REQUEST_DELIVERY_ID);
assertStaffSlip(pickSlips, PICK_SLIPS_ID, "Pick slip");
assertStaffSlip(requestDelivery, REQUEST_DELIVERY_ID, "Request delivery");
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestPoliciesApiTest method cannotCreateRequestPolicyWithoutName.
@Test
public void cannotCreateRequestPolicyWithoutName() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
CompletableFuture<JsonResponse> failedCompleted = new CompletableFuture<>();
List<RequestType> requestTypes = Collections.singletonList(RequestType.HOLD);
// create requestPolicy without name
UUID id = UUID.randomUUID();
RequestPolicy requestPolicy = new RequestPolicy();
requestPolicy.withDescription("test policy 2");
requestPolicy.withRequestTypes(requestTypes);
requestPolicy.withId(id.toString());
client.post(requestPolicyStorageUrl(""), requestPolicy, StorageTestSuite.TENANT_ID, ResponseHandler.json(failedCompleted));
JsonResponse response2 = failedCompleted.get(CONNECTION_TIMEOUT, TimeUnit.SECONDS);
assertThat(response2, isUnprocessableEntity());
JsonObject error = extractErrorObject(response2);
assertThat("unexpected error message", error, // any server language
anyOf(hasMessage("must not be null"), hasMessage("darf nicht null sein")));
}
use of org.folio.rest.support.JsonResponse in project mod-circulation-storage by folio-org.
the class RequestPoliciesApiTest method cannotCreateRequestPolicyWithBadUID.
@Test
public void cannotCreateRequestPolicyWithBadUID() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
List<RequestType> requestTypes = Collections.singletonList(RequestType.HOLD);
String badId = "bad_uuid";
RequestPolicy requestPolicy = new RequestPolicy();
requestPolicy.withDescription("test policy");
requestPolicy.withName("successful_get");
requestPolicy.withRequestTypes(requestTypes);
requestPolicy.withId(badId);
client.post(requestPolicyStorageUrl(""), requestPolicy, StorageTestSuite.TENANT_ID, ResponseHandler.json(createCompleted));
JsonResponse response = createCompleted.get(CONNECTION_TIMEOUT, TimeUnit.SECONDS);
assertThat(String.format("Failed to create request policy: %s", response.getBody()), response.getStatusCode(), is(HttpURLConnection.HTTP_INTERNAL_ERROR));
assertThat(response.getBody(), containsString("Invalid UUID string"));
}
Aggregations