Search in sources :

Example 1 with ApiTestSuite.getCanCirculateLoanType

use of api.ApiTestSuite.getCanCirculateLoanType in project mod-inventory by folio-org.

the class ItemApiExamples method CanGetAllItemsWithDifferentTemporaryLoanType.

@Test
public void CanGetAllItemsWithDifferentTemporaryLoanType() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
    JsonObject smallAngryInstance = createInstance(smallAngryPlanet(UUID.randomUUID()));
    UUID smallAngryHoldingId = holdingsStorageClient.create(new HoldingRequestBuilder().forInstance(UUID.fromString(smallAngryInstance.getString("id")))).getId();
    itemsClient.create(new ItemRequestBuilder().forHolding(smallAngryHoldingId).book().canCirculate().withBarcode("645398607547"));
    itemsClient.create(new ItemRequestBuilder().forHolding(smallAngryHoldingId).book().canCirculate().temporarilyCourseReserves().withBarcode("175848607547"));
    final var getAllCompleted = okapiClient.get(ApiRoot.items());
    Response getAllResponse = getAllCompleted.toCompletableFuture().get(5, SECONDS);
    assertThat(getAllResponse.getStatusCode(), is(200));
    List<JsonObject> items = JsonArrayHelper.toList(getAllResponse.getJson().getJsonArray("items"));
    assertThat(items.size(), is(2));
    assertThat(getAllResponse.getJson().getInteger("totalRecords"), is(2));
    assertThat(items.stream().filter(item -> StringUtils.equals(item.getString("barcode"), "645398607547")).findFirst().orElse(new JsonObject()).getJsonObject("permanentLoanType").getString("id"), is(ApiTestSuite.getCanCirculateLoanType()));
    assertThat(items.stream().filter(item -> StringUtils.equals(item.getString("barcode"), "645398607547")).findFirst().orElse(new JsonObject()).containsKey("temporaryLoanType"), is(false));
    assertThat(items.stream().filter(item -> StringUtils.equals(item.getString("barcode"), "175848607547")).findFirst().orElse(new JsonObject()).getJsonObject("permanentLoanType").getString("id"), is(ApiTestSuite.getCanCirculateLoanType()));
    assertThat(items.stream().filter(item -> StringUtils.equals(item.getString("barcode"), "175848607547")).findFirst().orElse(new JsonObject()).getJsonObject("temporaryLoanType").getString("id"), is(ApiTestSuite.getCourseReserveLoanType()));
    items.forEach(ItemApiExamples::hasConsistentPermanentLoanType);
    items.forEach(ItemApiExamples::hasConsistentTemporaryLoanType);
    items.forEach(ItemApiExamples::hasConsistentPermanentLocation);
    items.forEach(ItemApiExamples::hasConsistentTemporaryLocation);
}
Also used : Response(org.folio.inventory.support.http.client.Response) CoreMatchers.is(org.hamcrest.CoreMatchers.is) ApiTestSuite.getCanCirculateLoanType(api.ApiTestSuite.getCanCirculateLoanType) InstanceSamples.nod(api.support.InstanceSamples.nod) CoreMatchers(org.hamcrest.CoreMatchers) ApiTestSuite(api.ApiTestSuite) DateTimeZone(org.joda.time.DateTimeZone) URL(java.net.URL) ApiTestSuite.getDvdMaterialType(api.ApiTestSuite.getDvdMaterialType) ApiTestSuite.getMainLibraryLocation(api.ApiTestSuite.getMainLibraryLocation) TimeoutException(java.util.concurrent.TimeoutException) JsonArrayHelper(org.folio.inventory.support.JsonArrayHelper) DATE_KEY(org.folio.inventory.domain.items.CirculationNote.DATE_KEY) Item(org.folio.inventory.domain.items.Item) StringUtils(org.apache.commons.lang3.StringUtils) USER_ID(api.ApiTestSuite.USER_ID) InstanceSamples.girlOnTheTrain(api.support.InstanceSamples.girlOnTheTrain) FIRST_NAME_KEY(org.folio.inventory.domain.user.Personal.FIRST_NAME_KEY) Seconds(org.joda.time.Seconds) JsonObject(io.vertx.core.json.JsonObject) JUnitParamsRunner(junitparams.JUnitParamsRunner) NOTE_TYPE_KEY(org.folio.inventory.domain.items.CirculationNote.NOTE_TYPE_KEY) STAFF_ONLY_KEY(org.folio.inventory.domain.items.CirculationNote.STAFF_ONLY_KEY) ApiRoot(api.support.ApiRoot) CIRCULATION_NOTES_KEY(org.folio.inventory.domain.items.Item.CIRCULATION_NOTES_KEY) ItemRequestBuilder(api.support.builders.ItemRequestBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) ID_KEY(org.folio.inventory.domain.user.User.ID_KEY) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) InstanceSamples.smallAngryPlanet(api.support.InstanceSamples.smallAngryPlanet) Assert.assertFalse(org.junit.Assert.assertFalse) IndividualResource(org.folio.inventory.support.http.client.IndividualResource) StringUtil.urlEncode(org.folio.util.StringUtil.urlEncode) Parameters(junitparams.Parameters) LAST_NAME_KEY(org.folio.inventory.domain.user.Personal.LAST_NAME_KEY) ResponseMatchers.hasValidationError(support.matchers.ResponseMatchers.hasValidationError) SOURCE_KEY(org.folio.inventory.domain.items.CirculationNote.SOURCE_KEY) ApiTestSuite.getReadingRoomLocation(api.ApiTestSuite.getReadingRoomLocation) CoreMatchers.not(org.hamcrest.CoreMatchers.not) RunWith(org.junit.runner.RunWith) Response(org.folio.inventory.support.http.client.Response) PERSONAL_KEY(org.folio.inventory.domain.user.User.PERSONAL_KEY) InstanceApiClient(api.support.InstanceApiClient) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) BusinessLogicInterfaceUrls.items(api.support.http.BusinessLogicInterfaceUrls.items) HoldingRequestBuilder(api.support.builders.HoldingRequestBuilder) MalformedURLException(java.net.MalformedURLException) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) Assert.assertNotNull(org.junit.Assert.assertNotNull) DateTime(org.joda.time.DateTime) Test(org.junit.Test) NOTE_KEY(org.folio.inventory.domain.items.CirculationNote.NOTE_KEY) ApiTests(api.support.ApiTests) ExecutionException(java.util.concurrent.ExecutionException) JsonArray(io.vertx.core.json.JsonArray) Matchers.hasItem(org.hamcrest.Matchers.hasItem) TextDateTimeMatcher.withinSecondsAfter(support.matchers.TextDateTimeMatcher.withinSecondsAfter) Assert(org.junit.Assert) ApiTestSuite.getThirdFloorLocation(api.ApiTestSuite.getThirdFloorLocation) SECONDS(java.util.concurrent.TimeUnit.SECONDS) HoldingRequestBuilder(api.support.builders.HoldingRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) ItemRequestBuilder(api.support.builders.ItemRequestBuilder) Test(org.junit.Test)

Aggregations

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 ApiRoot (api.support.ApiRoot)1 ApiTests (api.support.ApiTests)1 InstanceApiClient (api.support.InstanceApiClient)1 InstanceSamples.girlOnTheTrain (api.support.InstanceSamples.girlOnTheTrain)1 InstanceSamples.nod (api.support.InstanceSamples.nod)1 InstanceSamples.smallAngryPlanet (api.support.InstanceSamples.smallAngryPlanet)1 HoldingRequestBuilder (api.support.builders.HoldingRequestBuilder)1 ItemRequestBuilder (api.support.builders.ItemRequestBuilder)1 BusinessLogicInterfaceUrls.items (api.support.http.BusinessLogicInterfaceUrls.items)1 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1