use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationUnitTest method cannotCreateLibSameId.
@Test
public void cannotCreateLibSameId() 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);
Response response = createLib(id, "Library on the other Side of the River", "OS", campId);
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 canListLibs.
@Test
public void canListLibs() 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);
createLib(null, "Main Library", "ML", campId);
createLib(null, "Side Library", "SL", campId);
CompletableFuture<Response> getCompleted = new CompletableFuture<>();
send(locLibraryStorageUrl("/"), 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 canUpdateACamp.
@Test
public void canUpdateACamp() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID instId = UUID.randomUUID();
createInst(instId, "Institute of MetaPhysics", "MPI");
UUID id = UUID.randomUUID();
createCamp(id, "Riverside Campus", "MPI", instId);
JsonObject updateRequest = new JsonObject().put("id", id.toString()).put("name", "The Other Campus").put("institutionId", instId.toString());
CompletableFuture<Response> updated = new CompletableFuture<>();
send(locCampusStorageUrl("/" + id.toString()), HttpMethod.PUT, updateRequest.toString(), SUPPORTED_CONTENT_TYPE_JSON_DEF, ResponseHandler.any(updated));
Response updateResponse = updated.get(5, TimeUnit.SECONDS);
assertThat(updateResponse, statusCodeIs(HttpURLConnection.HTTP_NO_CONTENT));
assertThat(updateResponse.getStatusCode(), is(HttpURLConnection.HTTP_NO_CONTENT));
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("The Other Campus"));
}
use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.
the class LocationUnitTest method createInst.
// ///////////////////////////////////////////////////// Inst test helpers
// May also be used from other tests
public static Response createInst(String name, String code) throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<Response> createLocationUnit = new CompletableFuture<>();
JsonObject request = new JsonObject().put("name", name).put("code", code);
send(locInstitutionStorageUrl(""), 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 canGetAnInstById.
@Test
public void canGetAnInstById() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID id = UUID.randomUUID();
createInst(id, "Institute of MetaPhysics", "MPI");
Response getResponse = getInstById(id);
assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject item = getResponse.getJson();
assertThat(item.getString("id"), is(id.toString()));
assertThat(item.getString("name"), is("Institute of MetaPhysics"));
}
Aggregations