Search in sources :

Example 61 with IndividualResource

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

the class ItemStorageTest method explicitRightTruncationCanBeApplied.

@Test
public void explicitRightTruncationCanBeApplied() throws Exception {
    final UUID holdingsRecordId = createInstanceAndHolding(mainLibraryLocationId);
    final IndividualResource firstItemToMatch = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 2014").available());
    final IndividualResource secondItemToMatch = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 2014").withItemLevelCallNumberSuffix("Curriculum Materials Collection").available());
    final IndividualResource thirdItemToMatch = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F73 ").withItemLevelCallNumberSuffix("2014 Curriculum Materials Collection").available());
    itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecordId).withMaterialType(journalMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withItemLevelCallNumber("GE77 .F74 ").withItemLevelCallNumberSuffix("2014 Curriculum Materials Collection").available());
    final List<UUID> foundItems = searchByCallNumberEyeReadable("GE77 .F73*");
    assertThat(foundItems.size(), is(3));
    assertThat(foundItems, hasItems(firstItemToMatch.getId(), secondItemToMatch.getId(), thirdItemToMatch.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 62 with IndividualResource

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

the class InstanceStorageTest method canSearchUsingMetadataDateUpdatedIndex.

@Test
public void canSearchUsingMetadataDateUpdatedIndex() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
    UUID firstInstanceId = UUID.randomUUID();
    JsonObject firstInstanceToCreate = smallAngryPlanet(firstInstanceId);
    createInstance(firstInstanceToCreate);
    UUID secondInstanceId = UUID.randomUUID();
    JsonObject secondInstanceToCreate = nod(secondInstanceId);
    IndividualResource ir = createInstance(secondInstanceToCreate);
    CompletableFuture<Response> getCompleted = new CompletableFuture<>();
    JsonObject metadata = ir.getJson().getJsonObject("metadata");
    String query = urlEncode(String.format("%s.updatedDate>=%s", METADATA_KEY, metadata.getString("updatedDate")));
    client.get(instancesStorageUrl(String.format("?query=%s", query)), StorageTestSuite.TENANT_ID, ResponseHandler.json(getCompleted));
    Response response = getCompleted.get(5, TimeUnit.SECONDS);
    JsonObject responseBody = response.getJson();
    JsonArray allInstances = responseBody.getJsonArray("instances");
    assertThat(allInstances.size(), is(1));
    JsonObject instance = allInstances.getJsonObject(0);
    assertThat(instance.getString("title"), is(ir.getJson().getString("title")));
}
Also used : JsonErrorResponse(org.folio.rest.support.JsonErrorResponse) InstancesBatchResponse(org.folio.rest.jaxrs.model.InstancesBatchResponse) Response(org.folio.rest.support.Response) JsonArray(io.vertx.core.json.JsonArray) CompletableFuture(java.util.concurrent.CompletableFuture) JsonObject(io.vertx.core.json.JsonObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) UUID(java.util.UUID) IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 63 with IndividualResource

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

the class InstanceStorageTest method canSearchByDiscoverySuppressProperty.

@Test
public void canSearchByDiscoverySuppressProperty() throws Exception {
    final IndividualResource suppressedInstance = createInstance(smallAngryPlanet(UUID.randomUUID()).put(DISCOVERY_SUPPRESS, true));
    final IndividualResource notSuppressedInstance = createInstance(smallAngryPlanet(UUID.randomUUID()));
    final List<IndividualResource> suppressedInstances = instancesClient.getMany("%s==true", DISCOVERY_SUPPRESS);
    final List<IndividualResource> notSuppressedInstances = instancesClient.getMany("%s==false", DISCOVERY_SUPPRESS);
    assertThat(suppressedInstances.size(), is(1));
    assertThat(suppressedInstances.get(0).getId(), is(suppressedInstance.getId()));
    assertThat(notSuppressedInstances.size(), is(1));
    assertThat(notSuppressedInstances.get(0).getId(), is(notSuppressedInstance.getId()));
}
Also used : IndividualResource(org.folio.rest.support.IndividualResource) Test(org.junit.Test)

Example 64 with IndividualResource

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

the class InstanceStorageTest method createInstance.

private IndividualResource createInstance(JsonObject instanceToCreate) throws InterruptedException, ExecutionException, TimeoutException {
    CompletableFuture<Response> createCompleted = new CompletableFuture<>();
    client.post(instancesStorageUrl(""), instanceToCreate, TENANT_ID, json(createCompleted));
    Response response = createCompleted.get(2, SECONDS);
    assertThat(String.format("Create instance failed: %s", response.getBody()), response.getStatusCode(), is(201));
    return new IndividualResource(response);
}
Also used : JsonErrorResponse(org.folio.rest.support.JsonErrorResponse) InstancesBatchResponse(org.folio.rest.jaxrs.model.InstancesBatchResponse) Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) IndividualResource(org.folio.rest.support.IndividualResource)

Example 65 with IndividualResource

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

the class ItemCallNumberNormalizedTest method createRecords.

@BeforeClass
public static void createRecords() throws Exception {
    final IndividualResource instance = instancesClient.create(smallAngryPlanet(UUID.randomUUID()));
    final IndividualResource holdings = holdingsClient.create(new HoldingRequestBuilder().forInstance(instance.getId()).withPermanentLocation(mainLibraryLocationId));
    for (String[] callNumberComponents : callNumberData()) {
        itemsClient.create(new ItemRequestBuilder().forHolding(holdings.getId()).withPermanentLoanType(canCirculateLoanTypeId).withMaterialType(bookMaterialTypeId).withItemLevelCallNumberPrefix(callNumberComponents[0]).withItemLevelCallNumber(callNumberComponents[1]).withItemLevelCallNumberSuffix(callNumberComponents[2]));
    }
}
Also used : HoldingRequestBuilder(org.folio.rest.support.builders.HoldingRequestBuilder) IndividualResource(org.folio.rest.support.IndividualResource) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder) BeforeClass(org.junit.BeforeClass)

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