Skip to content

Commit

Permalink
CIRC-2148: test case added partial for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
kapil-epam committed Sep 19, 2024
1 parent f7534b9 commit 06a6a98
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
37 changes: 37 additions & 0 deletions src/test/java/api/requests/RequestsAPIRetrievalTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
45 changes: 42 additions & 3 deletions src/test/java/api/support/builders/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
);
}

Expand Down Expand Up @@ -191,6 +195,10 @@ public JsonObject create() {
}
}

if (printDetails != null) {
put(request, "printDetails", printDetails.toJsonObject());
}

return request;
}

Expand Down Expand Up @@ -321,4 +329,35 @@ private static class PatronSummary {
public static class Tags {
private final List<String> 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;
}
}
}

0 comments on commit 06a6a98

Please sign in to comment.