Search in sources :

Example 6 with StaffSlipRequestBuilder

use of org.folio.rest.support.builders.StaffSlipRequestBuilder in project mod-circulation-storage by folio-org.

the class StaffSlipsApiTest method canCreateAStaffSlip.

/* Begin Tests */
@Test
public void canCreateAStaffSlip() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    JsonResponse creationResponse = makeStaffSlip(new StaffSlipRequestBuilder().withName(TEST_STAFF_SLIP_1_NAME).withDescription(TEST_STAFF_SLIP_1_DESCRIPTION).withTemplate(TEST_STAFF_SLIP_1_Template).create());
    assertThat(creationResponse.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));
    assertThat(creationResponse.getJson().getString(ID_KEY), notNullValue());
    assertThat(creationResponse.getJson().getBoolean(ACTIVE_KEY), is(true));
    assertThat(creationResponse.getJson().getString(NAME_KEY), is(TEST_STAFF_SLIP_1_NAME));
    assertThat(creationResponse.getJson().getString(DESCRIPTON_KEY), is(TEST_STAFF_SLIP_1_DESCRIPTION));
    assertThat(creationResponse.getJson().getString(TEMPLATE_KEY), is(TEST_STAFF_SLIP_1_Template));
}
Also used : StaffSlipRequestBuilder(org.folio.rest.support.builders.StaffSlipRequestBuilder) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 7 with StaffSlipRequestBuilder

use of org.folio.rest.support.builders.StaffSlipRequestBuilder in project mod-circulation-storage by folio-org.

the class StaffSlipsApiTest method canUpdateStaffSlipById.

@Test
public void canUpdateStaffSlipById() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    UUID slipId = UUID.randomUUID();
    JsonResponse creationResponse = makeStaffSlip(new StaffSlipRequestBuilder().withId(slipId).withName(TEST_STAFF_SLIP_1_NAME).withDescription(TEST_STAFF_SLIP_1_DESCRIPTION).withTemplate(TEST_STAFF_SLIP_1_Template).create());
    assertThat(String.format("%s", creationResponse.getBody()), creationResponse.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));
    CompletableFuture<Response> putCompleted = new CompletableFuture<>();
    JsonObject updatedSlip = new StaffSlipRequestBuilder().withId(slipId).withName(TEST_STAFF_SLIP_1_NAME).withDescription(TEST_STAFF_SLIP_1_DESCRIPTION_ALTERNATE).create();
    client.put(staffSlipsStorageUrl("/" + slipId), updatedSlip, StorageTestSuite.TENANT_ID, ResponseHandler.empty(putCompleted));
    Response putReponse = putCompleted.get(5, TimeUnit.SECONDS);
    CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
    client.get(staffSlipsStorageUrl("/" + slipId), StorageTestSuite.TENANT_ID, ResponseHandler.json(getCompleted));
    JsonResponse getResponse = getCompleted.get(5, TimeUnit.SECONDS);
    assertThat(putReponse.getStatusCode(), is(HttpURLConnection.HTTP_NO_CONTENT));
    assertThat(getResponse.getJson().getString(DESCRIPTON_KEY), is(TEST_STAFF_SLIP_1_DESCRIPTION_ALTERNATE));
}
Also used : JsonResponse(org.folio.rest.support.JsonResponse) Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) StaffSlipRequestBuilder(org.folio.rest.support.builders.StaffSlipRequestBuilder) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 8 with StaffSlipRequestBuilder

use of org.folio.rest.support.builders.StaffSlipRequestBuilder in project mod-circulation-storage by folio-org.

the class StaffSlipsApiTest method canGetStaffSlipById.

@Test
public void canGetStaffSlipById() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    JsonResponse creationResponse = makeStaffSlip(new StaffSlipRequestBuilder().create());
    CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
    String slipId = creationResponse.getJson().getString(ID_KEY);
    client.get(staffSlipsStorageUrl("/" + slipId), StorageTestSuite.TENANT_ID, ResponseHandler.json(getCompleted));
    JsonResponse getResponse = getCompleted.get(5, TimeUnit.SECONDS);
    assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
    assertThat(getResponse.getJson().getString(ID_KEY), is(slipId));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) StaffSlipRequestBuilder(org.folio.rest.support.builders.StaffSlipRequestBuilder) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Aggregations

JsonResponse (org.folio.rest.support.JsonResponse)8 StaffSlipRequestBuilder (org.folio.rest.support.builders.StaffSlipRequestBuilder)8 Test (org.junit.Test)8 CompletableFuture (java.util.concurrent.CompletableFuture)4 UUID (java.util.UUID)2 Response (org.folio.rest.support.Response)2 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 URL (java.net.URL)1