@@ -1520,7 +1520,39 @@ void testGetEveryAllTimeAdminToRecipients() {
15201520 }
15211521
15221522 @ Test
1523- void testUpdateDueDateAuthorized () {
1523+ void testGetEveryAllTimeAdminToExternalRecipients () {
1524+ MemberProfile admin = createADefaultMemberProfile ();
1525+ assignAdminRole (admin );
1526+ MemberProfile pdlMemberProfile = createASecondDefaultMemberProfile ();
1527+ MemberProfile memberOne = createADefaultMemberProfileForPdl (pdlMemberProfile );
1528+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1529+ final FeedbackExternalRecipient externalRecipient02 = createASecondDefaultFeedbackExternalRecipient ();
1530+
1531+ LocalDate now = LocalDate .now ();
1532+ LocalDate oldestDate = LocalDate .of (2010 , 10 , 10 );
1533+ LocalDate withinLastFewMonths = now .minusMonths (2 );
1534+ LocalDate outOfRange = now .minusMonths (10 );
1535+
1536+ // create sample feedback requests with different send dates
1537+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient01 , now );
1538+ final FeedbackRequest feedbackReqTwo = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient02 , withinLastFewMonths );
1539+ final FeedbackRequest feedbackReqThree = saveFeedbackRequest (pdlMemberProfile , memberOne , externalRecipient02 , outOfRange );
1540+
1541+ final HttpRequest <?> request = HttpRequest .GET (String .format ("/?oldestDate=%s" , oldestDate ))
1542+ .basicAuth (admin .getWorkEmail (), RoleType .Constants .ADMIN_ROLE );
1543+ final HttpResponse <List <FeedbackRequestResponseDTO >> response = client .toBlocking ()
1544+ .exchange (request , Argument .listOf (FeedbackRequestResponseDTO .class ));
1545+
1546+ assertEquals (HttpStatus .OK , response .getStatus ());
1547+ assertTrue (response .getBody ().isPresent ());
1548+ assertEquals (3 , response .getBody ().get ().size ());
1549+ assertResponseEqualsEntity (feedbackReq , response .getBody ().get ().get (0 ));
1550+ assertResponseEqualsEntity (feedbackReqTwo , response .getBody ().get ().get (1 ));
1551+ assertResponseEqualsEntity (feedbackReqThree , response .getBody ().get ().get (2 ));
1552+ }
1553+
1554+ @ Test
1555+ void testUpdateDueDateAuthorizedToRecipient () {
15241556 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
15251557 assignPdlRole (pdlMemberProfile );
15261558 MemberProfile employeeMemberProfile = createADefaultMemberProfileForPdl (pdlMemberProfile );
@@ -1540,7 +1572,27 @@ void testUpdateDueDateAuthorized() {
15401572 }
15411573
15421574 @ Test
1543- void testUpdateDueDateToBeforeSendDate () {
1575+ void testUpdateDueDateAuthorizedToExternalRecipient () {
1576+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1577+ assignPdlRole (pdlMemberProfile );
1578+ MemberProfile employeeMemberProfile = createADefaultMemberProfileForPdl (pdlMemberProfile );
1579+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1580+
1581+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , employeeMemberProfile , externalRecipient01 );
1582+ feedbackReq .setDueDate (LocalDate .now ());
1583+ final FeedbackRequestUpdateDTO dto = updateDTO (feedbackReq );
1584+
1585+ final HttpRequest <?> request = HttpRequest .PUT ("" , dto )
1586+ .basicAuth (pdlMemberProfile .getWorkEmail (), RoleType .Constants .PDL_ROLE );
1587+ final HttpResponse <FeedbackRequestResponseDTO > response = client .toBlocking ().exchange (request , FeedbackRequestResponseDTO .class );
1588+
1589+ assertEquals (HttpStatus .OK , response .getStatus ());
1590+ assertTrue (response .getBody ().isPresent ());
1591+ assertResponseEqualsEntity (feedbackReq , response .getBody ().get ());
1592+ }
1593+
1594+ @ Test
1595+ void testUpdateDueDateToBeforeSendDateToRecipient () {
15441596 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
15451597 assignPdlRole (pdlMemberProfile );
15461598 MemberProfile employeeMemberProfile = createADefaultMemberProfileForPdl (pdlMemberProfile );
@@ -1561,7 +1613,28 @@ void testUpdateDueDateToBeforeSendDate() {
15611613 }
15621614
15631615 @ Test
1564- void testUpdateDueDateUnauthorized () {
1616+ void testUpdateDueDateToBeforeSendDateToExternalRecipient () {
1617+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1618+ assignPdlRole (pdlMemberProfile );
1619+ MemberProfile employeeMemberProfile = createADefaultMemberProfileForPdl (pdlMemberProfile );
1620+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1621+
1622+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , employeeMemberProfile , externalRecipient01 );
1623+ feedbackReq .setSendDate (LocalDate .of (1111 , 11 , 2 ));
1624+ feedbackReq .setDueDate (LocalDate .of (1111 , 11 , 1 ));
1625+ final FeedbackRequestUpdateDTO dto = updateDTO (feedbackReq );
1626+
1627+ final HttpRequest <?> request = HttpRequest .PUT ("" , dto )
1628+ .basicAuth (pdlMemberProfile .getWorkEmail (), RoleType .Constants .PDL_ROLE );
1629+ final HttpClientResponseException responseException = assertThrows (HttpClientResponseException .class , () ->
1630+ client .toBlocking ().exchange (request , Map .class ));
1631+
1632+ assertEquals (HttpStatus .BAD_REQUEST , responseException .getStatus ());
1633+ assertEquals ("Send date of feedback request must be before the due date." , responseException .getMessage ());
1634+ }
1635+
1636+ @ Test
1637+ void testUpdateDueDateUnauthorizedToRecipient () {
15651638 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
15661639 assignPdlRole (pdlMemberProfile );
15671640 MemberProfile employeeMemberProfile = createADefaultMemberProfileForPdl (pdlMemberProfile );
@@ -1579,6 +1652,24 @@ void testUpdateDueDateUnauthorized() {
15791652 assertUnauthorized (responseException );
15801653 }
15811654
1655+ @ Test
1656+ void testUpdateDueDateUnauthorizedToExternalRecipient () {
1657+ MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
1658+ assignPdlRole (pdlMemberProfile );
1659+ MemberProfile employeeMemberProfile = createADefaultMemberProfileForPdl (pdlMemberProfile );
1660+ final FeedbackExternalRecipient externalRecipient01 = createADefaultFeedbackExternalRecipient ();
1661+
1662+ final FeedbackRequest feedbackReq = saveFeedbackRequest (pdlMemberProfile , employeeMemberProfile , externalRecipient01 );
1663+ feedbackReq .setDueDate (Util .MAX .toLocalDate ());
1664+ final FeedbackRequestUpdateDTO dto = updateDTO (feedbackReq );
1665+
1666+ final HttpRequest <?> request = HttpRequest .PUT ("" , dto );
1667+ final HttpClientResponseException responseException = assertThrows (HttpClientResponseException .class , () ->
1668+ clientExternalRecipient .toBlocking ().exchange (request , Map .class ));
1669+
1670+ assertUnauthorized (responseException );
1671+ }
1672+
15821673 @ Test
15831674 void testUpdateStatusAndSubmitDateAuthorizedByRecipient () {
15841675 MemberProfile pdlMemberProfile = createADefaultMemberProfile ();
0 commit comments