From d8309fff05e54360fa549b356f566fbb5137e2de Mon Sep 17 00:00:00 2001 From: Chad Elliott Date: Wed, 15 Jan 2025 17:11:47 -0600 Subject: [PATCH] Added a test to ensure we can find anonymous pulse responses without causing an internal error. --- .../services/fixture/PulseResponseFixture.java | 5 +++++ .../PulseResponseControllerTest.java | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/server/src/test/java/com/objectcomputing/checkins/services/fixture/PulseResponseFixture.java b/server/src/test/java/com/objectcomputing/checkins/services/fixture/PulseResponseFixture.java index f3e2d667c1..17cee762a9 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/fixture/PulseResponseFixture.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/fixture/PulseResponseFixture.java @@ -10,4 +10,9 @@ default PulseResponse createADefaultPulseResponse(MemberProfile memberprofile) { return getPulseResponseRepository().save(new PulseResponse(0, 0, LocalDate.now(), memberprofile.getId(), "internalfeelings", "externalfeelings")); } + + default PulseResponse createADefaultAnonymousPulseResponse() { + return getPulseResponseRepository().save(new PulseResponse(0, 0, LocalDate.now(), + null, "internalfeelings", "externalfeelings")); + } } diff --git a/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java b/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java index 912038b5f5..904271d0c5 100644 --- a/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java +++ b/server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java @@ -286,6 +286,22 @@ void testGetFindByfindBySubmissionDateBetween() { assertEquals(Set.of(pulseResponse), response.body()); } + @Test + void testAnonymousGetFindByfindBySubmissionDateBetween() { + MemberProfile memberProfile = createADefaultMemberProfile(); + + PulseResponse pulseResponse = createADefaultAnonymousPulseResponse(); + + LocalDate testDateFrom = LocalDate.of(2019, 1, 1); + LocalDate testDateTo = Util.MAX.toLocalDate(); + + final HttpRequest request = HttpRequest.GET(String.format("/?dateFrom=%tF&dateTo=%tF", testDateFrom, testDateTo)).basicAuth(memberProfile.getWorkEmail(), ADMIN_ROLE); + final HttpResponse> response = client.toBlocking().exchange(request, Argument.setOf(PulseResponse.class)); + + assertEquals(HttpStatus.OK, response.getStatus()); + assertEquals(Set.of(pulseResponse), response.body()); + } + @Test void testGetFindById() {