use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemShelvingOrderMigrationServiceApiTest method shouldPopulateShelvingOrder.
@Test
public void shouldPopulateShelvingOrder() throws Exception {
var items = create201Items();
removeShelvingOrder(items);
tenantOp(TENANT_ID, getTenantAttributes());
for (IndividualResource item : items) {
var updatedItem = itemsClient.getById(item.getId());
assertThat(updatedItem.getJson().getString(EFFECTIVE_SHELVING_ORDER), notNullValue());
}
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemStorageTest method canFilterByCallNumberAndSuffix.
@Test
public void canFilterByCallNumberAndSuffix() throws Exception {
final UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
final IndividualResource itemWithWholeCallNumber = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumberPrefix("prefix").withItemLevelCallNumber("callNumber").withItemLevelCallNumberSuffix("suffix").available());
itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumberPrefix("prefix").withItemLevelCallNumber("callNumber").available());
final IndividualResource itemNoPrefix = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("callNumber").withItemLevelCallNumberSuffix("suffix").available());
final List<IndividualResource> foundItems = itemsClient.getMany("callNumberAndSuffix == \"%s\"", "callNumber suffix");
assertThat(foundItems.size(), is(2));
final Set<UUID> allFoundIds = foundItems.stream().map(IndividualResource::getId).collect(Collectors.toSet());
assertThat(allFoundIds, hasItems(itemWithWholeCallNumber.getId(), itemNoPrefix.getId()));
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemStorageTest method canFilterByFullCallNumber.
@Test
public void canFilterByFullCallNumber() throws Exception {
final UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
final IndividualResource itemWithWholeCallNumber = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumberPrefix("prefix").withItemLevelCallNumber("callNumber").withItemLevelCallNumberSuffix("suffix").available());
itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumberPrefix("prefix").withItemLevelCallNumber("callNumber").available());
itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumberPrefix("prefix").withItemLevelCallNumber("differentCallNumber").withItemLevelCallNumberSuffix("suffix").available());
final List<IndividualResource> foundItems = itemsClient.getMany("fullCallNumber == \"%s\"", "prefix callNumber suffix");
assertThat(foundItems.size(), is(1));
assertThat(foundItems.get(0).getId(), is(itemWithWholeCallNumber.getId()));
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemStorageTest method canSearchItemByEffectiveLocation.
@Test
public void canSearchItemByEffectiveLocation() throws Exception {
UUID holdingsWithPermLocation = createInstanceAndHolding(mainLibraryLocationId);
UUID holdingsWithTempLocation = createInstanceAndHolding(mainLibraryLocationId, annexLibraryLocationId);
Item itemWithHoldingPermLocation = buildItem(holdingsWithPermLocation, null, null);
Item itemWithHoldingTempLocation = buildItem(holdingsWithTempLocation, null, null);
Item itemWithTempLocation = buildItem(holdingsWithPermLocation, onlineLocationId, null);
Item itemWithPermLocation = buildItem(holdingsWithTempLocation, null, secondFloorLocationId);
Item itemWithAllLocation = buildItem(holdingsWithTempLocation, secondFloorLocationId, onlineLocationId);
Item[] itemsToCreate = { itemWithHoldingPermLocation, itemWithHoldingTempLocation, itemWithTempLocation, itemWithPermLocation, itemWithAllLocation };
for (Item item : itemsToCreate) {
IndividualResource createdItem = createItem(item);
assertTrue(createdItem.getJson().containsKey("effectiveLocationId"));
}
Items mainLibraryItems = findItems("effectiveLocationId=" + mainLibraryLocationId);
Items annexLibraryItems = findItems("effectiveLocationId=" + annexLibraryLocationId);
Items onlineLibraryItems = findItems("effectiveLocationId=" + onlineLocationId);
Items secondFloorLibraryItems = findItems("effectiveLocationId=" + secondFloorLocationId);
assertEquals(1, mainLibraryItems.getTotalRecords().intValue());
assertThat(mainLibraryItems.getItems().get(0).getId(), is(itemWithHoldingPermLocation.getId()));
assertEquals(1, annexLibraryItems.getTotalRecords().intValue());
assertThat(annexLibraryItems.getItems().get(0).getId(), is(itemWithHoldingTempLocation.getId()));
assertEquals(2, onlineLibraryItems.getTotalRecords().intValue());
assertThat(onlineLibraryItems.getItems().stream().map(Item::getId).collect(Collectors.toList()), hasItems(itemWithTempLocation.getId(), itemWithAllLocation.getId()));
assertEquals(1, secondFloorLibraryItems.getTotalRecords().intValue());
assertThat(secondFloorLibraryItems.getItems().get(0).getId(), is(itemWithPermLocation.getId()));
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemStorageTest method canSearchByDiscoverySuppressProperty.
@Test
public void canSearchByDiscoverySuppressProperty() throws Exception {
final UUID holdingsId = createInstanceAndHolding(mainLibraryLocationId);
final IndividualResource suppressedItem = itemsClient.create(nod(holdingsId).put(DISCOVERY_SUPPRESS, true));
final IndividualResource notSuppressedItem = itemsClient.create(smallAngryPlanet(holdingsId).put(DISCOVERY_SUPPRESS, false));
final IndividualResource notSuppressedItemDefault = itemsClient.create(uprooted(holdingsId));
final List<IndividualResource> suppressedItems = itemsClient.getMany("%s==true", DISCOVERY_SUPPRESS);
final List<IndividualResource> notSuppressedItems = itemsClient.getMany("cql.allRecords=1 not %s==true", DISCOVERY_SUPPRESS);
assertThat(suppressedItems.size(), is(1));
assertThat(suppressedItems.get(0).getId(), is(suppressedItem.getId()));
assertThat(notSuppressedItems.size(), is(2));
assertThat(notSuppressedItems.stream().map(IndividualResource::getId).collect(Collectors.toList()), containsInAnyOrder(notSuppressedItem.getId(), notSuppressedItemDefault.getId()));
}
Aggregations