You need to sign in to do that
Don't have an account?
Renuka Chavan
Apex Test class for AutocreatedConfigSelfReg class
Hi All,
I am trying to write an Apex Test class for AutocreatedConfigSelfReg
In the test class I want to pass the real values to below method defined in AutocreatedConfigSelfReg
global Id createUser(Id accountId, Id profileId, Map<SObjectField, String> registrationAttributes, String password)
Type: Map<Schema.sObjectField,String>
A map of attributes that the registering user entered on the self-registration page.
Cam somebody guide me how can I pass the below fields and associated values to the createUser method
FirstName
LastName
Email
I am trying to write an Apex Test class for AutocreatedConfigSelfReg
In the test class I want to pass the real values to below method defined in AutocreatedConfigSelfReg
global Id createUser(Id accountId, Id profileId, Map<SObjectField, String> registrationAttributes, String password)
Type: Map<Schema.sObjectField,String>
A map of attributes that the registering user entered on the self-registration page.
Cam somebody guide me how can I pass the below fields and associated values to the createUser method
FirstName
LastName
Try the ways as suggested above to write a test class.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
for example I want to test below method defined in AutocreatedConfigSelfReg
global Id createUser(Id accountId, Id profileId, Map<SObjectField, String> registrationAttributes, String password)
id testUid = AutocreatedConfigSelfReg.createUser('0010v00000ZC3ubAAD','00e0c000002Khy2AAC',{['FirstName':'Jack'],['LastName':'Frost'],['Email':'Jack.frost@atos.com']},'Test123$$');
Above giving loads of syntax error.Any pointer to the Apex syntax would be of great help.
I have managed to fix all my syntax errors in the Apex Test class using below syntax.
Map<SObjectField, String> Regfields = new Map<SObjectField, String>();
Schema.DescribeFieldResult fn = user.firstname.getDescribe();
Schema.sObjectField fname = fn.getSObjectField();
Schema.DescribeFieldResult ln = user.lastname.getDescribe();
Schema.sObjectField lname = ln.getSObjectField();
Schema.DescribeFieldResult em = user.email.getDescribe();
Schema.sObjectField uemail = em.getSObjectField();
Regfields.put(fname,'Jack');
Regfields.put(lname,'frost');
Regfields.put(uemail,'jack.frost@atos.com');
id testUid = new AutocreatedConfigSelfRegMetaPack().createUser('0010v00000ZC3ubAAD','00e0c000002Khy2AAC',Regfields,'Test123$$');
"System.UnexpectedException: Salesforce System Error: 419877735-162688 (-1761313995) (-1761313995) Stack Trace: Class.System.Site.validatePassword"
Did you get something similar? If so how did you resolve? Seems like the deployed test class gets caught up on the password validation.