use of api.support.builders.ItemRequestBuilder in project mod-inventory by folio-org.
the class BoundWithTests method boundWithTitlesArePresentInBoundWithItem.
@Test
public void boundWithTitlesArePresentInBoundWithItem() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
IndividualResource instance1 = instancesStorageClient.create(InstanceSamples.smallAngryPlanet(UUID.randomUUID()));
IndividualResource holdings1a = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(instance1.getId()).permanentlyInMainLibrary().withCallNumber("HOLDINGS 1A"));
IndividualResource item1a = itemsClient.create(new ItemRequestBuilder().forHolding(holdings1a.getId()).withBarcode("ITEM 1A"));
IndividualResource instance2 = instancesStorageClient.create(InstanceSamples.girlOnTheTrain(UUID.randomUUID()));
IndividualResource holdings2a = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(instance2.getId()).permanentlyInMainLibrary().withCallNumber("HOLDINGS 2A"));
IndividualResource instance3 = instancesStorageClient.create(InstanceSamples.leviathanWakes(UUID.randomUUID()));
IndividualResource holdings3a = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(instance3.getId()).permanentlyInMainLibrary().withCallNumber("HOLDINGS 3A"));
boundWithPartsStorageClient.create(makeObjectBoundWithPart(item1a.getJson().getString("id"), holdings1a.getJson().getString("id")));
boundWithPartsStorageClient.create(makeObjectBoundWithPart(item1a.getJson().getString("id"), holdings2a.getJson().getString("id")));
boundWithPartsStorageClient.create(makeObjectBoundWithPart(item1a.getJson().getString("id"), holdings3a.getJson().getString("id")));
Response itemResponse = okapiClient.get(ApiTestSuite.apiRoot() + "/inventory/items/" + item1a.getId()).toCompletableFuture().get(5, SECONDS);
assertThat("Item has boundWithTitles array with three titles", itemResponse.getJson().getJsonArray("boundWithTitles").size(), is(3));
}
Aggregations