@@ -1085,7 +1085,7 @@ void testGetByCreatorIdPermittedMultipleReqsToExternalRecipients() {
10851085 }
10861086
10871087 @ Test
1088- void testGetByCreatorRequesteeIdPermitted () {
1088+ void testGetByCreatorRequesteeIdPermittedToRecipients () {
10891089 //create two employee-PDL relationships
10901090 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
10911091 assignPdlRole (pdlMemberProfile );
@@ -1113,7 +1113,35 @@ void testGetByCreatorRequesteeIdPermitted() {
11131113 }
11141114
11151115 @ Test
1116- void testGetByCreatorRequesteeIdNotPermitted () {
1116+ void testGetByCreatorRequesteeIdPermittedToExternalRecipients () {
1117+ //create two employee-PDL relationships
1118+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1119+ assignPdlRole (pdlMemberProfile );
1120+ MemberProfile memberOne = createADefaultMemberProfileForPdl (pdlMemberProfile );
1121+ MemberProfile pdlMemberProfileTwo = createASecondDefaultMemberProfile ();
1122+ assignPdlRole (pdlMemberProfileTwo );
1123+ MemberProfile memberTwo = createASecondDefaultMemberProfileForPdl (pdlMemberProfileTwo );
1124+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1125+ final FeedbackExternalRecipient externalRecipient02 = createASecondDefaultFeedbackExternalRecipient ();
1126+
1127+ //create two sample feedback requests by the same PDL
1128+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient01 );
1129+ saveFeedbackRequest (pdlMemberProfileTwo , memberTwo , externalRecipient02 );
1130+
1131+ //search for feedback requests by a specific creator, requestee, and template
1132+ final HttpRequest <?> request = HttpRequest .GET (String .format ("/?creatorId=%s&requesteeId=%s" , feedbackReq .getCreatorId (), feedbackReq .getRequesteeId ()))
1133+ .basicAuth (pdlMemberProfile .getWorkEmail (), RoleType .Constants .PDL_ROLE );
1134+ final HttpResponse <List <FeedbackRequestResponseDTO >> response = client .toBlocking ()
1135+ .exchange (request , Argument .listOf (FeedbackRequestResponseDTO .class ));
1136+
1137+ assertTrue (response .getBody ().isPresent ());
1138+ assertEquals (1 , response .getBody ().get ().size ());
1139+ assertResponseEqualsEntity (feedbackReq , response .getBody ().get ().get (0 ));
1140+ assertEquals (HttpStatus .OK , response .getStatus ());
1141+ }
1142+
1143+ @ Test
1144+ void testGetByCreatorRequesteeIdNotPermittedToRecipients () {
11171145 //create two employee-PDL relationships
11181146 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
11191147 assignPdlRole (pdlMemberProfile );
@@ -1142,7 +1170,36 @@ void testGetByCreatorRequesteeIdNotPermitted() {
11421170 }
11431171
11441172 @ Test
1145- void testGetByCreatorRecipientIdPermitted () {
1173+ void testGetByCreatorRequesteeIdNotPermittedToExternalRecipients () {
1174+ //create two employee-PDL relationships
1175+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1176+ assignPdlRole (pdlMemberProfile );
1177+ MemberProfile memberOne = createADefaultMemberProfileForPdl (pdlMemberProfile );
1178+ MemberProfile pdlMemberProfileTwo = createASecondDefaultMemberProfile ();
1179+ assignPdlRole (pdlMemberProfileTwo );
1180+ MemberProfile memberTwo = createASecondDefaultMemberProfileForPdl (pdlMemberProfileTwo );
1181+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1182+ final FeedbackExternalRecipient externalRecipient02 = createASecondDefaultFeedbackExternalRecipient ();
1183+
1184+ //create two sample feedback requests by the same PDL
1185+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient01 );
1186+ saveFeedbackRequest (pdlMemberProfileTwo , memberTwo , externalRecipient02 );
1187+
1188+ //search for feedback requests by a specific creator, requestee, and template
1189+ final HttpRequest <?> request = HttpRequest .GET (String .format ("/?creatorId=%s&requesteeId=%s" , feedbackReq .getCreatorId (), feedbackReq .getRequesteeId ()))
1190+ .basicAuth (externalRecipient02 .getEmail (), RoleType .Constants .MEMBER_ROLE );
1191+ ;
1192+
1193+ final HttpResponse <List <FeedbackRequestResponseDTO >> response = client .toBlocking ()
1194+ .exchange (request , Argument .listOf (FeedbackRequestResponseDTO .class ));
1195+
1196+ assertTrue (response .getBody ().isPresent ());
1197+ assertEquals (0 , response .getBody ().get ().size ());
1198+ assertEquals (HttpStatus .OK , response .getStatus ());
1199+ }
1200+
1201+ @ Test
1202+ void testGetByCreatorRecipientIdPermittedToRecipients () {
11461203 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
11471204 assignPdlRole (pdlMemberProfile );
11481205 MemberProfile requestee = createADefaultMemberProfileForPdl (pdlMemberProfile );
@@ -1160,6 +1217,26 @@ void testGetByCreatorRecipientIdPermitted() {
11601217 assertResponseEqualsEntity (feedbackRequest , response .getBody ().get ());
11611218 }
11621219
1220+ @ Test
1221+ void testGetByCreatorRecipientIdPermittedToExternalRecipients () {
1222+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1223+ assignPdlRole (pdlMemberProfile );
1224+ MemberProfile requestee = createADefaultMemberProfileForPdl (pdlMemberProfile );
1225+ MemberProfile recipient = createADefaultRecipient ();
1226+ final FeedbackExternalRecipient externalRecipient = createADefaultFeedbackExternalRecipient ();
1227+ FeedbackRequest feedbackRequest = saveFeedbackRequest (pdlMemberProfile , requestee , externalRecipient );
1228+
1229+ //get feedback request
1230+ final HttpRequest <?> request = HttpRequest .GET (String .format ("/?externalRecipientId=%s" , feedbackRequest .getExternalRecipientId ()))
1231+ .basicAuth (recipient .getWorkEmail (), RoleType .Constants .MEMBER_ROLE );
1232+ final HttpResponse <FeedbackRequestResponseDTO > response = client .toBlocking ().exchange (request , FeedbackRequestResponseDTO .class );
1233+
1234+ // recipient must be able to get the feedback request
1235+ assertEquals (HttpStatus .OK , response .getStatus ());
1236+ assertTrue (response .getBody ().isPresent ());
1237+ assertResponseEqualsEntity (feedbackRequest , response .getBody ().get ());
1238+ }
1239+
11631240 @ Test
11641241 void testGetByCreatorRequesteeIdMultiplePermitted () {
11651242 //create two employee-PDL relationships
0 commit comments