use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class InstanceDiscoverySuppressMigrationScriptTest method verifyNotSuppressed.
private void verifyNotSuppressed(List<IndividualResource> instances) throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
for (IndividualResource instance : instances) {
Instance instanceInStorage = instancesClient.getById(instance.getId()).getJson().mapTo(Instance.class);
assertThat(instanceInStorage.getDiscoverySuppress(), is(false));
}
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class InstanceDiscoverySuppressMigrationScriptTest method discoverySuppressedInstancesAreNotUpdated.
@Test
public void discoverySuppressedInstancesAreNotUpdated() throws Exception {
List<IndividualResource> notSuppressedInstances = createInstances(2);
List<IndividualResource> suppressedInstances = new ArrayList<>(2);
suppressedInstances.add(instancesClient.create(smallAngryPlanetSuppressedFromDiscovery()));
suppressedInstances.add(instancesClient.create(smallAngryPlanetSuppressedFromDiscovery()));
for (IndividualResource instance : notSuppressedInstances) {
assertThat(unsetJsonbProperty("instance", instance.getId(), DISCOVERY_SUPPRESS).rowCount(), is(1));
}
executeMultipleSqlStatements(MIGRATION_SCRIPT);
verifyNotSuppressed(notSuppressedInstances);
verifySuppressed(suppressedInstances);
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method canPostSynchronousBatchWithExistingIdUpsertTrue.
@Test
public void canPostSynchronousBatchWithExistingIdUpsertTrue() throws Exception {
UUID duplicateId = UUID.randomUUID();
final IndividualResource existingInstance = createInstance(nod(duplicateId));
final JsonObject firstInstanceToCreate = uprooted(UUID.randomUUID());
final JsonObject instanceToUpdate = smallAngryPlanet(duplicateId);
final JsonObject secondInstanceToCreate = temeraire(UUID.randomUUID());
JsonArray instancesArray = new JsonArray();
instancesArray.add(firstInstanceToCreate);
instancesArray.add(instanceToUpdate);
instancesArray.add(secondInstanceToCreate);
JsonObject instanceCollection = new JsonObject().put(INSTANCES_KEY, instancesArray);
Response response = instancesStorageSyncClient.attemptToCreate("?upsert=true", instanceCollection);
assertThat(response, statusCodeIs(HttpStatus.HTTP_CREATED));
assertExists(instancesArray.getJsonObject(0));
assertExists(instancesArray.getJsonObject(1));
assertExists(instancesArray.getJsonObject(2));
Response getResponse = getById(duplicateId);
assertThat(getResponse.getStatusCode(), is(HTTP_OK));
JsonObject updatedInstance = getResponse.getJson();
assertThat(updatedInstance.getString("title"), is("Long Way to a Small Angry Planet"));
assertUpdateEventForInstance(existingInstance.getJson(), updatedInstance);
assertCreateEventForInstance(getById(firstInstanceToCreate.getString("id")).getJson());
assertCreateEventForInstance(getById(secondInstanceToCreate.getString("id")).getJson());
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method canDeleteAnInstance.
@Test
public void canDeleteAnInstance() throws InterruptedException, TimeoutException, ExecutionException {
UUID id = UUID.randomUUID();
JsonObject instanceToCreate = smallAngryPlanet(id);
final IndividualResource createdInstance = createInstance(instanceToCreate);
CompletableFuture<Response> deleteCompleted = new CompletableFuture<>();
URL url = instancesStorageUrl(String.format("/%s", id));
client.delete(url, TENANT_ID, ResponseHandler.empty(deleteCompleted));
Response deleteResponse = deleteCompleted.get(5, SECONDS);
assertThat(deleteResponse.getStatusCode(), is(HttpURLConnection.HTTP_NO_CONTENT));
assertGetNotFound(url);
assertRemoveEventForInstance(createdInstance.getJson());
}
use of org.folio.rest.support.IndividualResource in project mod-inventory-storage by folio-org.
the class BoundWithStorageTest method cannotDeleteItemThatHasBoundWithParts.
@Test
public void cannotDeleteItemThatHasBoundWithParts() {
IndividualResource instance1 = createInstance("Instance 1");
IndividualResource holdingsRecord1 = createHoldingsRecord(instance1.getId());
IndividualResource instance2 = createInstance("Instance 2");
IndividualResource holdingsRecord2 = createHoldingsRecord(instance2.getId());
IndividualResource item = createItem(holdingsRecord1.getId());
boundWithPartsClient.create(createBoundWithPartJson(holdingsRecord1.getId(), item.getId()));
boundWithPartsClient.create(createBoundWithPartJson(holdingsRecord2.getId(), item.getId()));
Response deleteBoundWithItemResponse = itemsClient.attemptToDelete(item.getId());
assertThat(deleteBoundWithItemResponse.getStatusCode(), is(HttpURLConnection.HTTP_BAD_REQUEST));
}
Aggregations