use of api.ApiTestSuite.getCanCirculateLoanType in project mod-inventory by folio-org.
the class ItemApiExamples method CanGetAllItemsWithDifferentTemporaryLoanType.
@Test
public void CanGetAllItemsWithDifferentTemporaryLoanType() 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"));
itemsClient.create(new ItemRequestBuilder().forHolding(smallAngryHoldingId).book().canCirculate().temporarilyCourseReserves().withBarcode("175848607547"));
final var getAllCompleted = okapiClient.get(ApiRoot.items());
Response getAllResponse = getAllCompleted.toCompletableFuture().get(5, SECONDS);
assertThat(getAllResponse.getStatusCode(), is(200));
List<JsonObject> items = JsonArrayHelper.toList(getAllResponse.getJson().getJsonArray("items"));
assertThat(items.size(), is(2));
assertThat(getAllResponse.getJson().getInteger("totalRecords"), is(2));
assertThat(items.stream().filter(item -> StringUtils.equals(item.getString("barcode"), "645398607547")).findFirst().orElse(new JsonObject()).getJsonObject("permanentLoanType").getString("id"), is(ApiTestSuite.getCanCirculateLoanType()));
assertThat(items.stream().filter(item -> StringUtils.equals(item.getString("barcode"), "645398607547")).findFirst().orElse(new JsonObject()).containsKey("temporaryLoanType"), is(false));
assertThat(items.stream().filter(item -> StringUtils.equals(item.getString("barcode"), "175848607547")).findFirst().orElse(new JsonObject()).getJsonObject("permanentLoanType").getString("id"), is(ApiTestSuite.getCanCirculateLoanType()));
assertThat(items.stream().filter(item -> StringUtils.equals(item.getString("barcode"), "175848607547")).findFirst().orElse(new JsonObject()).getJsonObject("temporaryLoanType").getString("id"), is(ApiTestSuite.getCourseReserveLoanType()));
items.forEach(ItemApiExamples::hasConsistentPermanentLoanType);
items.forEach(ItemApiExamples::hasConsistentTemporaryLoanType);
items.forEach(ItemApiExamples::hasConsistentPermanentLocation);
items.forEach(ItemApiExamples::hasConsistentTemporaryLocation);
}
Aggregations