diff --git a/src/test/java/api/requests/RequestsAPICreationTests.java b/src/test/java/api/requests/RequestsAPICreationTests.java index 3737cf8dc7..7b08979d85 100644 --- a/src/test/java/api/requests/RequestsAPICreationTests.java +++ b/src/test/java/api/requests/RequestsAPICreationTests.java @@ -229,7 +229,10 @@ void canCreateARequest() { .withHoldShelfExpiration(LocalDate.of(2017, 8, 31)) .withPickupServicePointId(pickupServicePointId) .withTags(new RequestBuilder.Tags(asList("new", "important"))) - .withPatronComments("I need this book")); + .withPatronComments("I need this book") + .withPrintDetails(new RequestBuilder.PrintDetails(49, + requester.getId().toString(), true, "2024-09-16T11:58:22" + + ".295+00:00"))); JsonObject representation = request.getJson(); diff --git a/src/test/java/api/requests/RequestsAPIRetrievalTests.java b/src/test/java/api/requests/RequestsAPIRetrievalTests.java index 6aa1b94bc8..cb9ad9db12 100644 --- a/src/test/java/api/requests/RequestsAPIRetrievalTests.java +++ b/src/test/java/api/requests/RequestsAPIRetrievalTests.java @@ -1,5 +1,24 @@ package api.requests; +import api.support.APITests; +import api.support.MultipleJsonRecords; +import api.support.builders.Address; +import api.support.builders.ItemBuilder; +import api.support.builders.RequestBuilder; +import api.support.http.IndividualResource; +import api.support.http.ItemResource; +import api.support.http.UserResource; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import org.folio.circulation.support.http.client.Response; +import org.hamcrest.CoreMatchers; +import org.junit.jupiter.api.Test; + +import java.net.HttpURLConnection; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.UUID; + import static api.support.builders.ItemBuilder.CHECKED_OUT; import static api.support.fixtures.ConfigurationExample.newYorkTimezoneConfiguration; import static api.support.http.CqlQuery.noQuery; @@ -26,26 +45,6 @@ import static org.hamcrest.core.Is.is; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.net.HttpURLConnection; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.util.UUID; - -import org.folio.circulation.support.http.client.Response; -import org.hamcrest.CoreMatchers; -import org.junit.jupiter.api.Test; - -import api.support.APITests; -import api.support.MultipleJsonRecords; -import api.support.TlrFeatureStatus; -import api.support.builders.Address; -import api.support.builders.ItemBuilder; -import api.support.builders.RequestBuilder; -import api.support.http.IndividualResource; -import api.support.http.ItemResource; -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; - class RequestsAPIRetrievalTests extends APITests { private static final String NEW_TAG = "new"; private static final String IMPORTANT_TAG = "important"; @@ -873,7 +872,8 @@ private void assertThatRequestsHavePatronComments(MultipleJsonRecords requests) @Test void printDetailsTest() { - UUID printDetailsRequester = usersFixture.charlotte().getId(); + UserResource printDetailsRequester = usersFixture.charlotte(); + UUID printDetailsRequesterId = printDetailsRequester.getId(); final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet(); final IndividualResource workAddressType = addressTypesFixture.work(); @@ -894,16 +894,31 @@ void printDetailsTest() { .forItem(smallAngryPlanet) .deliverToAddress(workAddressType.getId()) .by(charlotte) - .withPrintDetails(new RequestBuilder.PrintDetails(49, printDetailsRequester.toString(), true, "2024-09-16T11:58:22" + + .withPrintDetails(new RequestBuilder.PrintDetails(49, printDetailsRequesterId.toString(), true, "2024-09-16T11:58:22" + ".295+00:00"))); + final MultipleJsonRecords requests = requestsFixture.getRequests( - queryFromTemplate("requestType==%s", "Page"), + queryFromTemplate("printDetails.isPrinted==%s", "true"), noLimit(), noOffset()); assertThat(requests.size(), is(1)); assertThat(requests.totalRecords(), is(1)); - requests.forEach(this::requestHasExpectedProperties); + JsonObject printDetails = requests.getFirst().getJsonObject("printDetails"); + assertThat(printDetails.getInteger("printCount"), is(49)); + assertThat(printDetails.getString("requesterId"), + is(printDetailsRequesterId.toString())); + assertTrue(printDetails.getBoolean("isPrinted")); + + JsonObject lastPrintRequester = printDetails.getJsonObject( + "lastPrintRequester"); + JsonObject expectedLastPrintRequester = printDetailsRequester.getJson() + .getJsonObject("personal"); + + assertThat(lastPrintRequester.getString("firstName"), + is(expectedLastPrintRequester.getString("firstName"))); + assertThat(lastPrintRequester.getString("lastName"), + is(expectedLastPrintRequester.getString("lastName"))); } } diff --git a/src/test/java/api/support/builders/RequestBuilder.java b/src/test/java/api/support/builders/RequestBuilder.java index 96083b1788..180de0a22b 100644 --- a/src/test/java/api/support/builders/RequestBuilder.java +++ b/src/test/java/api/support/builders/RequestBuilder.java @@ -67,7 +67,7 @@ public class RequestBuilder extends JsonBuilder implements Builder { public RequestBuilder() { this(UUID.randomUUID(), - "Holdkapil", + "Hold", "Item", ZonedDateTime.of(2017, 7, 15, 9, 35, 27, 0, UTC), UUID.randomUUID(), @@ -91,8 +91,7 @@ public RequestBuilder() { null, null, null, - new PrintDetails(49, UUID.randomUUID().toString(), true, "2024-09-16T11:58:22" + - ".295+00:00")); + null); } public static RequestBuilder from(IndividualResource response) {