Skip to content

Commit

Permalink
add a unit test for new code
Browse files Browse the repository at this point in the history
  • Loading branch information
dragongrrl committed Jul 16, 2020
1 parent cfbe9d2 commit ad0a082
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,7 @@ global class RecommendationsInboundEmailHandler implements Messaging.InboundEmai

// create a task for the org-wide email address verification link
if (email.plainTextBody.containsIgnoreCase(CONFIRM_EMAIL_LINK_KEY)) {
// get the running user
Id runningUserId = UserInfo.getUserId();

// create the task and assign it to the user
Task confirmTask = new Task();
confirmTask.Subject = 'Confirm Organization-Wide Email Address';
confirmTask.Status = 'Open';
confirmTask.OwnerId = runningUserId;
confirmTask.Description = email.plainTextBody;

insert confirmTask;
createEmailConfirmTask(email.plainTextBody);
}

if (email.plainTextBody.containsIgnoreCase(EMAIL_REFERRAL_RESPONSE_TOKEN)) {
Expand Down Expand Up @@ -111,6 +101,21 @@ global class RecommendationsInboundEmailHandler implements Messaging.InboundEmai

}

@TestVisible
private static void createEmailConfirmTask(String emailBody) {
// get the running user
Id runningUserId = UserInfo.getUserId();

// create the task and assign it to the user
Task confirmTask = new Task();
confirmTask.Subject = 'Confirm Organization-Wide Email Address';
confirmTask.Status = 'Not Started';
confirmTask.OwnerId = runningUserId;
confirmTask.Description = emailBody;

insert confirmTask;
}

@TestVisible
private static Referral_Response__c getReferralResponse(String referralResponseId) {
Referral_Response__c response = new Referral_Response__c();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ public class Test_RecommendationsInboundEmailHandler {
System.assertEquals('How are you',refRespCheck.Question__c);
}

static testMethod void testCreateEmailConfirmTask() {
Test.startTest();
RecommendationsInboundEmailHandler.createEmailConfirmTask('body of email');
Test.stopTest();

Task confirmTask = [
SELECT
Id,
Description
FROM Task
WHERE Subject = 'Confirm Organization-Wide Email Address'
][0];

System.assertEquals('body of email', confirmTask.Description);
}

static Referral_Response__c getReferralResponse() {
List<Referral_Response__c> responses = [
SELECT
Expand Down

0 comments on commit ad0a082

Please sign in to comment.