Search in sources :

Example 1 with CheckInByBarcodeRequestBuilder

use of api.support.builders.CheckInByBarcodeRequestBuilder in project mod-circulation by folio-org.

the class CheckInFixture method checkInByBarcode.

public void checkInByBarcode(IndividualResource item, ZonedDateTime checkInDate, UUID servicePointId, OkapiHeaders okapiHeaders) {
    final JsonObject representation = new CheckInByBarcodeRequestBuilder().forItem(item).on(checkInDate).at(servicePointId).create();
    restAssuredClient.post(representation, checkInByBarcodeUrl(), 200, okapiHeaders);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder)

Example 2 with CheckInByBarcodeRequestBuilder

use of api.support.builders.CheckInByBarcodeRequestBuilder in project mod-circulation by folio-org.

the class JsonSchemaValidationTest method validationFailsWhenRequiredPropertyMissing.

@Test
void validationFailsWhenRequiredPropertyMissing() throws IOException {
    final JsonSchemaValidator validator = JsonSchemaValidator.fromResource("/check-in-by-barcode-request.json");
    final JsonObject checkInRequest = new CheckInByBarcodeRequestBuilder().withItemBarcode("246650492").on(ClockUtil.getZonedDateTime()).atNoServicePoint().create();
    final Result<String> result = validator.validate(checkInRequest.encode());
    assertThat(result.succeeded(), is(false));
    assertThat(result.cause(), isErrorWith(allOf(hasMessage("#: required key [servicePointId] not found"), hasParameter(null, null))));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with CheckInByBarcodeRequestBuilder

use of api.support.builders.CheckInByBarcodeRequestBuilder in project mod-circulation by folio-org.

the class JsonSchemaValidationTest method validationSucceedWithCompleteExample.

@Test
void validationSucceedWithCompleteExample() throws IOException {
    final JsonSchemaValidator validator = JsonSchemaValidator.fromResource("/check-in-by-barcode-request.json");
    final JsonObject checkInRequest = new CheckInByBarcodeRequestBuilder().withItemBarcode("246650492").on(ClockUtil.getZonedDateTime()).at(UUID.randomUUID()).create();
    assertThat(validator.validate(checkInRequest.encode()), succeeded());
}
Also used : JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with CheckInByBarcodeRequestBuilder

use of api.support.builders.CheckInByBarcodeRequestBuilder in project mod-circulation by folio-org.

the class JsonSchemaValidationTest method validationFailsForMultipleReasons.

@Test
void validationFailsForMultipleReasons() throws IOException {
    final JsonSchemaValidator validator = JsonSchemaValidator.fromResource("/check-in-by-barcode-request.json");
    final JsonObject checkInRequest = new CheckInByBarcodeRequestBuilder().withItemBarcode("246650492").on(ClockUtil.getZonedDateTime()).atNoServicePoint().create();
    checkInRequest.put("unexpectedProperty", "foo");
    final Result<String> result = validator.validate(checkInRequest.encode());
    assertThat(result.succeeded(), is(false));
    assertThat(result.cause(), isErrorWith(allOf(hasMessage("#: extraneous key [unexpectedProperty] is not permitted"), hasParameter(null, null))));
    assertThat(result.cause(), isErrorWith(allOf(hasMessage("#: required key [servicePointId] not found"), hasParameter(null, null))));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 5 with CheckInByBarcodeRequestBuilder

use of api.support.builders.CheckInByBarcodeRequestBuilder in project mod-circulation by folio-org.

the class ItemsInTransitReportTests method reportIncludesItemInTransit.

@Test
void reportIncludesItemInTransit() {
    final ItemResource smallAngryPlanet = createSmallAngryPlanet();
    final IndividualResource steve = usersFixture.steve();
    final UUID firstServicePointId = servicePointsFixture.cd1().getId();
    final UUID secondServicePointId = servicePointsFixture.cd2().getId();
    final ZonedDateTime checkInDate = ZonedDateTime.of(2019, 8, 13, 5, 0, 0, 0, UTC);
    final ZonedDateTime requestDate = ZonedDateTime.of(2019, 7, 5, 10, 0, 0, 0, UTC);
    final LocalDate requestExpirationDate = LocalDate.of(2019, 7, 11);
    checkOutFixture.checkOutByBarcode(smallAngryPlanet);
    createRequest(smallAngryPlanet, steve, secondServicePointId, requestDate, requestExpirationDate);
    mockClockManagerToReturnFixedDateTime(checkInDate);
    checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(smallAngryPlanet).on(checkInDate).at(firstServicePointId));
    List<JsonObject> items = ResourceClient.forItemsInTransitReport().getAll();
    assertThat(items.size(), is(1));
    JsonObject itemJson = items.get(0);
    verifyItem(itemJson, smallAngryPlanet, secondServicePointId);
    verifyLocation(itemJson);
    verifyRequestWithSecondPickupServicePoint(itemJson, requestDate, requestExpirationDate);
    verifyLoanInFirstServicePoint(itemJson, checkInDate);
    verifyLastCheckIn(itemJson, checkInDate, SERVICE_POINT_NAME_1);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) LocalDate(java.time.LocalDate) Test(org.junit.jupiter.api.Test)

Aggregations

CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)79 Test (org.junit.jupiter.api.Test)71 IndividualResource (api.support.http.IndividualResource)61 JsonObject (io.vertx.core.json.JsonObject)60 UUID (java.util.UUID)33 ZonedDateTime (java.time.ZonedDateTime)26 CheckInByBarcodeResponse (api.support.CheckInByBarcodeResponse)23 ItemResource (api.support.http.ItemResource)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 Response (org.folio.circulation.support.http.client.Response)18 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)15 RequestBuilder (api.support.builders.RequestBuilder)14 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)11 FeeFineBuilder (api.support.builders.FeeFineBuilder)8 FeeFineOwnerBuilder (api.support.builders.FeeFineOwnerBuilder)8 LocalDate (java.time.LocalDate)7 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)5 UserResource (api.support.http.UserResource)3 JsonObjectMatcher (api.support.matchers.JsonObjectMatcher)3 HashMap (java.util.HashMap)3