Hi, Please help on writing test case to get 100% code coverage . Lines in Red not covered
Here is the Apex class
public with sharing class TestFlighRequestPage { Test_Flight_Request__c fr; public List<Opportunity> listOpp; public String Id {get; set;} private string result;
public TestFlighRequestPage(ApexPages.StandardController stdController) { fr = (Test_Flight_Request__c)stdController.getRecord();
if(fr.Id == null) Id = ApexPages.currentPage().getParameters().get('opp'); else Id = fr.Opportunity__c;
listOpp = [SELECT id ,Name, Departure_Date__c,Number_of_Passengers__c,Destination_Zone__c,Return_Date__c, Origin_City__c,Destination_City__c,Flexibility_From__c,Flexibility_To__c FROM Opportunity WHERE Id = :Id];
HttpResponse res = h.send(req); result = res.getBody(); String[] toaddress = new String[]{}; toaddress.add('anil@swiftsetup.com'); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(toaddress); mail.setSubject('Flight Stat'); mail.setHtmlBody(result); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
public PageReference CloneFlightRequest() { try { Test_Flight_Request__c clFR = new Test_Flight_Request__c(); Test_Flight_Request__c oldFR = [SELECT From__c, To__c,Outbound_del__c,Pax_del__c,Region_del__c, Inbound_del__c,Outbound_Flexibility__c,Inbound_Flexibility__c,Opportunity__c, Budget__c,Publish_Fare__c FROM Test_Flight_Request__c WHERE Id = :fr.Id];
List<Opportunity> listOpp = [SELECT id ,Name, Departure_Date__c,Number_of_Passengers__c,Destination_Zone__c,Return_Date__c, Origin_City__c,Destination_City__c,Flexibility_From__c,Flexibility_To__c FROM Opportunity WHERE Id = :opp.Id];
HttpResponse res = h.send(req); String result = res.getBody(); String[] toaddress = new String[]{}; toaddress.add('anil@swiftsetup.com'); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(toaddress); mail.setSubject('Flight Stat'); mail.setHtmlBody(result); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Test_Flight_Request__c clFR = new Test_Flight_Request__c(); Test_Flight_Request__c oldFR = [SELECT From__c, To__c,Outbound_del__c,Pax_del__c,Region_del__c, Inbound_del__c,Outbound_Flexibility__c,Inbound_Flexibility__c,Opportunity__c, Budget__c,Publish_Fare__c FROM Test_Flight_Request__c WHERE Id = :fr.Id];
Can you post your test class, so that someone will help you to increase 100% code coverage.
some one is working on your issue.Once he wil do i will post the solution