You need to sign in to do that
Don't have an account?
System.nullpointer exception
Test method failed...
Am getting null pointer exception in test method where i cant get the value info.getContact().id;
Please guide me for a solution..
public with sharing class CurrentUser {
public CurrentUser() {
User u = [select Id, ContactId, UserType from User where Id = :Userinfo.getUserId()];
}
}
public class CreateAcct {
public CreateAcc(){
accountID = '';
account = new account();
}
Public void JoinAcc(){
list<account> acclist = new list<account>();
acclist = [select id,name,BillingCountry,BillingState,Account_Type__c,Account_ID__c from account where Account_ID__c = :accountID];
}
Public void Submit(){
contact con=new contact();
CurrentUser info = new CurrentUser ();
system.debug('contact id:' + info.getContact().id);
ComReqtInfo__c comInfo = new ComReqInfo__c();
comInfo.name = account.name;
comInfo.Accountid__c=account.id;
comInfo.Contactid__c=info.getContact().id;
companyInfo.status__c='RequestPending';
insert comInfo ;
}
test Method:
@isTest
private class CreateAccTest{
static testMethod void CorrectAccount () {
account acc = new account(name='dummy',Account_Type__c='dummy',BillingCountry='dummy',BillingState='dummy');
insert acc;
account acc1= [select id,Account_ID__c from account where id=:acc.id];
CreateAcc con1 = new CreateAcc() ;
con1.accountID = acc1.id ;
con1.submit(); }
}
}