The class I'm trying to upload is a copy of another one I made with just some basic differences like Role name. I had no trouble uploading the last class but for some reason this one is not working.
My Apex Class:
global class Extra_Mile implements Schedulable {
global void execute(SchedulableContext SC) {
UserRole Role = [SELECT Id from UserRole where Name='Success Manager'];
list <user> us = [SELECT Id, Name from User where UserRoleId=:role.Id];
List<task> ta = new list<task>();
for (User use: us)
{
Task t= new task();
t.Subject = 'Extra Mile';
t.ActivityDate = Date.today();
t.Description = 'Hacer algo extra para llegar mas rapido a tus metas';
t.Status = 'Open';
t.OwnerId = use.Id;
t.Priority = 'Normal';
ta.add(t);
}
insert ta;
}
}
The error is in the insert line
Test Class:
@isTest(seealldata=false) private class Extra_Mile_isTest{ public static String CRON_EXP = '0 0 0 15 3 ? 2022'; @testsetup static void createtestdata(){
Account myaccount = new account();
myaccount.Name='Scrum Diario The Influence';
myaccount.Cliente_Activo__c=true;
myaccount.OwnerId='00536000001DJsZ';
myaccount.Ninja__c='00536000001DJsZ';
Insert myaccount;
UserRole rol = new UserRole();
rol.Name='Success Manager';
user us = new user();
us.Alias='vic';
us.IsActive=true;
us.UserRoleId=rol.Id;
system.assertnotEquals(null,myaccount.id);
}
static testmethod void test1(){
Test.startTest();
system.schedule('test job', CRON_EXP, new Extra_Mile());
Test.stopTest();
}
}
I've looked around only to find that other people have the same issuer but no solution is given. What am I missing here?