Search in sources :

Example 1 with DeclareClaimedReturnedItemAsMissingRequestBuilder

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

the class DeclareClaimedReturnedItemAsMissingApiTests method cannotDeclareItemMissingWhenLoanIsNotFound.

@Test
void cannotDeclareItemMissingWhenLoanIsNotFound() {
    final String notExistentLoanId = UUID.randomUUID().toString();
    final Response response = claimItemReturnedFixture.attemptDeclareClaimedReturnedItemAsMissing(new DeclareClaimedReturnedItemAsMissingRequestBuilder().forLoan(notExistentLoanId).withComment(TESTING_COMMENT));
    assertThat(response.getStatusCode(), is(404));
}
Also used : Response(org.folio.circulation.support.http.client.Response) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DeclareClaimedReturnedItemAsMissingRequestBuilder(api.support.builders.DeclareClaimedReturnedItemAsMissingRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with DeclareClaimedReturnedItemAsMissingRequestBuilder

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

the class DeclareClaimedReturnedItemAsMissingApiTests method cannotDeclareItemMissingWhenCommentIsNotProvided.

@Test
void cannotDeclareItemMissingWhenCommentIsNotProvided() {
    final Response response = claimItemReturnedFixture.attemptDeclareClaimedReturnedItemAsMissing(new DeclareClaimedReturnedItemAsMissingRequestBuilder().forLoan(loanId));
    assertThat(response.getStatusCode(), is(422));
    assertThat(response.getJson(), hasErrorWith(hasMessage("Comment is a required field")));
    assertThat(response.getJson(), hasErrorWith(hasParameter("comment", null)));
}
Also used : Response(org.folio.circulation.support.http.client.Response) DeclareClaimedReturnedItemAsMissingRequestBuilder(api.support.builders.DeclareClaimedReturnedItemAsMissingRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with DeclareClaimedReturnedItemAsMissingRequestBuilder

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

the class DeclareClaimedReturnedItemAsMissingApiTests method cannotDeclareItemMissingWhenLoanIsClosed.

@Test
void cannotDeclareItemMissingWhenLoanIsClosed() {
    checkInFixture.checkInByBarcode(item);
    final Response response = claimItemReturnedFixture.attemptDeclareClaimedReturnedItemAsMissing(new DeclareClaimedReturnedItemAsMissingRequestBuilder().forLoan(loanId).withComment(TESTING_COMMENT));
    assertThat(response.getStatusCode(), is(422));
    assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Loan is closed"), hasParameter("loanId", loanId))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) DeclareClaimedReturnedItemAsMissingRequestBuilder(api.support.builders.DeclareClaimedReturnedItemAsMissingRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with DeclareClaimedReturnedItemAsMissingRequestBuilder

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

the class DeclareClaimedReturnedItemAsMissingApiTests method canDeclareItemMissingWhenClaimedReturned.

@Test
void canDeclareItemMissingWhenClaimedReturned() {
    claimItemReturnedFixture.claimItemReturned(new ClaimItemReturnedRequestBuilder().forLoan(loanId).withItemClaimedReturnedDate(getZonedDateTime()));
    claimItemReturnedFixture.declareClaimedReturnedItemAsMissing(new DeclareClaimedReturnedItemAsMissingRequestBuilder().forLoan(loanId).withComment(TESTING_COMMENT));
    assertLoanIsClosed(TESTING_COMMENT);
    assertItemIsMissing();
    assertNoteHasBeenCreated();
    var loan = loansClient.getById(UUID.fromString(loanId)).getJson();
    assertThatPublishedLoanLogRecordEventsAreValid(loan);
}
Also used : ClaimItemReturnedRequestBuilder(api.support.builders.ClaimItemReturnedRequestBuilder) DeclareClaimedReturnedItemAsMissingRequestBuilder(api.support.builders.DeclareClaimedReturnedItemAsMissingRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 5 with DeclareClaimedReturnedItemAsMissingRequestBuilder

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

the class DeclareClaimedReturnedItemAsMissingApiTests method cannotDeclareItemMissingWhenIsNotClaimedReturned.

@Test
void cannotDeclareItemMissingWhenIsNotClaimedReturned() {
    final Response response = claimItemReturnedFixture.attemptDeclareClaimedReturnedItemAsMissing(new DeclareClaimedReturnedItemAsMissingRequestBuilder().forLoan(loanId).withComment(TESTING_COMMENT));
    assertThat(response.getStatusCode(), is(422));
    assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Item is not Claimed returned"), hasParameter("itemId", item.getId().toString()))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) DeclareClaimedReturnedItemAsMissingRequestBuilder(api.support.builders.DeclareClaimedReturnedItemAsMissingRequestBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

DeclareClaimedReturnedItemAsMissingRequestBuilder (api.support.builders.DeclareClaimedReturnedItemAsMissingRequestBuilder)6 Test (org.junit.jupiter.api.Test)6 Response (org.folio.circulation.support.http.client.Response)5 ClaimItemReturnedRequestBuilder (api.support.builders.ClaimItemReturnedRequestBuilder)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1