Skip to content

Commit d8309ff

Browse files
committed
Added a test to ensure we can find anonymous pulse responses without causing an internal error.
1 parent ca5bc15 commit d8309ff

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

server/src/test/java/com/objectcomputing/checkins/services/fixture/PulseResponseFixture.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ default PulseResponse createADefaultPulseResponse(MemberProfile memberprofile) {
1010
return getPulseResponseRepository().save(new PulseResponse(0, 0, LocalDate.now(),
1111
memberprofile.getId(), "internalfeelings", "externalfeelings"));
1212
}
13+
14+
default PulseResponse createADefaultAnonymousPulseResponse() {
15+
return getPulseResponseRepository().save(new PulseResponse(0, 0, LocalDate.now(),
16+
null, "internalfeelings", "externalfeelings"));
17+
}
1318
}

server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,22 @@ void testGetFindByfindBySubmissionDateBetween() {
286286
assertEquals(Set.of(pulseResponse), response.body());
287287
}
288288

289+
@Test
290+
void testAnonymousGetFindByfindBySubmissionDateBetween() {
291+
MemberProfile memberProfile = createADefaultMemberProfile();
292+
293+
PulseResponse pulseResponse = createADefaultAnonymousPulseResponse();
294+
295+
LocalDate testDateFrom = LocalDate.of(2019, 1, 1);
296+
LocalDate testDateTo = Util.MAX.toLocalDate();
297+
298+
final HttpRequest<?> request = HttpRequest.GET(String.format("/?dateFrom=%tF&dateTo=%tF", testDateFrom, testDateTo)).basicAuth(memberProfile.getWorkEmail(), ADMIN_ROLE);
299+
final HttpResponse<Set<PulseResponse>> response = client.toBlocking().exchange(request, Argument.setOf(PulseResponse.class));
300+
301+
assertEquals(HttpStatus.OK, response.getStatus());
302+
assertEquals(Set.of(pulseResponse), response.body());
303+
}
304+
289305
@Test
290306
void testGetFindById() {
291307

0 commit comments

Comments
 (0)