Search in sources :

Example 31 with Response

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

the class LocationUnitTest method cannotCreateCampSameId.

@Test
public void cannotCreateCampSameId() 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 response = createCamp(id, "Campus on the other Side of the River", "OS", instId);
    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)

Example 32 with Response

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

the class LocationUnitTest method cannotCreateInstSameId.

@Test
public void cannotCreateInstSameId() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    UUID id = UUID.randomUUID();
    createInst(id, "Institute of MetaPhysics", "MPI");
    Response response = createInst(id, "The Other Institute", "MPI");
    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)

Example 33 with Response

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

the class LocationUnitTest method cannotCreateInstWithSameName.

@Test
public void cannotCreateInstWithSameName() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
    createInst("Institute of MetaPhysics", "MPI");
    Response response = createInst("Institute of MetaPhysics", "MPI");
    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 34 with Response

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

the class LocationUnitTest method canGetALibById.

@Test
public void canGetALibById() 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", "ML", campId);
    Response getResponse = getLibById(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"));
    assertThat(item.getString("campusId"), is(campId.toString()));
}
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 35 with Response

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

the class LocationUnitTest method canCreateALib.

// //////////// Library tests
@Test
public void canCreateALib() 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);
    Response response = createLib(null, "Main Library", "RS", campId);
    assertThat(response.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));
    assertThat(response.getJson().getString("id"), notNullValue());
    assertThat(response.getJson().getString("name"), is("Main Library"));
    assertThat(response.getJson().getString("code"), is("RS"));
}
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