@@ -1226,13 +1226,11 @@ void testGetByCreatorRecipientIdPermittedToExternalRecipients() {
12261226 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
12271227 assignPdlRole (pdlMemberProfile );
12281228 MemberProfile requestee = createADefaultMemberProfileForPdl (pdlMemberProfile );
1229- MemberProfile recipient = createADefaultRecipient ();
12301229 final FeedbackExternalRecipient externalRecipient = createADefaultFeedbackExternalRecipient ();
12311230 FeedbackRequest feedbackRequest = saveFeedbackRequest (pdlMemberProfile , requestee , externalRecipient );
12321231
12331232 //get feedback request
12341233 final HttpRequest <?> request = HttpRequest .GET (String .format ("/?externalRecipientId=%s" , feedbackRequest .getExternalRecipientId ()));
1235- //.basicAuth(recipient.getWorkEmail(), RoleType.Constants.MEMBER_ROLE);
12361234 final HttpResponse <FeedbackRequestResponseDTO > response = clientExternalRecipient .toBlocking ().exchange (request , FeedbackRequestResponseDTO .class );
12371235
12381236 // recipient must be able to get the feedback request
@@ -1242,7 +1240,7 @@ void testGetByCreatorRecipientIdPermittedToExternalRecipients() {
12421240 }
12431241
12441242 @ Test
1245- void testGetByCreatorRequesteeIdMultiplePermitted () {
1243+ void testGetByCreatorRequesteeIdMultiplePermittedToRecipients () {
12461244 //create two employee-PDL relationships
12471245 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
12481246 assignPdlRole (pdlMemberProfile );
@@ -1270,7 +1268,35 @@ void testGetByCreatorRequesteeIdMultiplePermitted() {
12701268 }
12711269
12721270 @ Test
1273- void testGetLastThreeMonthsByCreator () {
1271+ void testGetByCreatorRequesteeIdMultiplePermittedToExternalRecipients () {
1272+ //create two employee-PDL relationships
1273+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1274+ assignPdlRole (pdlMemberProfile );
1275+ MemberProfile memberOne = createADefaultMemberProfileForPdl (pdlMemberProfile );
1276+ MemberProfile pdlMemberProfileTwo = createASecondDefaultMemberProfile ();
1277+ assignPdlRole (pdlMemberProfileTwo );
1278+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1279+ final FeedbackExternalRecipient externalRecipient02 = createASecondDefaultFeedbackExternalRecipient ();
1280+
1281+ //create two sample feedback requests by the same PDL and same requestee
1282+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient01 );
1283+ final FeedbackRequest feedbackReqTwo = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient02 );
1284+
1285+ //search for feedback requests by a specific creator, requestee
1286+ final HttpRequest <?> request = HttpRequest .GET (String .format ("/?creatorId=%s&requesteeId=%s" , feedbackReq .getCreatorId (), feedbackReq .getRequesteeId ()))
1287+ .basicAuth (pdlMemberProfile .getWorkEmail (), RoleType .Constants .PDL_ROLE );
1288+ final HttpResponse <List <FeedbackRequestResponseDTO >> response = client .toBlocking ()
1289+ .exchange (request , Argument .listOf (FeedbackRequestResponseDTO .class ));
1290+
1291+ assertEquals (HttpStatus .OK , response .getStatus ());
1292+ assertTrue (response .getBody ().isPresent ());
1293+ assertEquals (2 , response .getBody ().get ().size ());
1294+ assertResponseEqualsEntity (feedbackReq , response .getBody ().get ().get (0 ));
1295+ assertResponseEqualsEntity (feedbackReqTwo , response .getBody ().get ().get (1 ));
1296+ }
1297+
1298+ @ Test
1299+ void testGetLastThreeMonthsByCreatorToRecipients () {
12741300 //create two employee-PDL relationships
12751301 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
12761302 assignPdlRole (pdlMemberProfile );
@@ -1303,7 +1329,40 @@ void testGetLastThreeMonthsByCreator() {
13031329 }
13041330
13051331 @ Test
1306- void testGetLastThreeMonthsByCreatorRequesteeId () {
1332+ void testGetLastThreeMonthsByCreatorToExternalRecipients () {
1333+ //create two employee-PDL relationships
1334+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1335+ assignPdlRole (pdlMemberProfile );
1336+ MemberProfile memberOne = createADefaultMemberProfileForPdl (pdlMemberProfile );
1337+ MemberProfile pdlMemberProfileTwo = createASecondDefaultMemberProfile ();
1338+ assignPdlRole (pdlMemberProfileTwo );
1339+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1340+ final FeedbackExternalRecipient externalRecipient02 = createASecondDefaultFeedbackExternalRecipient ();
1341+
1342+ LocalDate now = LocalDate .now ();
1343+ LocalDate oldestDate = now .minusMonths (3 );
1344+ LocalDate withinLastFewMonths = now .minusMonths (2 );
1345+ LocalDate outOfRange = now .minusMonths (10 );
1346+
1347+ // create sample feedback requests with different send dates
1348+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient01 , now );
1349+ final FeedbackRequest feedbackReqTwo = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient02 , withinLastFewMonths );
1350+ saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient02 , outOfRange );
1351+
1352+ final HttpRequest <?> request = HttpRequest .GET (String .format ("/?creatorId=%s&oldestDate=%s" , pdlMemberProfile .getId (), oldestDate ))
1353+ .basicAuth (pdlMemberProfile .getWorkEmail (), RoleType .Constants .PDL_ROLE );
1354+ final HttpResponse <List <FeedbackRequestResponseDTO >> response = client .toBlocking ()
1355+ .exchange (request , Argument .listOf (FeedbackRequestResponseDTO .class ));
1356+
1357+ assertEquals (HttpStatus .OK , response .getStatus ());
1358+ assertTrue (response .getBody ().isPresent ());
1359+ assertEquals (2 , response .getBody ().get ().size ());
1360+ assertResponseEqualsEntity (feedbackReq , response .getBody ().get ().get (0 ));
1361+ assertResponseEqualsEntity (feedbackReqTwo , response .getBody ().get ().get (1 ));
1362+ }
1363+
1364+ @ Test
1365+ void testGetLastThreeMonthsByCreatorRequesteeIdToRecipients () {
13071366 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
13081367 assignPdlRole (pdlMemberProfile );
13091368 MemberProfile memberOne = createADefaultMemberProfileForPdl (pdlMemberProfile );
@@ -1333,7 +1392,37 @@ void testGetLastThreeMonthsByCreatorRequesteeId() {
13331392 }
13341393
13351394 @ Test
1336- void testGetLastThreeMonthsByRequesteeId () {
1395+ void testGetLastThreeMonthsByCreatorRequesteeIdToExternalRecipients () {
1396+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1397+ assignPdlRole (pdlMemberProfile );
1398+ MemberProfile memberOne = createADefaultMemberProfileForPdl (pdlMemberProfile );
1399+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1400+ final FeedbackExternalRecipient externalRecipient02 = createASecondDefaultFeedbackExternalRecipient ();
1401+
1402+ LocalDate now = LocalDate .now ();
1403+ LocalDate oldestDate = now .minusMonths (3 );
1404+ LocalDate withinLastFewMonths = now .minusMonths (2 );
1405+ LocalDate outOfRange = now .minusMonths (10 );
1406+
1407+ // create sample feedback requests with different send dates
1408+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient01 , now );
1409+ final FeedbackRequest feedbackReqTwo = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient02 , withinLastFewMonths );
1410+ saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient02 , outOfRange );
1411+
1412+ final HttpRequest <?> request = HttpRequest .GET (String .format ("/?creatorId=%s&requesteeId=%s&oldestDate=%s" , pdlMemberProfile .getId (), memberOne .getId (), oldestDate ))
1413+ .basicAuth (pdlMemberProfile .getWorkEmail (), RoleType .Constants .PDL_ROLE );
1414+ final HttpResponse <List <FeedbackRequestResponseDTO >> response = client .toBlocking ()
1415+ .exchange (request , Argument .listOf (FeedbackRequestResponseDTO .class ));
1416+
1417+ assertEquals (HttpStatus .OK , response .getStatus ());
1418+ assertTrue (response .getBody ().isPresent ());
1419+ assertEquals (2 , response .getBody ().get ().size ());
1420+ assertResponseEqualsEntity (feedbackReq , response .getBody ().get ().get (0 ));
1421+ assertResponseEqualsEntity (feedbackReqTwo , response .getBody ().get ().get (1 ));
1422+ }
1423+
1424+ @ Test
1425+ void testGetLastThreeMonthsByRequesteeIdToRecipients () {
13371426 //create two employee-PDL relationships
13381427 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
13391428 assignPdlRole (pdlMemberProfile );
@@ -1366,7 +1455,40 @@ void testGetLastThreeMonthsByRequesteeId() {
13661455 }
13671456
13681457 @ Test
1369- void testGetEveryAllTimeAdmin () {
1458+ void testGetLastThreeMonthsByRequesteeIdToExternalRecipients () {
1459+ //create two employee-PDL relationships
1460+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1461+ assignPdlRole (pdlMemberProfile );
1462+ MemberProfile memberOne = createADefaultMemberProfileForPdl (pdlMemberProfile );
1463+ MemberProfile pdlMemberProfileTwo = createASecondDefaultMemberProfile ();
1464+ assignPdlRole (pdlMemberProfileTwo );
1465+ MemberProfile memberTwo = createASecondDefaultMemberProfileForPdl (pdlMemberProfileTwo );
1466+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1467+ final FeedbackExternalRecipient externalRecipient02 = createASecondDefaultFeedbackExternalRecipient ();
1468+
1469+ LocalDate now = LocalDate .now ();
1470+ LocalDate oldestDate = now .minusMonths (3 );
1471+ LocalDate withinLastFewMonths = now .minusMonths (2 );
1472+
1473+ // create sample feedback requests with different send dates and different requestees
1474+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient01 , now );
1475+ saveFeedbackRequest (pdlMemberProfile , memberTwo , externalRecipient02 , withinLastFewMonths );
1476+ final FeedbackRequest feedbackReqThree = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient02 , withinLastFewMonths );
1477+
1478+ final HttpRequest <?> request = HttpRequest .GET (String .format ("/?creatorId=%s&requesteeId=%s&oldestDate=%s" , feedbackReq .getCreatorId (), feedbackReq .getRequesteeId (), oldestDate ))
1479+ .basicAuth (pdlMemberProfile .getWorkEmail (), RoleType .Constants .PDL_ROLE );
1480+ final HttpResponse <List <FeedbackRequestResponseDTO >> response = client .toBlocking ()
1481+ .exchange (request , Argument .listOf (FeedbackRequestResponseDTO .class ));
1482+
1483+ assertEquals (HttpStatus .OK , response .getStatus ());
1484+ assertTrue (response .getBody ().isPresent ());
1485+ assertEquals (2 , response .getBody ().get ().size ());
1486+ assertResponseEqualsEntity (feedbackReq , response .getBody ().get ().get (0 ));
1487+ assertResponseEqualsEntity (feedbackReqThree , response .getBody ().get ().get (1 ));
1488+ }
1489+
1490+ @ Test
1491+ void testGetEveryAllTimeAdminToRecipients () {
13701492 MemberProfile admin = createADefaultMemberProfile ();
13711493 assignAdminRole (admin );
13721494 MemberProfile pdlMemberProfile = createASecondDefaultMemberProfile ();
0 commit comments