use of api.support.builders.DeclareItemLostRequestBuilder in project mod-circulation by folio-org.
the class DeclareLostAPITests method declaredLostEventIsPublished.
@Test
void declaredLostEventIsPublished() {
UUID servicePointId = servicePointsFixture.cd1().getId();
final IndividualResource loanIndividualResource = checkOutFixture.checkOutByBarcode(itemsFixture.basedUponNod(), usersFixture.jessica());
final DeclareItemLostRequestBuilder builder = new DeclareItemLostRequestBuilder().forLoanId(loanIndividualResource.getId()).on(getZonedDateTime()).withServicePointId(servicePointId).withNoComment();
declareLostFixtures.declareItemLost(builder);
// There should be five events published - "check out", "log event", "declared lost"
// and one "log record"
final var publishedEvents = Awaitility.await().atMost(1, SECONDS).until(FakePubSub::getPublishedEvents, hasSize(4));
final var event = publishedEvents.findFirst(byEventType(EventTypeMatchers.ITEM_DECLARED_LOST));
final var loan = loanIndividualResource.getJson();
assertThat(event, isValidItemDeclaredLostEvent(loan));
verifyNumberOfPublishedEvents(LOAN_CLOSED, 0);
assertThatPublishedLoanLogRecordEventsAreValid(loansClient.getById(UUID.fromString(loan.getString("id"))).getJson());
}
use of api.support.builders.DeclareItemLostRequestBuilder in project mod-circulation by folio-org.
the class DeclareLostAPITests method shouldNotCreateNoteWhenNotPreviouslyClaimedReturned.
@Test
void shouldNotCreateNoteWhenNotPreviouslyClaimedReturned() {
String comment = "testing";
UUID servicePointId = servicePointsFixture.cd1().getId();
ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
UUID loanId = checkOutFixture.checkOutByBarcode(item, usersFixture.charlotte()).getId();
ZonedDateTime dateTime = getZonedDateTime();
final DeclareItemLostRequestBuilder builder = new DeclareItemLostRequestBuilder().forLoanId(loanId).on(dateTime).withServicePointId(servicePointId).withComment(comment);
declareLostFixtures.declareItemLost(builder);
assertEquals(0, notesClient.getAll().size());
}
use of api.support.builders.DeclareItemLostRequestBuilder in project mod-circulation by folio-org.
the class DeclareLostAPITests method declareItemLostFailsWhenEventPublishingFailsWithBadRequestError.
@Test
void declareItemLostFailsWhenEventPublishingFailsWithBadRequestError() {
UUID servicePointId = servicePointsFixture.cd1().getId();
final IndividualResource checkOut = checkOutFixture.checkOutByBarcode(itemsFixture.basedUponNod(), usersFixture.jessica());
final DeclareItemLostRequestBuilder builder = new DeclareItemLostRequestBuilder().forLoanId(checkOut.getId()).on(getZonedDateTime()).withComment("testing").withServicePointId(servicePointId);
FakePubSub.setFailPublishingWithBadRequestError(true);
Response response = declareLostFixtures.attemptDeclareItemLost(500, builder);
assertThat(response.getBody(), containsString("Error during publishing Event Message in PubSub. Status code: 400"));
}
use of api.support.builders.DeclareItemLostRequestBuilder in project mod-circulation by folio-org.
the class DeclareLostAPITests method shouldReturn404IfLoanIsNotFound.
@Test
void shouldReturn404IfLoanIsNotFound() {
UUID servicePointId = servicePointsFixture.cd1().getId();
final UUID loanId = UUID.randomUUID();
final DeclareItemLostRequestBuilder builder = new DeclareItemLostRequestBuilder().forLoanId(loanId).withServicePointId(servicePointId).on(getZonedDateTime()).withNoComment();
Response response = declareLostFixtures.attemptDeclareItemLost(builder);
assertThat(response.getStatusCode(), is(404));
}
use of api.support.builders.DeclareItemLostRequestBuilder in project mod-circulation by folio-org.
the class DeclareLostAPITests method cannotDeclareItemLostWhenNoAutomatedLostItemFeeTypeIsDefined.
@Test
void cannotDeclareItemLostWhenNoAutomatedLostItemFeeTypeIsDefined() {
UUID servicePointId = servicePointsFixture.cd1().getId();
feeFineTypeFixture.delete(feeFineTypeFixture.lostItemFee());
final ItemResource item = itemsFixture.basedUponNod();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(item, usersFixture.charlotte());
final Response response = declareLostFixtures.attemptDeclareItemLost(new DeclareItemLostRequestBuilder().withServicePointId(servicePointId).forLoanId(loan.getId()));
assertThat(loansFixture.getLoanById(loan.getId()).getJson(), isOpen());
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Expected automated fee of type Lost item fee"), hasParameter("feeFineType", "Lost item fee"))));
}
Aggregations