use of api.support.builders.ItemRequestBuilder in project mod-inventory by folio-org.
the class ItemApiExamples method canChangeBarcodeForExistingItem.
@Test
public void canChangeBarcodeForExistingItem() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
JsonObject nodInstance = createInstance(nod(UUID.randomUUID()));
UUID nodHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(UUID.fromString(nodInstance.getString("id")))).getId();
IndividualResource nodItemResponse = itemsClient.create(new ItemRequestBuilder().forHolding(nodHoldingId).book().canCirculate().withBarcode("654647774352"));
JsonObject changedNodItem = nodItemResponse.getJson().copy().put("barcode", "645398607547");
URL nodItemLocation = new URL(String.format("%s/%s", ApiRoot.items(), nodItemResponse.getId()));
final var putItemCompleted = okapiClient.put(nodItemLocation, changedNodItem);
Response putItemResponse = putItemCompleted.toCompletableFuture().get(5, SECONDS);
assertThat(putItemResponse.getStatusCode(), is(204));
final var getItemCompleted = okapiClient.get(nodItemLocation);
Response getItemResponse = getItemCompleted.toCompletableFuture().get(5, SECONDS);
assertThat(getItemResponse.getStatusCode(), is(200));
assertThat(getItemResponse.getJson().getString("barcode"), is("645398607547"));
}
use of api.support.builders.ItemRequestBuilder in project mod-inventory by folio-org.
the class ItemApiExamples method canCreateMultipleItemsWithoutBarcode.
@Test
public void canCreateMultipleItemsWithoutBarcode() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID holdingId = createInstanceAndHolding();
itemsClient.create(new ItemRequestBuilder().forHolding(holdingId).withNoBarcode());
IndividualResource secondItemResponse = itemsClient.create(new ItemRequestBuilder().forHolding(holdingId).withNoBarcode());
JsonObject createdItem = itemsClient.getById(secondItemResponse.getId()).getJson();
assertThat(createdItem.containsKey("barcode"), is(false));
}
use of api.support.builders.ItemRequestBuilder in project mod-inventory by folio-org.
the class MarkItemInProcessApiTests method shouldChangeRequestBeingFulfilledBackToNotYetFilled.
@Test
@Parameters({ "Open - Awaiting delivery", "Open - Awaiting pickup", "Open - In transit" })
public void shouldChangeRequestBeingFulfilledBackToNotYetFilled(String requestStatus) throws Exception {
final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus(requestStatus.replace("Open - ", "")).canCirculate());
final IndividualResource request = createRequest(createdItem.getId(), requestStatus, DateTime.now(DateTimeZone.UTC).plusHours(1));
assertThat(markItemInProcess(createdItem).getJson(), isInProcess());
assertThat(itemsClient.getById(createdItem.getId()).getJson(), isInProcess());
assertThat(requestStorageClient.getById(request.getId()).getJson(), isOpenNotYetFilled());
}
use of api.support.builders.ItemRequestBuilder in project mod-inventory by folio-org.
the class MarkItemInProcessApiTests method canMarkItemInProcessWhenInAllowedStatus.
@Test
public void canMarkItemInProcessWhenInAllowedStatus() throws Exception {
final String initialStatus = "Aged to lost";
final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus("Available").canCirculate());
final Response response = markItemInProcess(createdItem);
assertEquals(200, response.getStatusCode());
assertThat(response.getJson(), isInProcess());
assertThat(itemsClient.getById(createdItem.getId()).getJson(), isInProcess());
}
use of api.support.builders.ItemRequestBuilder in project mod-inventory by folio-org.
the class MarkItemInProcessNonRequestableApiTests method shouldNotReopenExpiredRequests.
@Test
@Parameters({ "Open - Awaiting delivery", "Open - Awaiting pickup", "Open - In transit" })
public void shouldNotReopenExpiredRequests(String requestStatus) throws Exception {
final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus(requestStatus.replace("Open - ", "")).canCirculate());
final IndividualResource request = createRequest(createdItem.getId(), requestStatus, DateTime.now(DateTimeZone.UTC).minusHours(1));
assertThat(markItemInProcessNonRequestable(createdItem).getJson(), isInProcessNonRequestable());
assertThat(itemsClient.getById(createdItem.getId()).getJson(), isInProcessNonRequestable());
assertThat(requestStorageClient.getById(request.getId()).getJson(), hasStatus(requestStatus));
}
Aggregations