Search in sources :

Example 26 with ItemRequestBuilder

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

the class MarkItemInProcessNonRequestableApiTests method shouldNotReopenClosedRequests.

@Test
@Parameters({ "Closed - Cancelled", "Closed - Filled", "Closed - Pickup expired", "Closed - Unfilled" })
public void shouldNotReopenClosedRequests(String requestStatus) throws Exception {
    final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus("Awaiting pickup").canCirculate());
    final IndividualResource request = createRequest(createdItem.getId(), requestStatus, DateTime.now(DateTimeZone.UTC).plusHours(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)

Example 27 with ItemRequestBuilder

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

the class MarkItemIntellectualItemApiTests method cannotMarkItemIntellectualItemWhenNotInAllowedStatus.

@Test
public void cannotMarkItemIntellectualItemWhenNotInAllowedStatus() throws Exception {
    final String initialStatus = "Intellectual item";
    final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus(initialStatus).canCirculate());
    Response response = markItemIntellectualItem(createdItem);
    assertThat(markItemIntellectualItem(createdItem), hasValidationError("Item is not allowed to be marked as Intellectual item", "status.name", initialStatus));
}
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 28 with ItemRequestBuilder

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

the class MarkItemIntellectualItemApiTests method shouldNotReopenClosedRequests.

@Test
@Parameters({ "Closed - Cancelled", "Closed - Filled", "Closed - Pickup expired", "Closed - Unfilled" })
public void shouldNotReopenClosedRequests(String requestStatus) throws Exception {
    final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus("Awaiting pickup").canCirculate());
    final IndividualResource request = createRequest(createdItem.getId(), requestStatus, DateTime.now(DateTimeZone.UTC).plusHours(1));
    assertThat(markItemIntellectualItem(createdItem).getJson(), isIntellectualItem());
    assertThat(itemsClient.getById(createdItem.getId()).getJson(), isIntellectualItem());
    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)

Example 29 with ItemRequestBuilder

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

the class MarkItemIntellectualItemApiTests method canMarkItemIntellectualItemWhenInAllowedStatus.

@Test
public void canMarkItemIntellectualItemWhenInAllowedStatus() throws Exception {
    final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withStatus("Awaiting delivery").canCirculate());
    final Response response = markItemIntellectualItem(createdItem);
    assertEquals(200, response.getStatusCode());
    assertThat(response.getJson(), isIntellectualItem());
    assertThat(itemsClient.getById(createdItem.getId()).getJson(), isIntellectualItem());
}
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 30 with ItemRequestBuilder

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

the class MarkItemLongMissingApiTests method testMarkItemLongMissingPreservesCirculationNotes.

@Test
public void testMarkItemLongMissingPreservesCirculationNotes() throws Exception {
    final IndividualResource createdItem = itemsClient.create(new ItemRequestBuilder().forHolding(holdingsRecord.getId()).withCheckInNote().canCirculate());
    final var item = markItemLongMissing(createdItem).getJson();
    final var itemCirculationNotes = item.getJsonArray(CIRCULATION_NOTES_KEY);
    final var checkInNote = itemCirculationNotes.getJsonObject(0);
    assertThat(checkInNote.getString(NOTE_TYPE_KEY), is("Check in"));
    assertThat(checkInNote.getString(NOTE_KEY), is("Please read this note before checking in the item"));
    assertThat(checkInNote.getBoolean(STAFF_ONLY_KEY), is(false));
}
Also used : IndividualResource(org.folio.inventory.support.http.client.IndividualResource) ItemRequestBuilder(api.support.builders.ItemRequestBuilder) 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