use of org.folio.rest.support.builders.StaffSlipRequestBuilder in project mod-circulation-storage by folio-org.
the class StaffSlipsApiTest method canDeleteSlipById.
@Test
public void canDeleteSlipById() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
UUID slipId = UUID.randomUUID();
makeStaffSlip(new StaffSlipRequestBuilder().withId(slipId).withName(TEST_STAFF_SLIP_1_NAME).withDescription(TEST_STAFF_SLIP_1_DESCRIPTION).withTemplate(TEST_STAFF_SLIP_1_Template).create());
CompletableFuture<Response> deleteCompleted = new CompletableFuture<>();
client.delete(staffSlipsStorageUrl("/" + slipId), StorageTestSuite.TENANT_ID, ResponseHandler.empty(deleteCompleted));
Response deleteReponse = deleteCompleted.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(deleteReponse.getStatusCode(), is(HttpURLConnection.HTTP_NO_CONTENT));
assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_NOT_FOUND));
}
use of org.folio.rest.support.builders.StaffSlipRequestBuilder in project mod-circulation-storage by folio-org.
the class StaffSlipsApiTest method canQueryStaffSlip.
@Test
public void canQueryStaffSlip() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonResponse creationResponse = makeStaffSlip(new StaffSlipRequestBuilder().create());
CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
String slipId = creationResponse.getJson().getString(ID_KEY);
URL path = staffSlipsStorageUrl("?query=" + URLEncoder.encode(String.format("%s==\"%s\"", ID_KEY, slipId), UTF_8));
client.get(path, StorageTestSuite.TENANT_ID, ResponseHandler.json(getCompleted));
JsonResponse getResponse = getCompleted.get(10, TimeUnit.SECONDS);
assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonArray slipsJsonArray = getResponse.getJson().getJsonArray("staffSlips");
assertThat(slipsJsonArray.getJsonObject(0).getString(ID_KEY), is(slipId));
}
use of org.folio.rest.support.builders.StaffSlipRequestBuilder in project mod-circulation-storage by folio-org.
the class StaffSlipsApiTest method canCreateAnInactiveStaffSlip.
@Test
public void canCreateAnInactiveStaffSlip() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonResponse creationResponse = makeStaffSlip(new StaffSlipRequestBuilder().withActive(false).create());
assertThat(creationResponse.getJson().getBoolean(ACTIVE_KEY), is(false));
}
use of org.folio.rest.support.builders.StaffSlipRequestBuilder in project mod-circulation-storage by folio-org.
the class StaffSlipsApiTest method cannotCreateStaffSlipWithDuplicateName.
@Test
public void cannotCreateStaffSlipWithDuplicateName() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
makeStaffSlip(new StaffSlipRequestBuilder().withName(TEST_STAFF_SLIP_1_NAME).create());
JsonResponse creationAttemptResponse = makeStaffSlip(new StaffSlipRequestBuilder().withName(TEST_STAFF_SLIP_1_NAME).create());
assertThat(creationAttemptResponse, isBadRequest());
}
use of org.folio.rest.support.builders.StaffSlipRequestBuilder in project mod-circulation-storage by folio-org.
the class StaffSlipsApiTest method cannotCreateAStaffSlipWithoutAName.
@Test
public void cannotCreateAStaffSlipWithoutAName() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonResponse creationResponse = makeStaffSlip(new StaffSlipRequestBuilder().withName(null).create());
assertThat(String.format("Creating the loan should fail: %s", creationResponse.getBody()), creationResponse, isUnprocessableEntity());
}
Aggregations