Search in sources :

Example 56 with IndividualResource

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

Example 57 with IndividualResource

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

Example 58 with IndividualResource

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

Example 59 with IndividualResource

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()));
}
Also used : CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) DomainEventAssertions.assertUpdateEventForItem(org.folio.rest.support.matchers.DomainEventAssertions.assertUpdateEventForItem) DomainEventAssertions.assertCreateEventForItem(org.folio.rest.support.matchers.DomainEventAssertions.assertCreateEventForItem) Item(org.folio.rest.jaxrs.model.Item) DomainEventAssertions.assertRemoveAllEventForItem(org.folio.rest.support.matchers.DomainEventAssertions.assertRemoveAllEventForItem) DomainEventAssertions.assertRemoveEventForItem(org.folio.rest.support.matchers.DomainEventAssertions.assertRemoveEventForItem) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) Items(org.folio.rest.jaxrs.model.Items) UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 60 with IndividualResource

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

Aggregations

IndividualResource (org.folio.rest.support.IndividualResource)89 Test (org.junit.Test)73 JsonObject (io.vertx.core.json.JsonObject)44 UUID (java.util.UUID)37 Response (org.folio.rest.support.Response)20 CompletableFuture (java.util.concurrent.CompletableFuture)19 JsonArray (io.vertx.core.json.JsonArray)17 JsonResponse (org.folio.rest.support.JsonResponse)17 LoanRequestBuilder (org.folio.rest.support.builders.LoanRequestBuilder)17 DateTime (org.joda.time.DateTime)12 PrecedingSucceedingTitle (org.folio.rest.api.entities.PrecedingSucceedingTitle)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 TextResponse (org.folio.rest.support.TextResponse)7 ItemRequestBuilder (org.folio.rest.support.builders.ItemRequestBuilder)7 InstancesBatchResponse (org.folio.rest.jaxrs.model.InstancesBatchResponse)6 JsonErrorResponse (org.folio.rest.support.JsonErrorResponse)6 TRUE (java.lang.Boolean.TRUE)4 HttpURLConnection (java.net.HttpURLConnection)4 MalformedURLException (java.net.MalformedURLException)4 DateFormat (java.text.DateFormat)4