Search in sources :

Example 41 with Response

use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.

the class StorageTestSuite method removeTenant.

private static void removeTenant(String tenantId) throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    CompletableFuture<Response> tenantDeleted = new CompletableFuture<>();
    HttpClient client = new HttpClient(vertx);
    client.delete(storageUrl("/_/tenant"), tenantId, ResponseHandler.any(tenantDeleted));
    Response response = tenantDeleted.get(20, TimeUnit.SECONDS);
    String failureMessage = String.format("Tenant cleanup failed: %s: %s", response.getStatusCode(), response.getBody());
    assertThat(failureMessage, response.getStatusCode(), is(204));
}
Also used : Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) HttpClient(org.folio.rest.support.HttpClient)

Example 42 with Response

use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.

the class StorageTestSuite method prepareTenant.

private static void prepareTenant(String tenantId) throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    CompletableFuture<Response> tenantPrepared = new CompletableFuture<>();
    HttpClient client = new HttpClient(vertx);
    client.post(storageUrl("/_/tenant"), null, tenantId, ResponseHandler.any(tenantPrepared));
    Response response = tenantPrepared.get(20, TimeUnit.SECONDS);
    String failureMessage = String.format("Tenant preparation failed: %s: %s", response.getStatusCode(), response.getBody());
    assertThat(failureMessage, response.getStatusCode(), is(201));
}
Also used : Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) HttpClient(org.folio.rest.support.HttpClient)

Example 43 with Response

use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.

the class ShelfLocationsTest method canCreateShelfLocation.

@Test
public void canCreateShelfLocation() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    Response response = LocationsTest.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"));
}
Also used : Response(org.folio.rest.support.Response) HttpClientResponse(io.vertx.core.http.HttpClientResponse) Test(org.junit.Test)

Example 44 with Response

use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.

the class ShelfLocationsTest method canGetAShelfLocationById.

@Test
public void canGetAShelfLocationById() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    UUID id = UUID.randomUUID();
    LocationsTest.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"));
}
Also used : Response(org.folio.rest.support.Response) HttpClientResponse(io.vertx.core.http.HttpClientResponse) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) Test(org.junit.Test)

Example 45 with Response

use of org.folio.rest.support.Response in project mod-inventory-storage by folio-org.

the class ShelfLocationsClient method create.

public String create(String name) throws InterruptedException, ExecutionException, TimeoutException {
    CompletableFuture<Response> completed = new CompletableFuture<>();
    JsonObject shelfLocationRequest = new JsonObject().put("name", name);
    client.post(shelfLocationsUrl, shelfLocationRequest, StorageTestSuite.TENANT_ID, ResponseHandler.json(completed));
    Response response = completed.get(5, TimeUnit.SECONDS);
    return response.getJson().getString("id");
}
Also used : Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) JsonObject(io.vertx.core.json.JsonObject)

Aggregations

Response (org.folio.rest.support.Response)46 HttpClientResponse (io.vertx.core.http.HttpClientResponse)40 Test (org.junit.Test)34 CompletableFuture (java.util.concurrent.CompletableFuture)25 UUID (java.util.UUID)24 JsonObject (io.vertx.core.json.JsonObject)22 HttpClient (org.folio.rest.support.HttpClient)3 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 DecodeException (io.vertx.core.json.DecodeException)1 MalformedURLException (java.net.MalformedURLException)1