Search in sources :

Example 11 with ItemRequestBuilder

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));
}
Also used : Item(org.folio.rest.jaxrs.model.Item) UUID(java.util.UUID) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 12 with ItemRequestBuilder

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()));
}
Also used : UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder) Test(org.junit.Test)

Example 13 with ItemRequestBuilder

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()));
}
Also used : UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder) Test(org.junit.Test)

Example 14 with ItemRequestBuilder

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()));
}
Also used : UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder) Test(org.junit.Test)

Example 15 with ItemRequestBuilder

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));
}
Also used : Response(org.folio.rest.support.Response) JsonErrorResponse(org.folio.rest.support.JsonErrorResponse) StatisticalCodeBuilder(org.folio.rest.support.builders.StatisticalCodeBuilder) JsonObject(io.vertx.core.json.JsonObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) UUID(java.util.UUID) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder) Test(org.junit.Test)

Aggregations

ItemRequestBuilder (org.folio.rest.support.builders.ItemRequestBuilder)19 UUID (java.util.UUID)17 Test (org.junit.Test)17 JsonObject (io.vertx.core.json.JsonObject)10 IndividualResource (org.folio.rest.support.IndividualResource)8 Response (org.folio.rest.support.Response)6 HoldingRequestBuilder (org.folio.rest.support.builders.HoldingRequestBuilder)6 JsonErrorResponse (org.folio.rest.support.JsonErrorResponse)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 JsonArray (io.vertx.core.json.JsonArray)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Parameters (junitparams.Parameters)2 StatisticalCodeBuilder (org.folio.rest.support.builders.StatisticalCodeBuilder)2 Vertx (io.vertx.core.Vertx)1 Async (io.vertx.ext.unit.Async)1 TestContext (io.vertx.ext.unit.TestContext)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 IOException (java.io.IOException)1