You need to sign in to do that
Don't have an account?
sona gaikwad
test class for not covering line where Product_Category__c ='VC'
public pageReference saveMethod(){ try{ isError = FALSE; validateData(); if(leadinfo.Lead_Sub_Stage__c == 'Booked' && fromSaveNConvert == false){ leadinfo.Lead_Sub_Stage__c.addError('Please Click on Save and Convert Button'); isError = True; createLogACall = true; } if(isError == TRUE && createLogACall ==TRUE ){ fromSaveNConvert = false; throw new DataException(ErrorMessages.REVIEW_ERROR_MESSAGE); } } catch(exception e){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage())); return null; } Savepoint sp = Database.setSavepoint(); try { pageReference pr; if(campaignId.length()!=0) { leadinfo.Campaign__c = campaignId; } if(leadinfo.Product_Category__c=='VC'){ leadinfo.Direct_VC__c=TRUE; } if(leadchatlog == TRUE){ } leadinfo.Modified_Date_Time__c = System.today(); leadinfo.Is_LastCall_Inbound__c= logACall.Inbound_Call__c; leadinfo.Lead_Assigned__c=FALSE; if(leadinfo.Product_Category__c =='CWR' || leadinfo.Product_Category__c =='Corporate CWR'){ leadinfo.Enquiry_Type__c ='CWR Enquiry'; } if(leadinfo.Product_Category__c =='VC' ||leadinfo.Product_Category__c =='Corporate VC'){ leadinfo.Enquiry_Type__c ='Direct VC'; } if(leadinfo.Product_Category__c =='Plan/CWR'){ leadinfo.Enquiry_Type__c ='Plan Enquiry'; } insert leadinfo; if(createLogACall == TRUE ){ FollowUpTasksValidationController.insertLogACall(logACall, leadinfo.Id, TRUE); } if(createFollowUpTask == TRUE){ FollowUpTasksValidationController.insertFollowUpTask(followUpTask, leadinfo.Id); } pr = new pageReference('/'+leadinfo.id); pr.setRedirect(true); return pr; /* pr = new pageReference ('/apex/ProductNewOverridePage?retURL=/'+leadinfo.id+'&id='+leadinfo.id+'&isConvert='+isConvert); pr.setRedirect(true); return pr; */ } catch(Exception e) { leadinfo=leadinfo.clone(false,false); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage())); Database.rollback(sp); return null; } }
private static Testmethod void mytest() { Test.startTest(); init(); Apexpages.StandardController sc = new Apexpages.standardController(anothernewLead); ApexPages.currentPage().getParameters().put('retUrl',anothernewLead.Id); LeadNewOverrideExtension leadinfo = new LeadNewOverrideExtension(sc); leadinfo.leadinfo = anothernewLead; leadinfo.createFollowUpTask = TRUE; leadinfo.createLogACall = TRUE; leadinfo.campaignId =newCampaign.Id; leadinfo.followUpTask =NewTask; leadInfo.logACall = LogACallNew; leadInfo.showASD = TRUE; leadInfo.showPreferedDate = FALSE; leadInfo.getDays(); leadInfo.getTimeSlots(); leadInfo.ASDAvilability(); leadInfo.saveMethod(); leadInfo.leadchatlog = TRUE; LeadNewOverrideExtension.getVillageCityAutocomplete('Vitave','Chandwad'); LeadNewOverrideExtension.getCountryAutocomplete('India'); LeadNewOverrideExtension.getStateAutocomplete('Maharashtra','India'); LeadNewOverrideExtension.getdistrictAutocomplete('Nashik','Maharashtra'); LeadNewOverrideExtension.getTalukaAutocomplete('Chandwad','Nashik'); LeadNewOverrideExtension.getVillageCityAutocompleteupdate('Vitave','Chandwad'); LeadNewOverrideExtension.getCountryAutocompleteupdate('India'); LeadNewOverrideExtension.getStateAutocompleteupdate('Maharashtra','India'); LeadNewOverrideExtension.getDistrictAutocompleteupdate('Nashik','Maharashtra'); LeadNewOverrideExtension.getTalukaAutocompleteupdate('Chandwad','Nashik'); LeadNewOverrideExtension.getPhoneNumbersList('9988776243',''); LeadNewOverrideExtension.getZoneAutocomplete('Vitave'); LeadNewOverrideExtension.getZoneAutocompleteupdate('Vitave'); LeadNewOverrideExtension.getCampaigns('TV Program','TV Program'); LeadNewOverrideExtension.getCampaignsUpdate('TV Program','TV Program'); LeadNewOverrideExtension.getPhoneNumbersList('9988776243',anothernewLead.Id); ApexPages.currentPage().getParameters().put('returl','textUrl'); leadInfo.cancel(); Test.StopTest(); }
// initializing Fields values public static Lead createAnotherNewLead(String campaignId) { Lead newLead = new Lead(); newLead.firstName='Suresh'; newLead.LastName='Narayanarao'; newLead.Email = 'Suresh@mail.com'; newLead.MobilePhone = '9988776243'; newLead.Product_category__c ='VC'; newLead.LeadSource='TV Program'; newLead.Mobile_2__c = '7656876899'; newLead.campaign__c = campaignId; newLead.Lead_Sub_stage__c = 'Booked'; newLead.Date_of_Birth__c = Date.today()-2; newLead.Prefered_date_and_Time__c = Date.today()+2; newLead.Advanced_Schedule_Date_Value__c='14/01/19'; newLead.Time_Slot_Value__c= ''; newLead.Prop_City_Village__c ='Vitave'; newLead.Com_State__c = 'Maharashtra'; newLead.Prop_State__c = 'Maharashtra'; newLead.Prop_Taluka__c = 'Chandwad'; newLead.Com_Taluka__c = 'Chandwad'; newLead.Prop_Country__c = 'India'; newLead.Number_of_Times_Contacted__c = 0; newLead.IsConverted = False; return newLead ;
Raj Vakati
Can u give me a complete test class ??