Search in sources :

Example 16 with HoldingRequestBuilder

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

the class MarkItemIntellectualItemApiTests method createInstanceAndHoldingsRecord.

@Before
public void createInstanceAndHoldingsRecord() throws Exception {
    final IndividualResource instance = instancesClient.create(smallAngryPlanet(UUID.randomUUID()));
    holdingsRecord = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(instance.getId()));
}
Also used : HoldingRequestBuilder(api.support.builders.HoldingRequestBuilder) IndividualResource(org.folio.inventory.support.http.client.IndividualResource) Before(org.junit.Before)

Example 17 with HoldingRequestBuilder

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

the class HoldingApiExample method cannotUpdateAHoldingWithOptimisticLockingFailure.

@Test
public void cannotUpdateAHoldingWithOptimisticLockingFailure() throws Exception {
    JsonObject instance = createInstance(smallAngryPlanet(UUID.randomUUID()));
    JsonObject holding = new HoldingRequestBuilder().forInstance(UUID.fromString(instance.getString("id"))).permanentlyInMainLibrary().create().put("id", ApiTestSuite.ID_FOR_OPTIMISTIC_LOCKING_FAILURE);
    assertThat(createHolding(holding).getStatusCode(), is(201));
    assertThat(updateHolding(holding).getStatusCode(), is(409));
}
Also used : HoldingRequestBuilder(api.support.builders.HoldingRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 18 with HoldingRequestBuilder

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

the class HoldingApiExample method canCreateAHolding.

@Test
public void canCreateAHolding() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    JsonObject createdInstance = createInstance(smallAngryPlanet(UUID.randomUUID()));
    IndividualResource postResponse = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(UUID.fromString(createdInstance.getString("id"))).permanentlyInMainLibrary());
    JsonObject createdHolding = holdingsStorageClient.getById(postResponse.getId()).getJson();
    assertTrue(createdHolding.containsKey("id"));
    assertEquals(createdInstance.getString("id"), createdHolding.getString("instanceId"));
    assertTrue(createdHolding.containsKey("permanentLocationId"));
}
Also used : HoldingRequestBuilder(api.support.builders.HoldingRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(org.folio.inventory.support.http.client.IndividualResource) Test(org.junit.Test)

Example 19 with HoldingRequestBuilder

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

the class HoldingApiExample method cannotCreateAHoldingWithoutInstanceId.

@Test
public void cannotCreateAHoldingWithoutInstanceId() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    JsonObject createdInstance = createInstance(smallAngryPlanet(UUID.randomUUID()));
    JsonObject holdingAsJson = new HoldingRequestBuilder().forInstance(UUID.fromString(createdInstance.getString("id"))).permanentlyInMainLibrary().create();
    holdingAsJson.remove("instanceId");
    assertThat(createHolding(holdingAsJson).getStatusCode(), is(422));
}
Also used : HoldingRequestBuilder(api.support.builders.HoldingRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 20 with HoldingRequestBuilder

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

the class MarkItemUnknownApiTests method createInstanceAndHoldingsRecord.

@Before
public void createInstanceAndHoldingsRecord() throws Exception {
    final IndividualResource instance = instancesClient.create(smallAngryPlanet(UUID.randomUUID()));
    holdingsRecord = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(instance.getId()));
}
Also used : HoldingRequestBuilder(api.support.builders.HoldingRequestBuilder) IndividualResource(org.folio.inventory.support.http.client.IndividualResource) Before(org.junit.Before)

Aggregations

HoldingRequestBuilder (api.support.builders.HoldingRequestBuilder)41 Test (org.junit.Test)30 JsonObject (io.vertx.core.json.JsonObject)28 IndividualResource (org.folio.inventory.support.http.client.IndividualResource)25 UUID (java.util.UUID)24 Response (org.folio.inventory.support.http.client.Response)19 ItemRequestBuilder (api.support.builders.ItemRequestBuilder)15 Before (org.junit.Before)9 URL (java.net.URL)4 DateTime (org.joda.time.DateTime)4 Ignore (org.junit.Ignore)3 JsonArray (io.vertx.core.json.JsonArray)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ApiTestSuite (api.ApiTestSuite)1 USER_ID (api.ApiTestSuite.USER_ID)1 ApiTestSuite.getCanCirculateLoanType (api.ApiTestSuite.getCanCirculateLoanType)1 ApiTestSuite.getDvdMaterialType (api.ApiTestSuite.getDvdMaterialType)1 ApiTestSuite.getMainLibraryLocation (api.ApiTestSuite.getMainLibraryLocation)1 ApiTestSuite.getReadingRoomLocation (api.ApiTestSuite.getReadingRoomLocation)1 ApiTestSuite.getThirdFloorLocation (api.ApiTestSuite.getThirdFloorLocation)1