I need some help
I was advised to create a test apex class to test my logic. This conversation can be seen here -- > enter link description here
I created the following test apex however I get an error message
Apex Test Result Detail
Time Started 25/04/2014 16:36
Class DeactivateUsers_Test
Method Name testuserdeactivate
Pass/Fail Fail
Error Message System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Users may only be granted full System Administrator profile with the approval of Kamaljit. Please select Sys Admin (ex Japan).: []
Stack Trace Class.DeactivateUsers_Test.testuserdeactivate: line 52, column 1
Does anyone have any ideas, how I can overcome this ??
-----Apex Code -----
`enter preformatted text here`
@isTest
private class DeactivateUsers_Test {
static testMethod void testuserdeactivate() {
List<User> tobeadded = new List<User>();
//enter the profile name below that you want to set for the test users.
Profile prof = [select id from profile where name='System Administrator'];
//make sure to add/remove the fields below that are required at your company to create new users
//create test user 3
User u3 = new User();
//u3.email = 'u3user@' + mydomain;
u3.lastname = 'tester';
u3.firstname = 'u3user';
u3.emailencodingkey='UTF-8';
u3.alias = 'u3user';
u3.languagelocalekey='en_US';
u3.localesidkey='en_US';
u3.timezonesidkey='America/Los_Angeles';
u3.profileid = prof.Id;
u3.isactive = False;
u3.Inactive_Date__c = null;
//u3.username='u3user@' + mydomain;
//add test user to the tobeupdated list
tobeadded.add(u3);
//create user 4
User u4 = new User();
//u4.email = 'u4user@' + mydomain;
u4.lastname = 'tester';
u4.firstname = 'u4user';
u4.emailencodingkey='UTF-8';
u4.alias = 'u4user';
u4.languagelocalekey='en_US';
u4.localesidkey='en_US';
u4.timezonesidkey='America/Los_Angeles';
u4.profileid = prof.Id;
u4.isactive = False;
u4.Inactive_Date__c = null;
//u4.username='u4user@' + mydomain;
//add test user to the tobeupdated list
tobeadded.add(u4);
//insert the list of new users
insert tobeadded;
//verify the users were inserted
List<User> insertedlist = [select Id,Email,isactive from User Where CreatedDate = Today];
System.debug('list includes: ' + insertedlist);
System.assertNotEquals(insertedlist,null);
//test the scheduled class
DeactivateUsers sh1 = new DeactivateUsers();
String sch = '0 0 23 * * ?';
system.schedule('Test DeactivateUsers data', sch, sh1);
}}