use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.
the class HoldingsStorageTest method cannotCreateAHoldingsWithHRIDFailure.
@Test
public void cannotCreateAHoldingsWithHRIDFailure() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
log.info("Starting cannotCreateAHoldingsWithHRIDFailure");
final UUID instanceId = UUID.randomUUID();
instancesClient.create(smallAngryPlanet(instanceId));
setHoldingsSequence(99_999_999_999L);
final JsonObject goodHholdings = holdingsClient.create(new HoldingRequestBuilder().withId(UUID.randomUUID()).forInstance(instanceId).withPermanentLocation(mainLibraryLocationId).withTags(new JsonObject().put("tagList", new JsonArray().add(TAG_VALUE)))).getJson();
assertThat(goodHholdings.getString("hrid"), is("ho99999999999"));
final JsonObject badHoldings = new HoldingRequestBuilder().withId(UUID.randomUUID()).forInstance(instanceId).withPermanentLocation(mainLibraryLocationId).withTags(new JsonObject().put("tagList", new JsonArray().add(TAG_VALUE))).create();
final CompletableFuture<Response> createCompleted = new CompletableFuture<>();
client.post(holdingsStorageUrl(""), badHoldings, TENANT_ID, text(createCompleted));
final Response response = createCompleted.get(5, TimeUnit.SECONDS);
assertThat(response.getStatusCode(), is(HttpURLConnection.HTTP_INTERNAL_ERROR));
assertThat(response.getBody(), isMaximumSequenceValueError("hrid_holdings_seq"));
log.info("Finished cannotCreateAHoldingsWithHRIDFailure");
}
use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.
the class InstanceDomainEventTest method eventIsNotSentWhenRemoveFailed.
@Test
public void eventIsNotSentWhenRemoveFailed() {
final var instance = instancesClient.create(smallAngryPlanet(UUID.randomUUID()));
// create a holding so that instance is not allowed to be removed
holdingsClient.create(new HoldingRequestBuilder().forInstance(instance.getId()).withPermanentLocation(mainLibraryLocationId));
final Response removeResponse = instancesClient.attemptToDelete(instance.getId());
assertThat(removeResponse.getStatusCode(), is(400));
assertNoRemoveEvent(instance.getId().toString());
}
use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.
the class InstanceDomainEventTest method eventIsNotSentWhenRemoveAllFailed.
@Test
public void eventIsNotSentWhenRemoveAllFailed() {
final var instance = instancesClient.create(smallAngryPlanet(UUID.randomUUID()));
instancesClient.create(smallAngryPlanet(UUID.randomUUID()));
// create a holding so that instance is not allowed to be removed
holdingsClient.create(new HoldingRequestBuilder().forInstance(instance.getId()).withPermanentLocation(mainLibraryLocationId));
final Response removeResponse = instancesClient.attemptDeleteAll();
assertThat(removeResponse.getStatusCode(), is(500));
assertNoRemoveEvent(instance.getId().toString());
}
use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method canSearchByBarcodeAndPermanentLocation.
// This is intended to demonstrate usage of the two different views
@Test
public void canSearchByBarcodeAndPermanentLocation() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID smallAngryPlanetInstanceId = UUID.randomUUID();
UUID mainLibrarySmallAngryHoldingId = UUID.randomUUID();
createInstance(smallAngryPlanet(smallAngryPlanetInstanceId));
createHoldings(new HoldingRequestBuilder().withId(mainLibrarySmallAngryHoldingId).withPermanentLocation(mainLibraryLocationId).forInstance(smallAngryPlanetInstanceId).create());
createItem(new ItemRequestBuilder().forHolding(mainLibrarySmallAngryHoldingId).withBarcode("706949453641").withPermanentLoanType(canCirculateLoanTypeId).withMaterialType(bookMaterialTypeId).create());
UUID annexSmallAngryHoldingId = UUID.randomUUID();
createHoldings(new HoldingRequestBuilder().withId(annexSmallAngryHoldingId).withPermanentLocation(annexLibraryLocationId).forInstance(smallAngryPlanetInstanceId).create());
createItem(new ItemRequestBuilder().forHolding(annexSmallAngryHoldingId).withBarcode("70704539201").withPermanentLoanType(canCirculateLoanTypeId).withMaterialType(bookMaterialTypeId).create());
UUID nodInstanceId = UUID.randomUUID();
UUID nodHoldingId = UUID.randomUUID();
createInstance(nod(nodInstanceId));
createHoldings(new HoldingRequestBuilder().withId(nodHoldingId).forInstance(nodInstanceId).withPermanentLocation(mainLibraryLocationId).create());
createItem(new ItemRequestBuilder().forHolding(nodHoldingId).withMaterialType(bookMaterialTypeId).withPermanentLoanType(canCirculateLoanTypeId).withBarcode("766043059304").create());
// Use == as exact match is intended for barcode and location ID
canSort(String.format("item.barcode==706949453641 and holdingsRecords.permanentLocationId==%s", mainLibraryLocationId), "Long Way to a Small Angry Planet");
canSort(String.format("((contributors =/@name \"becky\") and holdingsRecords.permanentLocationId=\"%s\")", mainLibraryLocationId), "Long Way to a Small Angry Planet");
System.out.println("canSearchByBarcodeAndPermanentLocation");
}
use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.
the class EffectiveLocationMigrationTest method canMigrateToEffectiveLocationForItemsWithPermanentLocationOnly.
@Test
public void canMigrateToEffectiveLocationForItemsWithPermanentLocationOnly() throws InterruptedException, ExecutionException, TimeoutException {
holdingsClient.create(new HoldingRequestBuilder().withId(holdingsId).forInstance(instanceId).withPermanentLocation(mainLibraryLocationId));
runSql(removeExistingField);
RowSet<Row> result = runSql(query);
assertEquals(result.rowCount(), 1);
JsonObject entry = result.iterator().next().toJson();
assertNull(entry.getJsonObject("jsonb").getString("effectiveLocationId"));
runSql(SET_EFFECTIVE_LOCATION);
RowSet<Row> migrationResult = runSql(query);
assertEquals(migrationResult.rowCount(), 1);
JsonObject migrationEntry = migrationResult.iterator().next().toJson();
assertEquals(mainLibraryLocationId.toString(), migrationEntry.getJsonObject("jsonb").getString("effectiveLocationId"));
}
Aggregations