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