use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method updateInstance.
private IndividualResource updateInstance(JsonObject instance) {
Response putResponse = update(instance);
assertThat(putResponse.getStatusCode(), is(HttpURLConnection.HTTP_NO_CONTENT));
Response getResponse = getById(instance.getString("id"));
assertThat(getResponse.getStatusCode(), is(HTTP_OK));
return new IndividualResource(getResponse);
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class ItemEffectiveCallNumberComponentsTest method canCalculateEffectiveCallNumberPropertyOnUpdate.
@Test
@Parameters(source = ItemEffectiveCallNumberComponentsTestData.class, method = "updatePropertiesParams")
@TestCaseName("[{index}]: {params}")
public void canCalculateEffectiveCallNumberPropertyOnUpdate(CallNumberComponentPropertyNames callNumberProperties, String holdingsInitValue, String holdingsTargetValue, String itemInitValue, String itemTargetValue) {
final String holdingsPropertyName = callNumberProperties.holdingsPropertyName;
final String itemPropertyName = callNumberProperties.itemPropertyName;
final String effectivePropertyName = callNumberProperties.effectivePropertyName;
final String initEffectiveValue = StringUtils.firstNonBlank(itemInitValue, holdingsInitValue);
final String targetEffectiveValue = StringUtils.firstNonBlank(itemTargetValue, holdingsTargetValue);
IndividualResource holdings = createHoldingsWithPropertySetAndInstance(holdingsPropertyName, holdingsInitValue);
IndividualResource createdItem = itemsClient.create(nodWithNoBarcode(holdings.getId()).put(itemPropertyName, itemInitValue));
JsonObject effectiveCallNumberComponents = createdItem.getJson().getJsonObject("effectiveCallNumberComponents");
assertNotNull(effectiveCallNumberComponents);
assertThat(effectiveCallNumberComponents.getString(effectivePropertyName), is(initEffectiveValue));
holdingsClient.replace(holdings.getId(), getHoldingsById(holdings.getJson()).put(holdingsPropertyName, holdingsTargetValue));
var itemAfterHoldingsUpdate = getById(createdItem.getJson());
assertUpdateEventForItem(createdItem.getJson(), itemAfterHoldingsUpdate);
if (!Objects.equals(itemInitValue, itemTargetValue)) {
itemsClient.replace(createdItem.getId(), itemAfterHoldingsUpdate.copy().put(itemPropertyName, itemTargetValue));
await().untilAsserted(() -> {
var instanceId = holdings.getJson().getString("instanceId");
var itemId = createdItem.getId().toString();
var lastItemEvent = getLastItemEvent(instanceId, itemId);
assertTrue(lastItemEvent.value().getJsonObject("new").getInteger("_version") > 1);
assertUpdateEventForItem(itemAfterHoldingsUpdate, itemsClient.getById(createdItem.getId()).getJson());
});
}
final JsonObject updatedItem = itemsClient.getById(createdItem.getId()).getJson();
final JsonObject updatedEffectiveCallNumberComponents = updatedItem.getJsonObject("effectiveCallNumberComponents");
assertNotNull(updatedEffectiveCallNumberComponents);
assertThat(updatedEffectiveCallNumberComponents.getString(effectivePropertyName), is(targetEffectiveValue));
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class HoldingsSourceTest method canAssociateSourceWithHolding.
@Test
public void canAssociateSourceWithHolding() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
UUID instanceId = UUID.randomUUID();
UUID sourceId = UUID.randomUUID();
JsonObject instanceToCreate = new JsonObject();
instanceToCreate.put("id", instanceId.toString());
instanceToCreate.put("source", "Test Source");
instanceToCreate.put("title", "Test Instance");
instanceToCreate.put("instanceTypeId", "535e3160-763a-42f9-b0c0-d8ed7df6e2a2");
instancesClient.create(instanceToCreate);
holdingsSourceClient.create(new JsonObject().put("id", sourceId.toString()).put("name", "associatable source")).getJson();
IndividualResource holdingsResponse = holdingsClient.create(new HoldingRequestBuilder().withId(UUID.randomUUID()).forInstance(instanceId).withPermanentLocation(mainLibraryLocationId).withSource(sourceId));
assertThat(holdingsResponse.getJson().getString("sourceId"), is(sourceId.toString()));
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class HoldingsSourceTest method canCreateHoldingsSourcesWithoutProvidingAnId.
@Test
public void canCreateHoldingsSourcesWithoutProvidingAnId() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
IndividualResource sourceResponse = holdingsSourceClient.create(new JsonObject().put("name", "test source without id"));
JsonObject source = sourceResponse.getJson();
assertThat(source.getString("id"), is(notNullValue()));
assertThat(source.getString("name"), is("test source without id"));
UUID sourceId = sourceResponse.getId();
Response getResponse = holdingsSourceClient.getById(sourceId);
assertThat(getResponse.getStatusCode(), is(HttpURLConnection.HTTP_OK));
JsonObject sourceFromGet = getResponse.getJson();
assertThat(sourceFromGet.getString("id"), is(sourceId.toString()));
assertThat(sourceFromGet.getString("name"), is("test source without id"));
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class HoldingsSourceTest method canRemoveAHoldingsSource.
@Test
public void canRemoveAHoldingsSource() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
IndividualResource holdingsSource = holdingsSourceClient.create(new JsonObject().put("name", "deleteable source"));
UUID deleteableHoldingsSourceId = holdingsSource.getId();
holdingsSourceClient.delete(deleteableHoldingsSourceId);
Response deleteResponse = holdingsSourceClient.getById(deleteableHoldingsSourceId);
assertThat(deleteResponse.getStatusCode(), is(HttpURLConnection.HTTP_NOT_FOUND));
}
Aggregations