|
37 | 37 | import java.nio.charset.StandardCharsets; |
38 | 38 | import java.util.Base64; |
39 | 39 | import java.time.Instant; |
| 40 | +import java.net.URLEncoder; |
40 | 41 |
|
41 | 42 | import static com.objectcomputing.checkins.services.role.RoleType.Constants.ADMIN_ROLE; |
42 | 43 | import static com.objectcomputing.checkins.services.role.RoleType.Constants.MEMBER_ROLE; |
@@ -536,9 +537,10 @@ void testUpdateInvalidDatePulseResponse() { |
536 | 537 | @Test |
537 | 538 | void testCreateAPulseResponseFromSlack() { |
538 | 539 | MemberProfile memberProfile = createADefaultMemberProfile(); |
539 | | - slackSearch.users.put("SLACK_ID_HI", memberProfile.getWorkEmail()); |
| 540 | + String slackId = "SLACK_ID_HI"; |
| 541 | + slackSearch.users.put(slackId, memberProfile.getWorkEmail()); |
540 | 542 |
|
541 | | - final String rawBody = "payload=%7B%22type%22%3A+%22view_submission%22%2C+%22user%22%3A+%7B%22id%22%3A+%22SLACK_ID_HI%22%7D%2C+%22view%22%3A+%7B%22id%22%3A+%22VNHU13V36%22%2C+%22type%22%3A+%22modal%22%2C+%22state%22%3A+%7B%22values%22%3A+%7B%22internalNumber%22%3A+%7B%22internalScore%22%3A+%7B%22selected_option%22%3A+%7B%22type%22%3A+%22radio_buttons%22%2C+%22value%22%3A+%224%22%7D%7D%7D%2C+%22internalText%22%3A+%7B%22internalFeelings%22%3A+%7B%22type%22%3A+%22plain_text_input%22%2C+%22value%22%3A+%22I+am+a+robot.%22%7D%7D%2C+%22externalNumber%22%3A+%7B%22externalScore%22%3A+%7B%22selected_option%22%3A+%7B%22type%22%3A+%22radio_buttons%22%2C+%22value%22%3A+%225%22%7D%7D%7D%2C+%22externalText%22%3A+%7B%22externalFeelings%22%3A+%7B%22type%22%3A+%22plain_text_input%22%2C+%22value%22%3A+%22You+are+a+robot.%22%7D%7D%7D%7D%7D%7D"; |
| 543 | + final String rawBody = getSlackPulsePayload(slackId); |
542 | 544 |
|
543 | 545 | long currentTime = Instant.now().getEpochSecond(); |
544 | 546 | String timestamp = String.valueOf(currentTime); |
@@ -603,4 +605,53 @@ private MemberProfile profile(String key) { |
603 | 605 | private UUID id(String key) { |
604 | 606 | return profile(key).getId(); |
605 | 607 | } |
| 608 | + |
| 609 | + private String getSlackPulsePayload(String slackId) { |
| 610 | + return "payload=" + |
| 611 | + URLEncoder.encode(String.format(""" |
| 612 | +{ |
| 613 | + "type": "view_submission", |
| 614 | + "user": { |
| 615 | + "id": "%s" |
| 616 | + }, |
| 617 | + "view": { |
| 618 | + "id": "VNHU13V36", |
| 619 | + "type": "modal", |
| 620 | + "callback_id": "pulseSubmission", |
| 621 | + "state": { |
| 622 | + "values": { |
| 623 | + "internalNumber": { |
| 624 | + "internalScore": { |
| 625 | + "selected_option": { |
| 626 | + "type": "radio_buttons", |
| 627 | + "value": "4" |
| 628 | + } |
| 629 | + } |
| 630 | + }, |
| 631 | + "internalText": { |
| 632 | + "internalFeelings": { |
| 633 | + "type": "plain_text_input", |
| 634 | + "value": "I am a robot." |
| 635 | + } |
| 636 | + }, |
| 637 | + "externalNumber": { |
| 638 | + "externalScore": { |
| 639 | + "selected_option": { |
| 640 | + "type": "radio_buttons", |
| 641 | + "value": "5" |
| 642 | + } |
| 643 | + } |
| 644 | + }, |
| 645 | + "externalText": { |
| 646 | + "externalFeelings": { |
| 647 | + "type": "plain_text_input", |
| 648 | + "value": "You are a robot." |
| 649 | + } |
| 650 | + } |
| 651 | + } |
| 652 | + } |
| 653 | + } |
| 654 | +} |
| 655 | +""", slackId)); |
| 656 | + } |
606 | 657 | } |
0 commit comments