use of org.folio.inventory.domain.items.Item in project mod-inventory by folio-org.
the class ExternalItemCollectionExamples method anItemCanBeFoundById.
@Test
public void anItemCanBeFoundById() throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<Item> firstAddFuture = new CompletableFuture<>();
CompletableFuture<Item> secondAddFuture = new CompletableFuture<>();
collection.add(smallAngryPlanet, succeed(firstAddFuture), fail(firstAddFuture));
collection.add(nod, succeed(secondAddFuture), fail(secondAddFuture));
Item addedItem = getOnCompletion(firstAddFuture);
Item otherAddedItem = getOnCompletion(secondAddFuture);
CompletableFuture<Item> findFuture = new CompletableFuture<>();
CompletableFuture<Item> otherFindFuture = new CompletableFuture<>();
collection.findById(addedItem.id, succeed(findFuture), fail(findFuture));
collection.findById(otherAddedItem.id, succeed(otherFindFuture), fail(otherFindFuture));
Item foundItem = getOnCompletion(findFuture);
Item otherFoundItem = getOnCompletion(otherFindFuture);
assertThat(foundItem, notNullValue());
assertThat(foundItem.getBarcode(), is("036000291452"));
assertThat(foundItem.getStatus().getName(), is(ItemStatusName.AVAILABLE));
assertThat(foundItem.getMaterialTypeId(), is(bookMaterialTypeId));
assertThat(foundItem.getPermanentLoanTypeId(), is(canCirculateLoanTypeId));
assertThat(foundItem.getTemporaryLocationId(), is(annexLibraryLocationId));
assertThat(otherFoundItem, notNullValue());
assertThat(otherFoundItem.getBarcode(), is("565578437802"));
assertThat(otherFoundItem.getStatus().getName(), is(ItemStatusName.AVAILABLE));
assertThat(otherFoundItem.getMaterialTypeId(), is(bookMaterialTypeId));
assertThat(otherFoundItem.getPermanentLoanTypeId(), is(canCirculateLoanTypeId));
assertThat(otherFoundItem.getTemporaryLocationId(), is(annexLibraryLocationId));
}
use of org.folio.inventory.domain.items.Item in project mod-inventory by folio-org.
the class ExternalItemCollectionExamples method allItemsCanBePaged.
@Test
public void allItemsCanBePaged() throws InterruptedException, ExecutionException, TimeoutException {
WaitForAllFutures<Item> allAdded = new WaitForAllFutures<>();
collection.add(smallAngryPlanet, allAdded.notifySuccess(), v -> {
});
collection.add(nod, allAdded.notifySuccess(), v -> {
});
collection.add(uprooted, allAdded.notifySuccess(), v -> {
});
collection.add(temeraire, allAdded.notifySuccess(), v -> {
});
collection.add(interestingTimes, allAdded.notifySuccess(), v -> {
});
allAdded.waitForCompletion();
CompletableFuture<MultipleRecords<Item>> firstPageFuture = new CompletableFuture<>();
CompletableFuture<MultipleRecords<Item>> secondPageFuture = new CompletableFuture<>();
collection.findAll(new PagingParameters(3, 0), succeed(firstPageFuture), fail(secondPageFuture));
collection.findAll(new PagingParameters(3, 3), succeed(secondPageFuture), fail(secondPageFuture));
MultipleRecords<Item> firstPage = getOnCompletion(firstPageFuture);
MultipleRecords<Item> secondPage = getOnCompletion(secondPageFuture);
assertThat(firstPage.records.size(), is(3));
assertThat(secondPage.records.size(), is(2));
assertThat(firstPage.totalRecords, is(5));
assertThat(secondPage.totalRecords, is(5));
}
use of org.folio.inventory.domain.items.Item in project mod-inventory by folio-org.
the class ExternalItemCollectionExamples method anItemCanBeAddedWithAnId.
@Test
public void anItemCanBeAddedWithAnId() throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<Item> addFinished = new CompletableFuture<>();
String itemId = UUID.randomUUID().toString();
Item itemWithId = smallAngryPlanet.copyWithNewId(itemId);
collection.add(itemWithId, succeed(addFinished), fail(addFinished));
Item added = getOnCompletion(addFinished);
assertThat(added.id, is(itemId));
}
use of org.folio.inventory.domain.items.Item in project mod-inventory by folio-org.
the class ExternalItemCollectionExamples method itemsCanBeFoundByBarcode.
@Test
public void itemsCanBeFoundByBarcode() throws InterruptedException, ExecutionException, TimeoutException, UnsupportedEncodingException {
CompletableFuture<Item> firstAddFuture = new CompletableFuture<>();
CompletableFuture<Item> secondAddFuture = new CompletableFuture<>();
CompletableFuture<Item> thirdAddFuture = new CompletableFuture<>();
collection.add(smallAngryPlanet, succeed(firstAddFuture), fail(firstAddFuture));
collection.add(nod, succeed(secondAddFuture), fail(secondAddFuture));
collection.add(uprooted, succeed(thirdAddFuture), fail(thirdAddFuture));
CompletableFuture<Void> allAddsFuture = CompletableFuture.allOf(firstAddFuture, secondAddFuture, thirdAddFuture);
getOnCompletion(allAddsFuture);
Item addedSmallAngryPlanet = getOnCompletion(firstAddFuture);
CompletableFuture<MultipleRecords<Item>> findFuture = new CompletableFuture<>();
collection.findByCql("barcode==036000291452", new PagingParameters(10, 0), succeed(findFuture), fail(findFuture));
MultipleRecords<Item> wrappedItems = getOnCompletion(findFuture);
assertThat(wrappedItems.records.size(), is(1));
assertThat(wrappedItems.totalRecords, is(1));
assertThat(wrappedItems.records.stream().findFirst().get().id, is(addedSmallAngryPlanet.id));
}
use of org.folio.inventory.domain.items.Item in project mod-inventory by folio-org.
the class InProcessItemStatusValidatorTest method itemCanBeMarkedAsInProcessWhenInAcceptableSourceStatus.
@SneakyThrows
@Parameters({ "Aged to lost", "Available", "Awaiting pickup", "Awaiting delivery", "Checked out", "Claimed returned", "Declared lost", "In process (non-requestable)", "In transit", "Intellectual item", "Long missing", "Lost and paid", "Missing", "On order", "Order closed", "Paged", "Restricted", "Unavailable", "Unknown", "Withdrawn" })
@Test
public void itemCanBeMarkedAsInProcessWhenInAcceptableSourceStatus(String sourceStatus) {
final var targetValidator = validators.getValidator(IN_PROCESS);
final var item = new Item(null, null, null, new Status(ItemStatusName.forName(sourceStatus)), null, null, null);
final var validationFuture = targetValidator.refuseItemWhenNotInAcceptableSourceStatus(item);
validationFuture.get(1, TimeUnit.SECONDS);
// Validator responds with a successful future when valid
assertThat(validationFuture.isDone()).isTrue();
}
Aggregations