Search in sources :

Example 1 with HttpClient

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

the class StorageTestSuite method deleteAll.

static void deleteAll(URL rootUrl) {
    HttpClient client = new HttpClient(getVertx());
    CompletableFuture<Response> deleteAllFinished = new CompletableFuture<>();
    try {
        client.delete(rootUrl, TENANT_ID, ResponseHandler.any(deleteAllFinished));
        Response response = deleteAllFinished.get(5, TimeUnit.SECONDS);
        if (response.getStatusCode() != 204) {
            Assert.fail("Delete all preparation failed: " + response.getBody());
        }
    } catch (Exception e) {
        Assert.fail("WARNING!!!!! Unable to delete all: " + e.getMessage());
    }
}
Also used : Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) HttpClient(org.folio.rest.support.HttpClient) MalformedURLException(java.net.MalformedURLException) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with HttpClient

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

the class TestBase method testBaseBeforeClass.

@BeforeClass
public static void testBaseBeforeClass() throws Exception {
    Vertx vertx = StorageTestSuite.getVertx();
    if (vertx == null) {
        invokeStorageTestSuiteAfter = true;
        StorageTestSuite.before();
        vertx = StorageTestSuite.getVertx();
    }
    client = new HttpClient(vertx);
    instancesClient = ResourceClient.forInstances(client);
    holdingsClient = ResourceClient.forHoldings(client);
}
Also used : HttpClient(org.folio.rest.support.HttpClient) Vertx(io.vertx.core.Vertx) BeforeClass(org.junit.BeforeClass)

Example 3 with HttpClient

use of org.folio.rest.support.HttpClient 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 4 with HttpClient

use of org.folio.rest.support.HttpClient 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)

Aggregations

HttpClient (org.folio.rest.support.HttpClient)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 Response (org.folio.rest.support.Response)3 Vertx (io.vertx.core.Vertx)1 MalformedURLException (java.net.MalformedURLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 BeforeClass (org.junit.BeforeClass)1