Search in sources :

Example 1 with UserBuilder

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

the class CheckOutByBarcodeTests method cannotCheckOutByProxyWhenProxyingUserIsInactive.

@Test
void cannotCheckOutByProxyWhenProxyingUserIsInactive() {
    final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource james = usersFixture.james();
    final IndividualResource steve = usersFixture.steve(UserBuilder::inactive);
    proxyRelationshipsFixture.currentProxyFor(james, steve);
    final Response response = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(smallAngryPlanet).to(james).proxiedBy(steve).at(UUID.randomUUID()));
    assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Cannot check out via inactive proxying user"), hasProxyUserBarcodeParameter(steve))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UserBuilder(api.support.builders.UserBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with UserBuilder

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

the class DueDateScheduledNoticesProcessingTests method testNoticesForNullPatronGroupsDoNotBlockTheQueue.

@Test
void testNoticesForNullPatronGroupsDoNotBlockTheQueue() {
    generateLoanAndScheduledNotices();
    int expectedNumberOfUnprocessedNotices = 0;
    List<JsonObject> notices = createNoticesOverTime(dueDate.minusMinutes(1)::minusHours, 4);
    var basedUponNod = itemsFixture.basedUponNod();
    var jessica = usersFixture.jessica();
    var jessicaNodLoan = checkOutFixture.checkOutByBarcode(basedUponNod, jessica);
    usersClient.replace(borrower.getId(), new UserBuilder().withPatronGroupId(null));
    notices.get(1).put("loanId", jessicaNodLoan.getId());
    notices.get(3).put("loanId", jessicaNodLoan.getId());
    notices.get(3).put("recipientUserId", jessica.getId().toString());
    notices.get(1).put("recipientUserId", jessica.getId().toString());
    notices.forEach(scheduledNoticesClient::create);
    scheduledNoticeProcessingClient.runLoanNoticesProcessing(dueDate.minusSeconds(1));
    UUID expectedSentTemplateId1 = UUID.fromString(notices.get(1).getJsonObject("noticeConfig").getString("templateId"));
    UUID expectedSentTemplateId2 = UUID.fromString(notices.get(3).getJsonObject("noticeConfig").getString("templateId"));
    checkSentNotices(basedUponNod, jessica, jessicaNodLoan, expectedSentTemplateId1, expectedSentTemplateId2);
    verifyNumberOfSentNotices(2);
    verifyNumberOfScheduledNotices(expectedNumberOfUnprocessedNotices);
    verifyNumberOfPublishedEvents(NOTICE, 2);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 2);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) UserBuilder(api.support.builders.UserBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with UserBuilder

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

the class DueDateScheduledNoticesProcessingTests method testNoticeIsDeletedIfPatronGroupIsNull.

@Test
void testNoticeIsDeletedIfPatronGroupIsNull() {
    generateLoanAndScheduledNotices();
    JsonObject brokenNotice = createNoticesOverTime(dueDate.minusMinutes(1)::minusHours, 1).get(0);
    usersClient.replace(borrower.getId(), new UserBuilder().withPatronGroupId(null));
    scheduledNoticesClient.create(brokenNotice);
    scheduledNoticeProcessingClient.runLoanNoticesProcessing(dueDate.minusSeconds(1));
    verifyNumberOfSentNotices(0);
    verifyNumberOfScheduledNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 0);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 1);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) UserBuilder(api.support.builders.UserBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with UserBuilder

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

the class UserAddressTests method addressFoundWhenOtherAddressesAreDifferentTypes.

@Test
void addressFoundWhenOtherAddressesAreDifferentTypes() {
    final User user = new User(new UserBuilder().withAddress(SiriusBlack()).withAddress(patriciansPalace()).withAddress(RamkinResidence()).create());
    JsonObject foundAddress = user.getAddressByType(WORK_ADDRESS_TYPE.toString());
    assertThat("Should find address", foundAddress, notNullValue());
    assertThat(foundAddress.getString("addressTypeId"), is(WORK_ADDRESS_TYPE));
    assertThat(foundAddress.getString("addressLine1"), is("Patrician's Palace"));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) UserBuilder(api.support.builders.UserBuilder) Test(org.junit.jupiter.api.Test)

Example 5 with UserBuilder

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

the class UserAddressTests method firstAddressFoundWhenMultipleAddressesOfSameType.

@Test
void firstAddressFoundWhenMultipleAddressesOfSameType() {
    final User user = new User(new UserBuilder().withAddress(SiriusBlack()).withAddress(RamkinResidence()).create());
    JsonObject foundAddress = user.getAddressByType(HOME_ADDRESS_TYPE.toString());
    assertThat("Should find address", foundAddress, notNullValue());
    assertThat(foundAddress.getString("addressTypeId"), is(HOME_ADDRESS_TYPE));
    assertThat(foundAddress.getString("addressLine1"), is("12 Grimmauld Place"));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) UserBuilder(api.support.builders.UserBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

UserBuilder (api.support.builders.UserBuilder)19 Test (org.junit.jupiter.api.Test)18 JsonObject (io.vertx.core.json.JsonObject)11 IndividualResource (api.support.http.IndividualResource)6 ZonedDateTime (java.time.ZonedDateTime)6 UUID (java.util.UUID)6 Response (org.folio.circulation.support.http.client.Response)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 RequestBuilder (api.support.builders.RequestBuilder)5 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)3 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)3 Address (api.support.builders.Address)2 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)1 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)1 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)1 ItemResource (api.support.http.ItemResource)1 UserResource (api.support.http.UserResource)1 JsonArray (io.vertx.core.json.JsonArray)1 lombok.val (lombok.val)1 InstanceMapper (org.folio.circulation.storage.mappers.InstanceMapper)1