I get the following error when I run the following class:
public with sharing class CaseUpdatePriorityEmailBodyMisc {
public void updateCaseWhenDiscriptionFindBadWord(){
List<Case> updateCasePriority = new List<Case>();
for (Case badCase: (List<Case>)[FIND 'Scam OR Ponzi OR Lawyer OR Fraud OR Misrepresent OR Angry OR Upset OR Pissed OR Attorney' IN ALL FIELDS RETURNING Case(Id, CreatedDate, Priority)][0]){
if (badCase.Priority != 'High'){
badCase.Priority = 'High';
updateCasePriority.add(badCase);
}
}
update updateCasePriority;
}
}
Test class:
@isTest
private class CaseUpdatePriorityEmailBodyMiscTest {
public static Case setupCase(){
Case newCase = (Case)SmartFactory.createSObject('Case');
newCase.Status = 'Angry of with the service';
newCase.Priority = 'Low';
insert newCase;
return newCase;
}
@isTest static void testBadWordInCaseEscalateCasePriority() {
Case newCase = setupCase();
String [] fixedSearchResults= new String[1];
fixedSearchResults[0] = newCase.Status;
Test.setFixedSearchResults(fixedSearchResults);
Test.startTest();
CaseUpdatePriorityEmailBodyMisc casePriorityUpdate = new CaseUpdatePriorityEmailBodyMisc();
casePriorityUpdate.updateCaseWhenDiscriptionFindBadWord();
Test.stopTest();
System.assertEquals([Select Priority from Case where Id=:newCase.Id].Priority, 'High');
}
}
Stack Trace:
Unable to Access Page
OrderedDict([(u'@xsi:nil', u'true')])
When I run the code using anonymous apex it works. Any explanation?