Search in sources :

Example 21 with Response

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

the class LocationUnitTest method canDeleteAnInst.

@Test
public void canDeleteAnInst() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    UUID id = UUID.randomUUID();
    createInst(id, "Institute of MetaPhysics", "MPI");
    CompletableFuture<Response> deleteCompleted = new CompletableFuture<>();
    send(locInstitutionStorageUrl("/" + 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));
}
Also used : Response(org.folio.rest.support.Response) HttpClientResponse(io.vertx.core.http.HttpClientResponse) CompletableFuture(java.util.concurrent.CompletableFuture) UUID(java.util.UUID) Test(org.junit.Test)

Example 22 with Response

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

the class LocationUnitTest method createInst.

public static Response createInst(UUID id, String name, String code) throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    CompletableFuture<Response> createLocationUnit = new CompletableFuture<>();
    JsonObject request = new JsonObject().put("id", id.toString()).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);
}
Also used : Response(org.folio.rest.support.Response) HttpClientResponse(io.vertx.core.http.HttpClientResponse) CompletableFuture(java.util.concurrent.CompletableFuture) JsonObject(io.vertx.core.json.JsonObject)

Example 23 with Response

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

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

the class LocationsTest method cannotCreateLocationWithoutUnits.

@Test
public void cannotCreateLocationWithoutUnits() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    Response response = createLocation(null, "Main Library", null, null, null, "PI/CC/ML/X");
    assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
}
Also used : Response(org.folio.rest.support.Response) HttpClientResponse(io.vertx.core.http.HttpClientResponse) Test(org.junit.Test)

Example 25 with Response

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

the class LocationsTest method cannotCreateLocationWithSameId.

@Test
public void cannotCreateLocationWithSameId() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    UUID id = UUID.randomUUID();
    createLocation(id, "Main Library", instID, campID, libID, "PI/CC/ML/X");
    Response response = createLocation(id, "Some Other Library", instID, campID, libID, "AA/BB");
    assertThat(response.getStatusCode(), is(AdditionalHttpStatusCodes.UNPROCESSABLE_ENTITY));
}
Also used : Response(org.folio.rest.support.Response) HttpClientResponse(io.vertx.core.http.HttpClientResponse) UUID(java.util.UUID) Test(org.junit.Test)

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