+ Start a Discussion
Akash jena 3Akash jena 3 

what is the test class of this

public class CapsaveFacilityLetterEXT {
    
    public static Opportunity__c currentRecord {get;set;}
    public static Id opportunityId {get;set;}
    
    public CapsaveFacilityLetterEXT(ApexPages.StandardController controller) {
        opportunityId = ApexPages.CurrentPage().getparameters().get('Id');
        currentRecord = (Opportunity__c)controller.getRecord();
        
    }

    @AuraEnabled
    public static List<OpportunityProductWrapper> getOpportunityProducts(){
        OpportunityProductWrapper category;
        List<OpportunityProductWrapper.EquipmentType> equipmentTypes;

        List<Opportunity_Product__c> opptyProducts = [SELECT Id, Equipment__r.Name, Equipment__r.Category__c, Tenure_in_months__c, Rental_Sheet__c FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId Order By Equipment__r.Category__c];
        List<OpportunityProductWrapper> categories = new List<OpportunityProductWrapper>();

        String categoryName = '';
        for(Integer i = 0; i < opptyProducts.size(); i++){
            if(categoryName != opptyProducts[i].Equipment__r.Category__c){
                if(categoryName != ''){
                    category.EquipmentType = equipmentTypes;
                    categories.add(category);
                }
                categoryName = opptyProducts[i].Equipment__r.Category__c;
                category = new OpportunityProductWrapper();
                category.Name = categoryName;
                equipmentTypes = new List<OpportunityProductWrapper.EquipmentType>();
            }
            OpportunityProductWrapper.EquipmentType equipmentType = new OpportunityProductWrapper.EquipmentType();
            equipmentType.Name = opptyProducts[i].Equipment__r.Name;
            equipmentType.Tenor = String.valueOf(opptyProducts[i].Tenure_in_months__c);

            List<OpportunityProductWrapper.PTPP> ptpps = new List<OpportunityProductWrapper.PTPP>();
            if(String.isNotBlank(opptyProducts[i].Rental_Sheet__c))
            for(String str : opptyProducts[i].Rental_Sheet__c.split(';')){
                OpportunityProductWrapper.PTPP ptpp = new OpportunityProductWrapper.PTPP();
                ptpp.Range = str.split(':')[0];
                ptpp.Rental = str.split(':')[1];
                ptpps.add(ptpp);
            }
            equipmentType.PTPP = ptpps;
            equipmentTypes.add(equipmentType);
            if(i == opptyProducts.size()-1){
                category.EquipmentType = equipmentTypes;
                categories.add(category);
            }
        }
        return categories;
    }

    Public static String getVendorNames(){
        String ven = '';
        for(Opportunity_Product__c prod : [SELECT Id,Vendor_Name__c FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId]){
            if(String.isNotBlank(ven)){
                ven = ven +',' +prod.Vendor_Name__c ;
            }else{
                ven = prod.Vendor_Name__c;
            } 
        }
        return ven;
    }

    Public static String getEquipements(){
        String eType = '';
        for(AggregateResult ar : [SELECT Equipment__r.Name eqName, Equipment__r.Category__c eqCat FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId GROUP BY Equipment__r.Name, Equipment__r.Category__c ]){
            if(eType == '') eType = (String) ar.get('eqCat');
            else eType = eType + ',' + ar.get('eqCat');
        }
        return eType;
    }

    Public static list<Opportunity_Product__c> getOpportunityLineItems(){
        return [SELECT Equipment__r.Category__c ,Equipment__r.Name, Facility_Amount__c,Deposit_Type__c,
        Facility_Type__c, Facility_Amount_Million__c, Rental_Type__c, Rental_Frequency__c, Other__c, 
        Tenure_No_of_Payments__c, Tenure_Years__c, Vendor_Name__c, Tenure_in_months__c, Processing_Fee__c, 
        Rental_Sheet__c, Security_Deposit__c,Standard_Asset__c,Useful_Life_Obtained_From__c,Decommissioning_Efforts__c,
        Nature_of_Usage_of_the_Equipment__c,Equipment_Embedded_to_the_Ground__c,Responsible_for_Maintenance__c,
        Equipment_Adequately_Insured__c,Responsible_for_the_Insurance__c,Customers_Building_Leases_Term__c,
        Warranty_Maintenance__c,Asset_Maintenance_Services__c ,PNI__c,GRV__c,XIRR__c,Recovery_Statergy__c
        FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId ];
    }

    Public static List<Contact> getContacts(){
        return [SELECT Name, Designation__c, Phone, Email FROM Contact WHERE AccountId =:  currentRecord.Account__c  ];
    }


}
VinayVinay (Salesforce Developers) 
Hi Akash,

You should be able to see with Test appended prior to or after your class name'CapsaveFacilityLetterEXT' in your org.

If you do not find then you would need to create new test class for above controller.

https://trailhead.salesforce.com/content/learn/modules/apex_testing/apex_testing_intro
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_test.htm

Thanks,