use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationsTest method cannotCreateLocationWithSameCode.
@Test
public void cannotCreateLocationWithSameCode() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
createLocation(null, "Main Library", instID, campID, libID, "PI/CC/ML/X");
Response response = createLocation(null, "Some Other Library", instID, campID, libID, "PI/CC/ML/X");
assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationsTest method createLocation.
public static Response createLocation(UUID id, String name, UUID inst, UUID camp, UUID lib, String code) throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<Response> createLocation = new CompletableFuture<>();
JsonObject request = new JsonObject().put("name", name);
putIfNotNull(request, "id", id);
putIfNotNull(request, "institutionId", inst);
putIfNotNull(request, "campusId", camp);
putIfNotNull(request, "libraryId", lib);
putIfNotNull(request, "code", code);
send(locationsStorageUrl(""), HttpMethod.POST, request.toString(), SUPPORTED_CONTENT_TYPE_JSON_DEF, ResponseHandler.json(createLocation));
return createLocation.get(5, TimeUnit.SECONDS);
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationsTest method canGetALocationById.
@Test
public void canGetALocationById() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID id = UUID.randomUUID();
createLocation(id, "Main Library", instID, campID, libID, "PI/CC/ML/X");
Response getResponse = getById(id);
assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject item = getResponse.getJson();
assertThat(item.getString("id"), is(id.toString()));
assertThat(item.getString("name"), is("Main Library"));
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationsTest method cannotDeleteALocationAssociatedWithAnItem.
@Test
public void cannotDeleteALocationAssociatedWithAnItem() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID id = UUID.randomUUID();
createLocation(id, "Main Library", instID, campID, libID, "PI/CC/ML/X");
JsonObject item = createItemRequest(id.toString());
CompletableFuture<Response> createItemCompleted = new CompletableFuture<>();
send(itemsStorageUrl(""), HttpMethod.POST, item.toString(), SUPPORTED_CONTENT_TYPE_JSON_DEF, ResponseHandler.json(createItemCompleted));
Response createItemResponse = createItemCompleted.get(5, TimeUnit.SECONDS);
assertThat(createItemResponse.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));
CompletableFuture<Response> deleteCompleted = new CompletableFuture<>();
send(locationsStorageUrl(id.toString()), HttpMethod.DELETE, null, SUPPORTED_CONTENT_TYPE_JSON_DEF, ResponseHandler.any(deleteCompleted));
Response deleteResponse = deleteCompleted.get(5, TimeUnit.SECONDS);
assertThat(deleteResponse.getStatusCode(), is(HttpURLConnection.HTTP_BAD_REQUEST));
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationsTest method canCreateLocation.
@Test
public void canCreateLocation() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
Response response = createLocation(null, "Main Library", instID, campID, libID, "PI/CC/ML/X");
assertThat(response.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));
assertThat(response.getJson().getString("id"), notNullValue());
assertThat(response.getJson().getString("name"), is("Main Library"));
}
Aggregations