Search in sources :

Example 1 with UserManualBlockBuilder

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

the class RequestsAPICreationTests method canCreateRequestWhenRequesterNotHaveActiveManualBlocks.

@Test
void canCreateRequestWhenRequesterNotHaveActiveManualBlocks() {
    final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource requester = usersFixture.rebecca();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    final ZonedDateTime now = ClockUtil.getZonedDateTime();
    final ZonedDateTime expirationDate = now.plusDays(4);
    final UserManualBlockBuilder userManualBlockBuilder = getManualBlockBuilder().withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
    final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    userManualBlocksFixture.create(userManualBlockBuilder);
    Response postResponse = requestsClient.attemptCreate(requestBuilder);
    assertThat(postResponse, hasStatus(HTTP_CREATED));
}
Also used : Response(org.folio.circulation.support.http.client.Response) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UserManualBlockBuilder(api.support.builders.UserManualBlockBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with UserManualBlockBuilder

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

the class RequestsAPICreationTests method cannotCreateRequestWhenRequesterHasSomeActiveRequestManualBlocks.

@Test
void cannotCreateRequestWhenRequesterHasSomeActiveRequestManualBlocks() {
    final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource requester = usersFixture.rebecca();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    final ZonedDateTime now = ClockUtil.getZonedDateTime();
    final ZonedDateTime expirationDate = now.plusDays(4);
    final UserManualBlockBuilder requestUserManualBlockBuilder1 = getManualBlockBuilder().withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
    final UserManualBlockBuilder requestUserManualBlockBuilder2 = getManualBlockBuilder().withBorrowing(true).withRenewals(true).withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId())).withDesc("Test");
    final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    userManualBlocksFixture.create(requestUserManualBlockBuilder1);
    userManualBlocksFixture.create(requestUserManualBlockBuilder2);
    Response postResponse = requestsClient.attemptCreate(requestBuilder);
    assertThat(postResponse, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
    assertThat(postResponse.getJson(), hasErrors(1));
    assertThat(postResponse.getJson(), hasErrorWith(hasMessage("Patron blocked from requesting")));
}
Also used : Response(org.folio.circulation.support.http.client.Response) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UserManualBlockBuilder(api.support.builders.UserManualBlockBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with UserManualBlockBuilder

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

the class RequestsAPICreationTests method canCreateRequestWhenRequesterHasManualExpiredBlock.

@Test
void canCreateRequestWhenRequesterHasManualExpiredBlock() {
    final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource requester = usersFixture.rebecca();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    final ZonedDateTime now = ClockUtil.getZonedDateTime();
    final ZonedDateTime expirationDate = now.minusDays(1);
    final UserManualBlockBuilder userManualBlockBuilder = getManualBlockBuilder().withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
    final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    userManualBlocksFixture.create(userManualBlockBuilder);
    Response postResponse = requestsClient.attemptCreate(requestBuilder);
    assertThat(postResponse, hasStatus(HTTP_CREATED));
}
Also used : Response(org.folio.circulation.support.http.client.Response) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UserManualBlockBuilder(api.support.builders.UserManualBlockBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 4 with UserManualBlockBuilder

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

the class RequestsAPICreationTests method cannotCreateRequestWhenRequesterHasActiveRequestManualBlocks.

@Test
void cannotCreateRequestWhenRequesterHasActiveRequestManualBlocks() {
    final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource requester = usersFixture.rebecca();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    final ZonedDateTime now = ClockUtil.getZonedDateTime();
    final ZonedDateTime expirationDate = now.plusDays(4);
    final UserManualBlockBuilder userManualBlockBuilder = getManualBlockBuilder().withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
    final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    userManualBlocksFixture.create(userManualBlockBuilder);
    Response postResponse = requestsClient.attemptCreate(requestBuilder);
    assertThat(postResponse, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
    assertThat(postResponse.getJson(), hasErrors(1));
    assertThat(postResponse.getJson(), hasErrorWith(allOf(hasMessage("Patron blocked from requesting"), hasParameter("reason", "Display description"))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UserManualBlockBuilder(api.support.builders.UserManualBlockBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 5 with UserManualBlockBuilder

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

the class RequestsAPICreationTests method canCreateRequestWhenRequesterNoHaveRequestBlockAndHaveBorrowingRenewalsBlock.

@Test
void canCreateRequestWhenRequesterNoHaveRequestBlockAndHaveBorrowingRenewalsBlock() {
    final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource requester = usersFixture.rebecca();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    final ZonedDateTime now = ClockUtil.getZonedDateTime();
    final ZonedDateTime expirationDate = now.plusDays(7);
    final UserManualBlockBuilder borrowingUserManualBlockBuilder = getManualBlockBuilder().withBorrowing(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
    final UserManualBlockBuilder renewalsUserManualBlockBuilder = getManualBlockBuilder().withRenewals(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
    final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    userManualBlocksFixture.create(borrowingUserManualBlockBuilder);
    userManualBlocksFixture.create(renewalsUserManualBlockBuilder);
    Response postResponse = requestsClient.attemptCreate(requestBuilder);
    assertThat(postResponse, hasStatus(HTTP_CREATED));
}
Also used : Response(org.folio.circulation.support.http.client.Response) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UserManualBlockBuilder(api.support.builders.UserManualBlockBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

MoveRequestBuilder (api.support.builders.MoveRequestBuilder)5 RequestBuilder (api.support.builders.RequestBuilder)5 UserManualBlockBuilder (api.support.builders.UserManualBlockBuilder)5 IndividualResource (api.support.http.IndividualResource)5 ZonedDateTime (java.time.ZonedDateTime)5 UUID (java.util.UUID)5 Response (org.folio.circulation.support.http.client.Response)5 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)5 Test (org.junit.jupiter.api.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5