use of org.folio.rest.support.builders.ItemRequestBuilder in project mod-inventory-storage by folio-org.
the class InventoryHierarchyViewTest method canGetHoldingWhenAllItemForItAreSuppressed.
@Test
public void canGetHoldingWhenAllItemForItAreSuppressed() throws InterruptedException, ExecutionException, TimeoutException {
// given
// one instance, 1 holding with 2 not suppressed items, 1 holding with 1 suppressed item
UUID instanceId = UUID.fromString(predefinedInstance.getString("id"));
UUID holdingId = createHolding(instanceId, mainLibraryLocationId, null);
JsonObject item = new ItemRequestBuilder().forHolding(holdingId).withBarcode("21734").withTemporaryLocation(mainLibraryLocationId).withItemLevelCallNumber("item suppressed call number").withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withDiscoverySuppress(true).create();
super.createItem(item);
// when
params.put(QUERY_PARAM_NAME_SKIP_SUPPRESSED_FROM_DISCOVERY_RECORDS, "true");
JsonObject instancesData = getInventoryHierarchyInstances(params).get(0);
JsonArray holdings = (JsonArray) instancesData.getValue("holdings");
JsonArray items = (JsonArray) instancesData.getValue("items");
// then
assertEquals(2, holdings.getList().size());
assertEquals(2, items.getList().size());
}
use of org.folio.rest.support.builders.ItemRequestBuilder in project mod-inventory-storage by folio-org.
the class ItemCallNumberNormalizedTest method createRecords.
@BeforeClass
public static void createRecords() throws Exception {
final IndividualResource instance = instancesClient.create(smallAngryPlanet(UUID.randomUUID()));
final IndividualResource holdings = holdingsClient.create(new HoldingRequestBuilder().forInstance(instance.getId()).withPermanentLocation(mainLibraryLocationId));
for (String[] callNumberComponents : callNumberData()) {
itemsClient.create(new ItemRequestBuilder().forHolding(holdings.getId()).withPermanentLoanType(canCirculateLoanTypeId).withMaterialType(bookMaterialTypeId).withItemLevelCallNumberPrefix(callNumberComponents[0]).withItemLevelCallNumber(callNumberComponents[1]).withItemLevelCallNumberSuffix(callNumberComponents[2]));
}
}
use of org.folio.rest.support.builders.ItemRequestBuilder in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method canSearchByTitleAndBarcodeWithMissingHoldingsAndItemsAndStillGetInstances.
// This is intended to demonstrate that instances without holdings or items
// are not excluded from searching
@Test
public void canSearchByTitleAndBarcodeWithMissingHoldingsAndItemsAndStillGetInstances() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException, UnsupportedEncodingException {
UUID smallAngryPlanetInstanceId = UUID.randomUUID();
UUID mainLibrarySmallAngryHoldingId = UUID.randomUUID();
createInstance(smallAngryPlanet(smallAngryPlanetInstanceId));
createHoldings(new HoldingRequestBuilder().withId(mainLibrarySmallAngryHoldingId).withPermanentLocation(mainLibraryLocationId).forInstance(smallAngryPlanetInstanceId).create());
createItem(new ItemRequestBuilder().forHolding(mainLibrarySmallAngryHoldingId).withBarcode("706949453641").withPermanentLoanType(canCirculateLoanTypeId).withMaterialType(bookMaterialTypeId).create());
UUID nodInstanceId = UUID.randomUUID();
createInstance(nod(nodInstanceId));
CompletableFuture<Response> searchCompleted = new CompletableFuture<>();
String url = instancesStorageUrl("").toString() + "?query=" + urlEncode("item.barcode=706949453641* or title=Nod*");
client.get(url, TENANT_ID, json(searchCompleted));
Response searchResponse = searchCompleted.get(5, SECONDS);
assertThat(searchResponse.getStatusCode(), is(200));
JsonObject responseBody = searchResponse.getJson();
assertThat(responseBody.getInteger(TOTAL_RECORDS_KEY), is(2));
List<JsonObject> foundInstances = JsonArrayHelper.toList(responseBody.getJsonArray(INSTANCES_KEY));
assertThat(foundInstances.size(), is(2));
Optional<JsonObject> firstInstance = foundInstances.stream().filter(instance -> instance.getString("id").equals(smallAngryPlanetInstanceId.toString())).findFirst();
Optional<JsonObject> secondInstance = foundInstances.stream().filter(instance -> instance.getString("id").equals(nodInstanceId.toString())).findFirst();
assertThat("Instance with barcode should be found", firstInstance.isPresent(), is(true));
assertThat("Instance with title and no holding or items, should be found", secondInstance.isPresent(), is(true));
}
use of org.folio.rest.support.builders.ItemRequestBuilder in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method canSearchByBarcode.
@Test
public void canSearchByBarcode() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID expectedInstanceId = UUID.randomUUID();
UUID expectedHoldingId = UUID.randomUUID();
createInstance(smallAngryPlanet(expectedInstanceId));
createHoldings(new HoldingRequestBuilder().withId(expectedHoldingId).withPermanentLocation(mainLibraryLocationId).forInstance(expectedInstanceId).create());
createItem(new ItemRequestBuilder().forHolding(expectedHoldingId).withBarcode("706949453641").withPermanentLoanType(canCirculateLoanTypeId).withMaterialType(bookMaterialTypeId).create());
UUID otherInstanceId = UUID.randomUUID();
UUID otherHoldingId = UUID.randomUUID();
createInstance(nod(otherInstanceId));
createHoldings(new HoldingRequestBuilder().withId(otherHoldingId).forInstance(otherInstanceId).withPermanentLocation(mainLibraryLocationId).create());
createItem(new ItemRequestBuilder().forHolding(expectedHoldingId).withMaterialType(bookMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withBarcode("766043059304").create());
// Use == as exact match is intended for barcode
canSort("item.barcode==706949453641", "Long Way to a Small Angry Planet");
}
Aggregations