Skip to main content
Any one please guide me on writing test case to get 100% code coverage for following class

 

public with sharing class TestFlighRequestPage {

 

    Test_Flight_Request__c fr;

 

     public List<Opportunity> listOpp;

 

     public String Id  {get; set;}

 

 

 

    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 ,  Origin_City__c,Destination_City__c   FROM Opportunity WHERE Id = :Id];

 

        

 

        if(listOpp.size() >0)

 

        {

 

            if(fr.Opportunity__c  == null)

 

            {

 

                fr.Opportunity__c  =  listOpp[0].Id;

 

            }

 

            if (fr.From__c == null)

 

            {

 

                fr.From__c = listOpp[0].Origin_City__c;

 

            }

 

            if (fr.To__c == null)

 

            {

 

                fr.To__c = listOpp[0].Destination_City__c;

 

            }

 

         }

 

    }

 

 }
2 answers
0/9000