Search in sources :

Example 26 with HoldingRequestBuilder

use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.

the class StatisticalCodeTest method canNotDeleteStatisticalCodeIfInUseByItem.

@Test
public void canNotDeleteStatisticalCodeIfInUseByItem() throws Exception {
    final var statisticalCode = new StatisticalCodeBuilder().withId(UUID.fromString("b06fa5fe-a267-4597-8e74-3b308bd4c932")).withCode("stcone").withName("STATISTICAL CODE 1");
    final var createdCode = statisticalCodeFixture.createSerialManagementCode(statisticalCode);
    UUID instanceId = UUID.randomUUID();
    instancesClient.create(smallAngryPlanet(instanceId));
    UUID holdingId = UUID.randomUUID();
    final var holdingToCreate = new HoldingRequestBuilder().withId(holdingId).forInstance(instanceId).withPermanentLocation(mainLibraryLocationId);
    holdingsClient.create(holdingToCreate);
    UUID itemId = UUID.randomUUID();
    List<UUID> codes = new ArrayList<>();
    codes.add(createdCode.getId());
    final var itemToCreate = new ItemRequestBuilder().withId(itemId).forHolding(holdingId).withMaterialType(bookMaterialTypeId).withPermanentLoanTypeId(canCirculateLoanTypeId).withStatisticalCodeIds(codes);
    itemsClient.create(itemToCreate);
    CompletableFuture<Response> deleteCompleted = new CompletableFuture<>();
    client.delete(statisticalCodesUrl("/" + createdCode.getId().toString()), StorageTestSuite.TENANT_ID, ResponseHandler.text(deleteCompleted));
    Response response = deleteCompleted.get(5, TimeUnit.SECONDS);
    assertThat(response.getStatusCode(), is(400));
    assertThat(response.getBody().trim(), is("foreign_key_violation: Key (id)=(b06fa5fe-a267-4597-8e74-3b308bd4c932) is still referenced from table \"item\"."));
}
Also used : Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) HoldingRequestBuilder(org.folio.rest.support.builders.HoldingRequestBuilder) ArrayList(java.util.ArrayList) StatisticalCodeBuilder(org.folio.rest.support.builders.StatisticalCodeBuilder) UUID(java.util.UUID) ItemRequestBuilder(org.folio.rest.support.builders.ItemRequestBuilder) Test(org.junit.Test)

Example 27 with HoldingRequestBuilder

use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.

the class TestBaseWithInventoryUtil method createInstanceAndHoldingWithCallNumberPrefix.

protected static UUID createInstanceAndHoldingWithCallNumberPrefix(UUID holdingsPermanentLocationId) {
    UUID instanceId = UUID.randomUUID();
    instancesClient.create(instance(instanceId));
    return holdingsClient.create(new HoldingRequestBuilder().withId(UUID.randomUUID()).forInstance(instanceId).withPermanentLocation(holdingsPermanentLocationId).withCallNumberPrefix("testCallNumberPrefix")).getId();
}
Also used : HoldingRequestBuilder(org.folio.rest.support.builders.HoldingRequestBuilder) UUID(java.util.UUID)

Example 28 with HoldingRequestBuilder

use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.

the class TestBaseWithInventoryUtil method createInstanceAndHoldingWithBuilder.

static UUID createInstanceAndHoldingWithBuilder(UUID holdingsPermanentLocationId, UnaryOperator<HoldingRequestBuilder> holdingsBuilderProcessor) {
    UUID instanceId = UUID.randomUUID();
    instancesClient.create(instance(instanceId));
    HoldingRequestBuilder holdingsBuilder = new HoldingRequestBuilder().withId(UUID.randomUUID()).forInstance(instanceId).withPermanentLocation(holdingsPermanentLocationId);
    return holdingsClient.create(holdingsBuilderProcessor.apply(holdingsBuilder)).getId();
}
Also used : HoldingRequestBuilder(org.folio.rest.support.builders.HoldingRequestBuilder) UUID(java.util.UUID)

Example 29 with HoldingRequestBuilder

use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.

the class TestBaseWithInventoryUtil method createInstanceAndHoldingWithCallNumberSuffix.

protected static UUID createInstanceAndHoldingWithCallNumberSuffix(UUID holdingsPermanentLocationId) {
    UUID instanceId = UUID.randomUUID();
    instancesClient.create(instance(instanceId));
    return holdingsClient.create(new HoldingRequestBuilder().withId(UUID.randomUUID()).forInstance(instanceId).withPermanentLocation(holdingsPermanentLocationId).withCallNumberSuffix("testCallNumberSuffix")).getId();
}
Also used : HoldingRequestBuilder(org.folio.rest.support.builders.HoldingRequestBuilder) UUID(java.util.UUID)

Example 30 with HoldingRequestBuilder

use of org.folio.rest.support.builders.HoldingRequestBuilder in project mod-inventory-storage by folio-org.

the class TestBaseWithInventoryUtil method createInstanceAndHoldingWithCallNumber.

protected static UUID createInstanceAndHoldingWithCallNumber(UUID holdingsPermanentLocationId) {
    UUID instanceId = UUID.randomUUID();
    instancesClient.create(instance(instanceId));
    return holdingsClient.create(new HoldingRequestBuilder().withId(UUID.randomUUID()).forInstance(instanceId).withPermanentLocation(holdingsPermanentLocationId).withCallNumber("testCallNumber")).getId();
}
Also used : HoldingRequestBuilder(org.folio.rest.support.builders.HoldingRequestBuilder) UUID(java.util.UUID)

Aggregations

HoldingRequestBuilder (org.folio.rest.support.builders.HoldingRequestBuilder)61 Test (org.junit.Test)55 UUID (java.util.UUID)53 JsonObject (io.vertx.core.json.JsonObject)39 JsonArray (io.vertx.core.json.JsonArray)31 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)19 URL (java.net.URL)16 CompletableFuture (java.util.concurrent.CompletableFuture)15 Response (org.folio.rest.support.Response)6 ItemRequestBuilder (org.folio.rest.support.builders.ItemRequestBuilder)6 IndividualResource (org.folio.rest.support.IndividualResource)4 ArrayList (java.util.ArrayList)3 Row (io.vertx.sqlclient.Row)2 Vertx (io.vertx.core.Vertx)1 Async (io.vertx.ext.unit.Async)1 TestContext (io.vertx.ext.unit.TestContext)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HttpURLConnection (java.net.HttpURLConnection)1