use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationUnitTest method canListCamps.
@Test
public void canListCamps() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID instId = UUID.randomUUID();
createInst(instId, "Institute of MetaPhysics", "MPI");
createCamp(null, "Riverside Campus", "RSC", instId);
createCamp(null, "Other Side Campus", "OSC", instId);
CompletableFuture<Response> getCompleted = new CompletableFuture<>();
send(locCampusStorageUrl("/"), HttpMethod.GET, null, SUPPORTED_CONTENT_TYPE_JSON_DEF, ResponseHandler.json(getCompleted));
Response getResponse = getCompleted.get(5, TimeUnit.SECONDS);
assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject item = getResponse.getJson();
assertThat(item.getInteger("totalRecords"), is(2));
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationUnitTest method canDeleteALib.
@Test
public void canDeleteALib() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID instId = UUID.randomUUID();
createInst(instId, "Institute of MetaPhysics", "MPI");
UUID campId = UUID.randomUUID();
createCamp(campId, "Riverside Campus", "RS", instId);
UUID id = UUID.randomUUID();
createLib(id, "Main Library", "RS", campId);
CompletableFuture<Response> deleteCompleted = new CompletableFuture<>();
send(locLibraryStorageUrl("/" + 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_NO_CONTENT));
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationUnitTest method createLib.
// //////////////////////////////////// Library test helpers
public static Response createLib(UUID id, String name, String code, UUID campId) throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<Response> createLocationUnit = new CompletableFuture<>();
JsonObject request = new JsonObject().put("name", name).put("code", code).put("campusId", campId.toString());
if (id != null) {
request.put("id", id.toString());
}
send(locLibraryStorageUrl(""), HttpMethod.POST, request.toString(), SUPPORTED_CONTENT_TYPE_JSON_DEF, ResponseHandler.json(createLocationUnit));
return createLocationUnit.get(5, TimeUnit.SECONDS);
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationUnitTest method cannotCreateCampWithSameName.
@Test
public void cannotCreateCampWithSameName() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID instId = UUID.randomUUID();
createInst(instId, "Institute of MetaPhysics", "MPI");
createCamp(null, "Riverside Campus", "RS", instId);
Response response = createCamp(null, "Riverside Campus", "RS", instId);
assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationUnitTest method canGetACampById.
@Test
public void canGetACampById() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID instId = UUID.randomUUID();
createInst(instId, "Institute of MetaPhysics", "MPI");
UUID id = UUID.randomUUID();
createCamp(id, "Riverside Campus", "RS", instId);
Response getResponse = getCampById(id);
assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject item = getResponse.getJson();
assertThat(item.getString("id"), is(id.toString()));
assertThat(item.getString("name"), is("Riverside Campus"));
}
Aggregations