use of org.folio.rest.support.builders.ItemRequestBuilder in project mod-inventory-storage by folio-org.
the class ItemEffectiveCallNumberDataUpgradeTest method canInitializeEffectiveCallNumberTypeId.
@Test
@Parameters(method = "initializeCallNumberTypeParams")
public void canInitializeEffectiveCallNumberTypeId(String itemLevelCallNumberType, String holdingsRecordCallNumberType) throws Exception {
String expectedTypeId = StringUtils.firstNonBlank(itemLevelCallNumberType, holdingsRecordCallNumberType);
UUID holding = createInstanceAndHoldingWithBuilder(mainLibraryLocationId, builder -> builder.withCallNumberTypeId(holdingsRecordCallNumberType));
String itemId = createItem(new ItemRequestBuilder().forHolding(holding).withPermanentLoanType(canCirculateLoanTypeId).withMaterialType(bookMaterialTypeId).withItemLevelCallNumberTypeId(itemLevelCallNumberType)).getId().toString();
removeEffectiveCallNumberComponents(itemId);
runSql(POPULATE_EFFECTIVE_CALL_NUMBER_SQL);
Item populatedItem = getItem(itemId);
assertNotNull(populatedItem.getEffectiveCallNumberComponents());
assertThat(populatedItem.getEffectiveCallNumberComponents().getTypeId(), is(expectedTypeId));
}
use of org.folio.rest.support.builders.ItemRequestBuilder 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.builders.ItemRequestBuilder 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.builders.ItemRequestBuilder in project mod-inventory-storage by folio-org.
the class ItemStorageTest method explicitRightTruncationCanBeApplied.
@Test
public void explicitRightTruncationCanBeApplied() throws Exception {
final UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
final IndividualResource firstItemToMatch = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 2014").available());
final IndividualResource secondItemToMatch = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 2014").withItemLevelCallNumberSuffix("Curriculum Materials Collection").available());
final IndividualResource thirdItemToMatch = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 ").withItemLevelCallNumberSuffix("2014 Curriculum Materials Collection").available());
itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F74 ").withItemLevelCallNumberSuffix("2014 Curriculum Materials Collection").available());
final List<UUID> foundItems = searchByCallNumberEyeReadable("GE77 .F73*");
assertThat(foundItems.size(), is(3));
assertThat(foundItems, hasItems(firstItemToMatch.getId(), secondItemToMatch.getId(), thirdItemToMatch.getId()));
}
use of org.folio.rest.support.builders.ItemRequestBuilder in project mod-inventory-storage by folio-org.
the class ItemStorageTest method cannotCreateItemWithAtLeastOneNonExistentStatisticalCodeId.
@Test
public void cannotCreateItemWithAtLeastOneNonExistentStatisticalCodeId() throws Exception {
final var statisticalCode = statisticalCodeFixture.createSerialManagementCode(new StatisticalCodeBuilder().withCode("stcone").withName("Statistical code 1"));
final UUID nonExistentStatisticalCodeId = UUID.randomUUID();
final UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
final UUID statisticalCodeId = UUID.fromString(statisticalCode.getJson().getString("id"));
final String status = "Available";
final JsonObject itemToCreate = new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withStatus(status).withStatisticalCodeIds(Arrays.asList(statisticalCodeId, nonExistentStatisticalCodeId)).create();
final String itemId = itemToCreate.getString("id");
final Response createdItem = itemsClient.attemptToCreate(itemToCreate);
String expectedMessage = String.format("statistical code doesn't exist: %s foreign key violation in statisticalCodeIds array of item with id=%s", nonExistentStatisticalCodeId.toString(), itemId);
assertThat(createdItem, hasValidationError(expectedMessage, "item", itemId));
}
Aggregations