From 06a6a9834086c12d530e45bbe85c36d74a69e564 Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Thu, 19 Sep 2024 11:44:54 +0530 Subject: [PATCH] CIRC-2148: test case added partial for debug --- .../requests/RequestsAPIRetrievalTests.java | 37 +++++++++++++++ .../api/support/builders/RequestBuilder.java | 45 +++++++++++++++++-- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/src/test/java/api/requests/RequestsAPIRetrievalTests.java b/src/test/java/api/requests/RequestsAPIRetrievalTests.java index 6605d72546..6aa1b94bc8 100644 --- a/src/test/java/api/requests/RequestsAPIRetrievalTests.java +++ b/src/test/java/api/requests/RequestsAPIRetrievalTests.java @@ -869,4 +869,41 @@ private void assertThatRequestsHavePatronComments(MultipleJsonRecords requests) hasJsonPath("patronComments", "Comment 5") )); } + + + @Test + void printDetailsTest() { + UUID printDetailsRequester = usersFixture.charlotte().getId(); + final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet(); + + final IndividualResource workAddressType = addressTypesFixture.work(); + + final IndividualResource charlotte = usersFixture.charlotte( + builder -> builder.withAddress( + new Address(workAddressType.getId(), + "Fake first address line", + "Fake second address line", + "Fake city", + "Fake region", + "Fake postal code", + "Fake country code"))); + + + requestsFixture.place(new RequestBuilder() + .page() + .forItem(smallAngryPlanet) + .deliverToAddress(workAddressType.getId()) + .by(charlotte) + .withPrintDetails(new RequestBuilder.PrintDetails(49, printDetailsRequester.toString(), true, "2024-09-16T11:58:22" + + ".295+00:00"))); + + final MultipleJsonRecords requests = requestsFixture.getRequests( + queryFromTemplate("requestType==%s", "Page"), + noLimit(), noOffset()); + + assertThat(requests.size(), is(1)); + assertThat(requests.totalRecords(), is(1)); + + requests.forEach(this::requestHasExpectedProperties); + } } diff --git a/src/test/java/api/support/builders/RequestBuilder.java b/src/test/java/api/support/builders/RequestBuilder.java index 2514482a1e..96083b1788 100644 --- a/src/test/java/api/support/builders/RequestBuilder.java +++ b/src/test/java/api/support/builders/RequestBuilder.java @@ -63,10 +63,11 @@ public class RequestBuilder extends JsonBuilder implements Builder { private final Tags tags; private final String patronComments; private final BlockOverrides blockOverrides; + private final PrintDetails printDetails; public RequestBuilder() { this(UUID.randomUUID(), - "Hold", + "Holdkapil", "Item", ZonedDateTime.of(2017, 7, 15, 9, 35, 27, 0, UTC), UUID.randomUUID(), @@ -89,7 +90,9 @@ public RequestBuilder() { null, null, null, - null); + null, + new PrintDetails(49, UUID.randomUUID().toString(), true, "2024-09-16T11:58:22" + + ".295+00:00")); } public static RequestBuilder from(IndividualResource response) { @@ -120,7 +123,8 @@ public static RequestBuilder from(IndividualResource response) { getUUIDProperty(representation, "pickupServicePointId"), new Tags((toStream(representation.getJsonObject("tags"), "tagList").collect(toList()))), getProperty(representation, "patronComments"), - null + null, + PrintDetails.fromRepresentation(representation) ); } @@ -191,6 +195,10 @@ public JsonObject create() { } } + if (printDetails != null) { + put(request, "printDetails", printDetails.toJsonObject()); + } + return request; } @@ -321,4 +329,35 @@ private static class PatronSummary { public static class Tags { private final List tagList; } + + @AllArgsConstructor + @Getter + public static class PrintDetails { + private final Integer printCount; + private final String requesterId; + private final Boolean isPrinted; + private final String printEventDate; + + public static PrintDetails fromRepresentation(JsonObject representation) { + JsonObject printDetails = representation.getJsonObject("printDetails"); + if (printDetails != null) { + final Integer printCount = printDetails.getInteger("printCount"); + final String requesterId = printDetails.getString("requesterId"); + final Boolean isPrinted = printDetails.getBoolean("isPrinted"); + final String printEventDate = printDetails.getString("printEventDate"); + return new PrintDetails(printCount, requesterId, isPrinted, + printEventDate); + } + return null; + } + + public JsonObject toJsonObject() { + JsonObject printDetails = new JsonObject(); + printDetails.put("printCount", printCount); + printDetails.put("requesterId", requesterId); + printDetails.put("isPrinted", isPrinted); + printDetails.put("printEventDate", printEventDate); + return printDetails; + } + } }