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