Search in sources :

Example 36 with IndividualResource

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);
}
Also used : Response(org.folio.rest.support.Response) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 37 with IndividualResource

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());
    }
}
Also used : Item(org.folio.rest.jaxrs.model.Item) DomainEventAssertions.assertUpdateEventForItem(org.folio.rest.support.matchers.DomainEventAssertions.assertUpdateEventForItem) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 38 with IndividualResource

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

Example 39 with IndividualResource

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

Example 40 with IndividualResource

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()));
}
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