Search in sources :

Example 51 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class UpdateItemStatusDateFunctionMigrationTest method createAndChangeItemStatus.

private UUID createAndChangeItemStatus() {
    final UUID holdingsId = createInstanceAndHolding(mainLibraryLocationId);
    final IndividualResource item = itemsClient.create(new ItemRequestBuilder().available().withMaterialType(bookMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).forHolding(holdingsId));
    itemsClient.replace(item.getId(), item.copyJson().put("status", new JsonObject().put("name", "Checked out")));
    return item.getId();
}
Also used : JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder)

Example 52 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class ModesOfIssuanceMigrationScriptTest method canMigrateModeOfIssuance.

@Test
public void canMigrateModeOfIssuance() throws Exception {
    IndividualResource integratingResource = createModeOfIssuance("4fc0f4fe-06fd-490a-a078-c4da1754e03a", "Integrating Resource", "rdamodeissue");
    IndividualResource singleUnitResource = createModeOfIssuance("9d18a02f-5897-4c31-9106-c9abb5c7ae8b", "Monograph", "rdamodeissue");
    IndividualResource unspecifiedResource = createModeOfIssuance("612bbd3d-c16b-4bfb-8517-2afafc60204a", "Other", "rdamodeissue");
    IndividualResource multipartMonographResource = createModeOfIssuance("f5cc2ab6-bb92-4cab-b83f-5a3d09261a41", "Sequential Monograph", "rdamodeissue");
    IndividualResource serialResource = createModeOfIssuance("068b5344-e2a6-40df-9186-1829e13cd344", "Serial", "rdamodeissue");
    executeMultipleSqlStatements(MIGRATION_SCRIPT);
    List<JsonObject> modesOfIssuance = modesOfIssuanceClient.getAll();
    expectModeOfIssuance(modesOfIssuance.get(0), integratingResource.getId(), "integrating resource", "rdamodeissue");
    expectModeOfIssuance(modesOfIssuance.get(1), multipartMonographResource.getId(), "multipart monograph", "rdamodeissue");
    expectModeOfIssuance(modesOfIssuance.get(2), serialResource.getId(), "serial", "rdamodeissue");
    expectModeOfIssuance(modesOfIssuance.get(3), singleUnitResource.getId(), "single unit", "rdamodeissue");
    expectModeOfIssuance(modesOfIssuance.get(4), unspecifiedResource.getId(), "unspecified", "folio");
}
Also used : JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 53 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class ResourceClient method create.

public IndividualResource create(JsonObject request) {
    Response response = attemptToCreate(request);
    assertThat(String.format("Failed to create %s: %s", resourceName, response.getBody()), response.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));
    System.out.println(String.format("Created resource %s: %s", resourceName, response.getJson().encodePrettily()));
    return new IndividualResource(response);
}
Also used : Response(org.folio.rest.support.Response) IndividualResource(org.folio.rest.support.IndividualResource)

Example 54 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class BoundWithStorageTest method canCreateAndRetrieveBoundWithParts.

@Test
public void canCreateAndRetrieveBoundWithParts() {
    FakeKafkaConsumer.removeAllEvents();
    IndividualResource mainInstance = createInstance("Main Instance");
    IndividualResource mainHoldingsRecord = createHoldingsRecord(mainInstance.getId());
    IndividualResource item = createItem(mainHoldingsRecord.getId());
    IndividualResource anotherInstance = createInstance("Another Instance");
    IndividualResource anotherHoldingsRecord = createHoldingsRecord(anotherInstance.getId());
    IndividualResource aThirdInstance = createInstance("Third Instance");
    IndividualResource aThirdHoldingsRecord = createHoldingsRecord(aThirdInstance.getId());
    // Make 'item' a bound-with
    boundWithPartsClient.create(createBoundWithPartJson(mainHoldingsRecord.getId(), item.getId()));
    IndividualResource secondPart = boundWithPartsClient.create(createBoundWithPartJson(anotherHoldingsRecord.getId(), item.getId()));
    boundWithPartsClient.create(createBoundWithPartJson(aThirdHoldingsRecord.getId(), item.getId()));
    Response boundWithGETResponseForPartById = boundWithPartsClient.getById(secondPart.getId());
    List<JsonObject> getAllPartsForBoundWithItem = boundWithPartsClient.getByQuery("?query=itemId==" + item.getId());
    assertThat(boundWithGETResponseForPartById.getStatusCode(), is(HttpURLConnection.HTTP_OK));
    assertThat(getAllPartsForBoundWithItem.size(), is(3));
    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 55 with IndividualResource

use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.

the class ItemEffectiveLocationTest method canCalculateEffectiveLocationOnHoldingUpdate.

public void canCalculateEffectiveLocationOnHoldingUpdate() throws Exception {
    UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
    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.put("temporaryLocationId", secondFloorLocationId.toString());
    holdingsClient.replace(holdingsRecordId, holding);
    for (Item item : itemsToCreate) {
        Item fetchedItem = getItem(item.getId());
        assertEquals(fetchedItem.getEffectiveLocationId(), secondFloorLocationId.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)

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