Search in sources :

Example 21 with ItemRequestBuilder

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

the class ItemApiExamples method canChangeBarcodeForExistingItem.

@Test
public void canChangeBarcodeForExistingItem() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    JsonObject nodInstance = createInstance(nod(UUID.randomUUID()));
    UUID nodHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(UUID.fromString(nodInstance.getString("id")))).getId();
    IndividualResource nodItemResponse = itemsClient.create(new ItemRequestBuilder().forHolding(nodHoldingId).book().canCirculate().withBarcode("654647774352"));
    JsonObject changedNodItem = nodItemResponse.getJson().copy().put("barcode", "645398607547");
    URL nodItemLocation = new URL(String.format("%s/%s", ApiRoot.items(), nodItemResponse.getId()));
    final var putItemCompleted = okapiClient.put(nodItemLocation, changedNodItem);
    Response putItemResponse = putItemCompleted.toCompletableFuture().get(5, SECONDS);
    assertThat(putItemResponse.getStatusCode(), is(204));
    final var getItemCompleted = okapiClient.get(nodItemLocation);
    Response getItemResponse = getItemCompleted.toCompletableFuture().get(5, SECONDS);
    assertThat(getItemResponse.getStatusCode(), is(200));
    assertThat(getItemResponse.getJson().getString("barcode"), is("645398607547"));
}
Also used : Response(org.folio.inventory.support.http.client.Response) HoldingRequestBuilder(api.support.builders.HoldingRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) IndividualResource(org.folio.inventory.support.http.client.IndividualResource) ItemRequestBuilder(api.support.builders.ItemRequestBuilder) URL(java.net.URL) Test(org.junit.Test)

Example 22 with ItemRequestBuilder

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

the class ItemApiExamples method canCreateMultipleItemsWithoutBarcode.

@Test
public void canCreateMultipleItemsWithoutBarcode() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    UUID holdingId = createInstanceAndHolding();
    itemsClient.create(new ItemRequestBuilder().forHolding(holdingId).withNoBarcode());
    IndividualResource secondItemResponse = itemsClient.create(new ItemRequestBuilder().forHolding(holdingId).withNoBarcode());
    JsonObject createdItem = itemsClient.getById(secondItemResponse.getId()).getJson();
    assertThat(createdItem.containsKey("barcode"), is(false));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) ItemRequestBuilder(api.support.builders.ItemRequestBuilder) IndividualResource(org.folio.inventory.support.http.client.IndividualResource) Test(org.junit.Test)

Example 23 with ItemRequestBuilder

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

the class MarkItemInProcessApiTests method shouldChangeRequestBeingFulfilledBackToNotYetFilled.

@Test
@Parameters({ "Open - Awaiting delivery", "Open - Awaiting pickup", "Open - In transit" })
public void shouldChangeRequestBeingFulfilledBackToNotYetFilled(String requestStatus) throws Exception {
    final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus(requestStatus.replace("Open - ", "")).canCirculate());
    final IndividualResource request = createRequest(createdItem.getId(), requestStatus, DateTime.now(DateTimeZone.UTC).plusHours(1));
    assertThat(markItemInProcess(createdItem).getJson(), isInProcess());
    assertThat(itemsClient.getById(createdItem.getId()).getJson(), isInProcess());
    assertThat(requestStorageClient.getById(request.getId()).getJson(), isOpenNotYetFilled());
}
Also used : IndividualResource(org.folio.inventory.support.http.client.IndividualResource) ItemRequestBuilder(api.support.builders.ItemRequestBuilder) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 24 with ItemRequestBuilder

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

the class MarkItemInProcessApiTests method canMarkItemInProcessWhenInAllowedStatus.

@Test
public void canMarkItemInProcessWhenInAllowedStatus() throws Exception {
    final String initialStatus = "Aged to lost";
    final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus("Available").canCirculate());
    final Response response = markItemInProcess(createdItem);
    assertEquals(200, response.getStatusCode());
    assertThat(response.getJson(), isInProcess());
    assertThat(itemsClient.getById(createdItem.getId()).getJson(), isInProcess());
}
Also used : Response(org.folio.inventory.support.http.client.Response) IndividualResource(org.folio.inventory.support.http.client.IndividualResource) ItemRequestBuilder(api.support.builders.ItemRequestBuilder) Test(org.junit.Test)

Example 25 with ItemRequestBuilder

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

the class MarkItemInProcessNonRequestableApiTests method shouldNotReopenExpiredRequests.

@Test
@Parameters({ "Open - Awaiting delivery", "Open - Awaiting pickup", "Open - In transit" })
public void shouldNotReopenExpiredRequests(String requestStatus) throws Exception {
    final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus(requestStatus.replace("Open - ", "")).canCirculate());
    final IndividualResource request = createRequest(createdItem.getId(), requestStatus, DateTime.now(DateTimeZone.UTC).minusHours(1));
    assertThat(markItemInProcessNonRequestable(createdItem).getJson(), isInProcessNonRequestable());
    assertThat(itemsClient.getById(createdItem.getId()).getJson(), isInProcessNonRequestable());
    assertThat(requestStorageClient.getById(request.getId()).getJson(), hasStatus(requestStatus));
}
Also used : IndividualResource(org.folio.inventory.support.http.client.IndividualResource) ItemRequestBuilder(api.support.builders.ItemRequestBuilder) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

ItemRequestBuilder (api.support.builders.ItemRequestBuilder)96 Test (org.junit.Test)96 IndividualResource (org.folio.inventory.support.http.client.IndividualResource)83 Response (org.folio.inventory.support.http.client.Response)41 JsonObject (io.vertx.core.json.JsonObject)40 UUID (java.util.UUID)38 Parameters (junitparams.Parameters)29 HoldingRequestBuilder (api.support.builders.HoldingRequestBuilder)15 JsonArray (io.vertx.core.json.JsonArray)10 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 ItemsMoveRequestBuilder (api.support.builders.ItemsMoveRequestBuilder)5 DateTime (org.joda.time.DateTime)5 URL (java.net.URL)4 List (java.util.List)3 Date (java.util.Date)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