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))));
}
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);
}
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);
}
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"));
}
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"));
}
Aggregations