use of api.support.builders.HoldingRequestBuilder in project mod-inventory by folio-org.
the class ItemApiTitleExamples method noTitleWhenHoldingOrInstanceNotFound.
@Ignore("mod-inventory-storage disallows this scenario, change to be isolated test")
@Test
public void noTitleWhenHoldingOrInstanceNotFound() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID firstInstanceId = instancesClient.create(InstanceRequestExamples.smallAngryPlanet()).getId();
UUID firstHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(firstInstanceId).create()).getId();
UUID firstItemId = itemsClient.create(ItemRequestExamples.basedUponSmallAngryPlanet().forHolding(firstHoldingId)).getId();
UUID secondInstanceId = instancesClient.create(InstanceRequestExamples.temeraire()).getId();
UUID secondHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(secondInstanceId).create()).getId();
UUID secondItemId = itemsClient.create(ItemRequestExamples.basedUponTemeraire().forHolding(secondHoldingId)).getId();
// Delete instance or holding
instancesClient.delete(firstInstanceId);
holdingsStorageClient.delete(secondHoldingId);
List<JsonObject> fetchedItemsResponse = itemsClient.getAll();
assertThat(fetchedItemsResponse.size(), is(2));
JsonObject firstFetchedItem = getRecordById(fetchedItemsResponse, firstItemId).orElse(new JsonObject());
assertThat("has no title", firstFetchedItem.containsKey("title"), is(false));
JsonObject secondFetchedItem = getRecordById(fetchedItemsResponse, secondItemId).orElse(new JsonObject());
assertThat("has no title", secondFetchedItem.containsKey("title"), is(false));
}
use of api.support.builders.HoldingRequestBuilder in project mod-inventory by folio-org.
the class ItemApiTitleExamples method titlesComeFromInstancesForMultipleMultipleItems.
@Test
public void titlesComeFromInstancesForMultipleMultipleItems() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID firstInstanceId = instancesClient.create(InstanceRequestExamples.smallAngryPlanet()).getId();
UUID firstHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(firstInstanceId)).getId();
UUID firstItemId = itemsClient.create(ItemRequestExamples.basedUponSmallAngryPlanet().forHolding(firstHoldingId)).getId();
UUID secondInstanceId = instancesClient.create(InstanceRequestExamples.temeraire()).getId();
UUID secondHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(secondInstanceId)).getId();
UUID secondItemId = itemsClient.create(ItemRequestExamples.basedUponTemeraire().forHolding(secondHoldingId)).getId();
List<JsonObject> fetchedItemsResponse = itemsClient.getAll();
assertThat(fetchedItemsResponse.size(), is(2));
JsonObject firstFetchedItem = getRecordById(fetchedItemsResponse, firstItemId).orElse(new JsonObject());
assertThat("has title from instance", firstFetchedItem.getString("title"), is("The Long Way to a Small, Angry Planet"));
JsonObject secondFetchedItem = getRecordById(fetchedItemsResponse, secondItemId).orElse(new JsonObject());
assertThat("has title from instance", secondFetchedItem.getString("title"), is("Temeraire"));
}
use of api.support.builders.HoldingRequestBuilder in project mod-inventory by folio-org.
the class ItemApiExamples method canDeleteAllItems.
@Test
public void canDeleteAllItems() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
JsonObject createdInstance = createInstance(smallAngryPlanet(UUID.randomUUID()));
UUID holdingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(UUID.fromString(createdInstance.getString("id")))).getId();
itemsClient.create(new ItemRequestBuilder().forHolding(holdingId).withBarcode("645398607547"));
itemsClient.create(new ItemRequestBuilder().forHolding(holdingId).withBarcode("175848607547"));
itemsClient.create(new ItemRequestBuilder().forHolding(holdingId).withBarcode("645334645247"));
itemsClient.deleteAll();
final var getAllCompleted = okapiClient.get(ApiRoot.items());
Response getAllResponse = getAllCompleted.toCompletableFuture().get(5, SECONDS);
assertThat(getAllResponse.getJson().getJsonArray("items").size(), is(0));
assertThat(getAllResponse.getJson().getInteger("totalRecords"), is(0));
}
use of api.support.builders.HoldingRequestBuilder in project mod-inventory by folio-org.
the class ItemApiExamples method cannotCreateSecondItemWithSameBarcode.
@Test
public void cannotCreateSecondItemWithSameBarcode() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
JsonObject smallAngryInstance = createInstance(smallAngryPlanet(UUID.randomUUID()));
UUID smallAngryHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(UUID.fromString(smallAngryInstance.getString("id")))).getId();
itemsClient.create(new ItemRequestBuilder().forHolding(smallAngryHoldingId).book().canCirculate().withBarcode("645398607547"));
JsonObject nodInstance = createInstance(nod(UUID.randomUUID()));
UUID nodHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(UUID.fromString(nodInstance.getString("id")))).getId();
JsonObject sameBarcodeItemRequest = new ItemRequestBuilder().forHolding(nodHoldingId).book().canCirculate().withBarcode("645398607547").create();
final var createItemCompleted = okapiClient.post(ApiRoot.items(), sameBarcodeItemRequest);
Response sameBarcodeCreateResponse = createItemCompleted.toCompletableFuture().get(5, SECONDS);
assertThat(sameBarcodeCreateResponse.getStatusCode(), is(400));
assertThat(sameBarcodeCreateResponse.getBody(), is("Barcode must be unique, 645398607547 is already assigned to another item"));
}
use of api.support.builders.HoldingRequestBuilder in project mod-inventory by folio-org.
the class MarkItemMissingApiTests method createInstanceAndHoldingsRecord.
@Before
public void createInstanceAndHoldingsRecord() throws Exception {
final IndividualResource instance = instancesClient.create(smallAngryPlanet(UUID.randomUUID()));
holdingsRecord = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(instance.getId()));
}
Aggregations