You need to sign in to do that
Don't have an account?
Wajeed Khan
please can anyone give test code coverage for below code
public with sharing class Call_Controller { public apexpages.StandardController stdctrl{get;set;} public Call__c call{get;set;} public Id accountId {get;set;} public List<Account_Affiliation__c> accAf{get;Set;} public List<wrapperClass> wrapClassList{get;set;} public wrapperClass wc{get;set;} public List<Call__c> callList{get;set;} public Call_Controller(ApexPages.StandardController ctrl) { PageReference myVfPage = Page.Accounts; wrapClassList = new List<wrapperClass>(); accountId =ApexPages.currentPage().getParameters().get('accId'); accAf = new List<Account_Affiliation__c>(); callList=[Select Id,Status__c,Created__c,Account__c,Account__r.Name,Call_Date__c,Comments__c,Out_of_Office__c from Call__c where Account__c=:accountId]; if(callList.size()>0) { call=[Select Id,Status__c,Created__c,Account__c,Account__r.Name,Call_Date__c,Comments__c,Out_of_Office__c from Call__c where Account__c=:ApexPages.currentPage().getparameters().get('accId')][0]; } accAf=[Select Status__c,To__r.name,From__c,To__c From Account_Affiliation__c where From__c=:ApexPages.currentPage().getparameters().get('accId')]; for(Account_Affiliation__c af:accAf) { wc = new wrapperClass(af.To__r.Name); wc.flag=false; wc.accWrap=af; wrapClassList.add(wc); } // stdctrl=ctrl; } public class wrapperClass { public boolean flag{get;set;} public Account_Affiliation__c accWrap{get;set;} public String accName{get;set;} public wrapperClass(String Name) { accName=Name; flag=false; } } //Record Creation for Related Records on Save public void createRelRecordOnSave() { for(wrapperClass wc:wrapClassList) { if(wc.flag==true ) { Call__c Rcl =new Call__c(); Rcl.Account__c=wc.accWrap.To__c; Rcl.Call_Date__c=call.Call_Date__c; Rcl.Comments__c=call.Comments__c; Rcl.Out_of_office__c=call.Out_of_office__c; Rcl.Status__c='Draft'; upsert rcl; } } } //Record Creation for Related Records on Submit public void createRelRecordOnSubmit() { for(wrapperClass wc:wrapClassList) { if(wc.flag==true ) { Call__c Rcl =new Call__c(); Rcl.Account__c=wc.accWrap.To__c; Rcl.Call_Date__c=call.Call_Date__c; Rcl.Comments__c=call.Comments__c; Rcl.Out_of_office__c=call.Out_of_office__c; Rcl.Status__c='Submitted'; upsert rcl; } } } //Save Button public PageReference Save() { if(call.Call_Date__c>System.today() ) { ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'You Cannot Enter A future Date')); return null; } else { try{ Call__c Call1=New Call__C(); call1.Account__c=call.Account__c; call1.Call_Date__c=call.Call_Date__c; call1.Comments__c=call.Comments__c; call1.Out_of_office__c=call.Out_of_office__c; call1.Status__c='Draft'; upsert call1; createRelRecordOnSave(); } catch(Exception ex) { ApexPages.addMessages(ex); } } PageReference reRend = new PageReference('/a0B?fcf'); reRend.setRedirect(true); return reRend; } //Submit Button public PageReference Submit() { if(call.Call_Date__c>system.today()) { call.Call_Date__c.addError('The Date Should not be Future Date'); } try{ Call__c Call1=New Call__C(); call1.Account__c=call.Account__c; call1.Call_Date__c=call.Call_Date__c; call1.Comments__c=call.Comments__c; call1.Out_of_office__c=call.Out_of_office__c; call1.Status__c='Submitted'; upsert call1; createRelRecordOnSubmit(); } catch(Exception ex) { ApexPages.addMessages(ex); } PageReference reRend = new PageReference('/a0B?fcf'); reRend.setRedirect(true); return reRend; } }
Raj Vakati
Try this code