use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class BoundWithStorageTest method canChangeOnePartOfABoundWith.
@Test
public void canChangeOnePartOfABoundWith() {
FakeKafkaConsumer.removeAllEvents();
IndividualResource instance1 = createInstance("Instance 1");
IndividualResource holdingsRecord1 = createHoldingsRecord(instance1.getId());
IndividualResource instance2 = createInstance("Instance 2");
IndividualResource holdingsRecord2 = createHoldingsRecord(instance2.getId());
IndividualResource item = createItem(holdingsRecord1.getId());
boundWithPartsClient.create(createBoundWithPartJson(holdingsRecord1.getId(), item.getId()));
IndividualResource part2Created = boundWithPartsClient.create(createBoundWithPartJson(holdingsRecord2.getId(), item.getId()));
List<JsonObject> getAllPartsForBoundWithItem = boundWithPartsClient.getByQuery("?query=itemId==" + item.getId());
List<JsonObject> part2 = boundWithPartsClient.getByQuery("?query=holdingsRecordId==" + holdingsRecord2.getId() + "");
IndividualResource instance3 = createInstance("Instance 3");
IndividualResource holdingsRecord3 = createHoldingsRecord(instance3.getId());
Response updateResponse = boundWithPartsClient.attemptToReplace(part2Created.getId(), createBoundWithPartJson(holdingsRecord3.getId(), item.getId()));
List<JsonObject> getAllPartsForBoundWithItemAgain = boundWithPartsClient.getByQuery("?query=itemId==" + item.getId());
List<JsonObject> oldPart2Gone = boundWithPartsClient.getByQuery("?query=holdingsRecordId==" + holdingsRecord2.getId());
List<JsonObject> newPart2 = boundWithPartsClient.getByQuery("?query=holdingsRecordId==" + holdingsRecord3.getId());
assertThat(getAllPartsForBoundWithItem.size(), is(2));
assertThat(part2.toString(), part2.size(), is(1));
assertThat(updateResponse.getStatusCode(), is(HttpURLConnection.HTTP_NO_CONTENT));
assertThat(getAllPartsForBoundWithItemAgain.size(), is(2));
assertThat(oldPart2Gone.size(), is(0));
assertThat(newPart2.size(), is(1));
await().atMost(10, TimeUnit.SECONDS).until(() -> FakeKafkaConsumer.getAllPublishedBoundWithIdsCount() == 3);
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemEffectiveLocationTest method canCalculateEffectiveLocationOnHoldingRemoveTempLocationShouldBeHoldingPermLocation.
@Test
public void canCalculateEffectiveLocationOnHoldingRemoveTempLocationShouldBeHoldingPermLocation() throws Exception {
UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId, annexLibraryLocationId);
final Item[] itemsToCreate = { buildItem(holdingsRecordId, null, null), buildItem(holdingsRecordId, null, null), buildItem(holdingsRecordId, null, null) };
for (Item item : itemsToCreate) {
IndividualResource createdItem = createItem(item);
assertTrue(createdItem.getJson().containsKey("effectiveLocationId"));
}
JsonObject holding = holdingsClient.getById(holdingsRecordId).getJson();
holding.remove("temporaryLocationId");
holdingsClient.replace(holdingsRecordId, holding);
for (Item item : itemsToCreate) {
Item fetchedItem = getItem(item.getId());
assertEquals(fetchedItem.toString(), fetchedItem.getEffectiveLocationId(), mainLibraryLocationId.toString());
}
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemShelvingOrderMigrationServiceApiTest method removeShelvingOrder.
private void removeShelvingOrder(List<IndividualResource> items) throws Exception {
for (IndividualResource item : items) {
unsetJsonbProperty("item", item.getId(), EFFECTIVE_SHELVING_ORDER);
assertThat(itemsClient.getById(item.getId()).getJson().getJsonObject(EFFECTIVE_SHELVING_ORDER), nullValue());
}
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemStorageTest method canCreateItemWithAllAllowedStatuses.
@Test
@Parameters({ "Aged to lost", "Available", "Awaiting pickup", "Awaiting delivery", "Checked out", "Claimed returned", "Declared lost", "In process", "In process (non-requestable)", "In transit", "Intellectual item", "Long missing", "Lost and paid", "Missing", "On order", "Paged", "Restricted", "Order closed", "Unavailable", "Unknown", "Withdrawn" })
public void canCreateItemWithAllAllowedStatuses(String status) throws Exception {
final UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
final ItemRequestBuilder itemToCreate = new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withStatus(status);
final IndividualResource createdItem = itemsClient.create(itemToCreate);
assertThat(createdItem.getJson().getJsonObject("status").getString("name"), is(status));
JsonObject itemInStorage = itemsClient.getById(createdItem.getId()).getJson();
assertThat(itemInStorage.getJsonObject("status").getString("name"), is(status));
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemStorageTest method canSearchByPurchaseOrderLineIdentifierProperty.
@Test
public void canSearchByPurchaseOrderLineIdentifierProperty() throws Exception {
final UUID holdingsId = createInstanceAndHolding(mainLibraryLocationId);
final IndividualResource firstItem = itemsClient.create(smallAngryPlanet(holdingsId).put("purchaseOrderLineIdentifier", "poli-1"));
itemsClient.create(nod(holdingsId).put("purchaseOrderLineIdentifier", "poli-2"));
final List<IndividualResource> poli1Items = itemsClient.getMany("purchaseOrderLineIdentifier==\"poli-1\"");
assertThat(poli1Items.size(), is(1));
assertThat(poli1Items.get(0).getId(), is(firstItem.getId()));
}
Aggregations