function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ronaldo CostaRonaldo Costa 

ChatterAnswers AuthProvider Class

Hello all,

I''m having trouble with the following test class. I get an error on line #15, "attempt to de-reference a null object".
Any thoughts please? I belive it has to do with the profile id, but I'm not sure.
@isTest 
private class ChatterAnswersAuthProviderRegTest { 
static testMethod void validateCreateUpdateUser() { 
Auth.UserData userData = new Auth.UserData('00ej0000000jJMR', 'testFirst', 'testLast', 
'testFirst testLast', 'no-reply@salesforce.com', null, 'testuserlong', 'en_US', 'facebook', 
null, new Map<String, String>{'language' => 'en_US'}); 
ChatterAnswersAuthProviderRegistration reg = new ChatterAnswersAuthProviderRegistration(); 
User newUser = reg.createUser(null, userData); 
System.assert(newUser == null); 


Auth.UserData updateUserData = new Auth.UserData('00ej0000000jJMR', 'updatedFirst', 'updatedLast', 
'updatedFirst updatedLast', 'no-reply@new.salesforce.com', null, 'testuserlong', 'en_US', 'facebook', 
null, new Map<String, String>{'language' => 'en_US'}); 
reg.updateUser(newUser.iD, null, updateUserData); 
} 
}

Thanks!!
Hargobind_SinghHargobind_Singh
Line 09, where you are checking that newuser should be equal to null, then line 15 would have newUser as null, so newUser.id would give a null pointer exception.