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));
}
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));
}
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));
}
Aggregations