+ Start a Discussion
Salah Odeh 10Salah Odeh 10 

Test coverage for an Apex Class

Hello Everyone,

We have an integration with box that brings back URL share links. We have developed an Apex class that is working fine, but our test class is not having the coverage we need. Below are the Apex Class & the Test Class. It looks like the test class is not covering Try & Catch method. Please let us know if you can direct us to the right direction.
Apex Class:
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Salah,

I think you will have to make sure the exception is intentionally made and then it needs to be caught in the test class implementation.

I hope this helps and in case if this comes handy can you please choose this as best answer so that it can be used by others in the future.

Regards,
Anutej
Salah Odeh 10Salah Odeh 10
Apex Class
public class Controller_createBoxOpportunityFolder {

    private String oppId = '';
    public Opportunity opp {get; set;}  
    public Boolean testError {get; set;}  
    private BoxFolderMap boxFoldermap = null;
    
    public Controller_createBoxOpportunityFolder(){
        this.testError = false;
        this.oppId = ApexPages.currentPage().getParameters().get('id');
        this.boxFolderMap = new BoxFolderMap('Opportunity');
        String query = 'SELECT ID, Name, Box_Folder_Created__c, ' + String.join(boxFolderMap.fieldNames,',') + ' FROM Opportunity WHERE ID = \'' + this.oppId + '\'';
        System.debug('Query: ' + query);
        this.opp = Database.query(query);
    }
    
    public PageReference createFolder(){
        System.debug('Create Folder');
        if(this.opp.Box_Folder_Created__c == true){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Cannot create Box folder.  There is already a folder for this Opportunity.');
            ApexPages.addMessage(myMsg);
            return null;        
        }
        List<Opportunity> otherOpps = new List<Opportunity>();
        otherOpps = [SELECT Id FROM Opportunity WHERE Name = :this.opp.Name AND Id != :this.oppId];
        System.debug('Other Opps Size: ' + otherOpps.size());
        if(otherOpps.size() > 0){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Duplicate Opportunity Name.  Cannot create folders with duplicate Opportunity Name.');
            ApexPages.addMessage(myMsg);
            return null;
        } else {
            System.debug('Lookup up template Folder');
            Box_Templates__mdt opportunityTemplate = getBoxTemplate('Opportunity Template'); 
            List<box__FRUP__c> frups = null;
            frups = [SELECT ID FROM box__FRUP__c WHERE box__Record_ID__c = :this.opp.Id];   
            System.debug('FRUP: ' + frups.size());
            if(frups.size() > 0){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Already a mapped folder for this Opportunity.');
                ApexPages.addMessage(myMsg);
                return null;   
            }
            try {
                box__FRUP__c frup = null;
                if(this.testError && Test.isRunningTest()){
                    throw new DummyException('test error');
                } 
                CloudBox.FolderFile folderFile = CloudBoxPlatformApi.cloneAndParentFolderFile(this.opp.Name, opportunityTemplate.TemplateFolderId__c, opportunityTemplate.TargetFolderId__c);  
                frup = new  box__FRUP__c(box__Folder_ID__c = folderFile.id, box__Record_ID__c = this.opp.Id);
                CloudBox.MiniFolderFileCollection children = folderFile.item_collection; 
                List<CloudBox.MiniFolderFile> folders = children.entries;
                for(CloudBox.MiniFolderFile mff : folders){
                    List<BoxFolderMap.BoxFolderInfo> infos = this.boxFolderMap.boxFolderInfoMap.get(mff.name);
                    if(infos == null || infos.size() == 0) continue;
                    for(BoxFolderMap.BoxFolderInfo info : infos){
                        if(info.subfolderName == null && ! info.hasParent){
                            System.debug('Processing Top level Folders');
                            if(info.emailUpload){
                                String email = CloudBoxPlatformApi.createEmailUpload(mff.id, 'open');
                                this.opp.put(info.fieldName, email);
                            }
                            if(info.shareLink){
                                CloudBox.FolderFile sharedLinkFolder = CloudBoxPlatformApi.createSharedLink(mff.Id, 'open'); 
                                CloudBox.SharedLink sharedLink = sharedLinkFolder.shared_link; 
                                this.opp.put(info.fieldName, sharedLink.url);
                            }
                        } else {
                            System.debug('Processing Child Folders');
                            CloudBox.FolderFile childFolder = CloudBoxPlatformApi.getFolderById(mff.id);
                            CloudBox.MiniFolderFileCollection childCollection = childFolder.item_collection; 
                            List<CloudBox.MiniFolderFile> childFolders = childCollection.entries;
                            for(CloudBox.MiniFolderFile cff : childFolders){
                                List<BoxFolderMap.BoxFolderInfo> subInfos = this.boxFolderMap.boxFolderInfoMap.get(cff.name);
                                if(subInfos == null || subInfos.size() == 0) continue;
                                System.debug('Child Folder Name: ' + cff.name);
                                for(BoxFolderMap.BoxFolderInfo subInfo : subInfos){
                                    System.debug('Subinfos Folder Name: ' + subInfo.folderName);
                                    if(subInfo.subfolderName == null){
                                        if(subInfo.emailUpload){
                                            String email = CloudBoxPlatformApi.createEmailUpload(cff.id, 'open');
                                            this.opp.put(subInfo.fieldName, email);                                        
                                        }
                                        if(subInfo.shareLink){
                                            CloudBox.FolderFile sharedLinkFolder = CloudBoxPlatformApi.createSharedLink(cff.Id, 'open'); 
                                            CloudBox.SharedLink sharedLink = sharedLinkFolder.shared_link; 
                                            this.opp.put(subInfo.fieldName, sharedLink.url);                                        
                                        }
                                    }                                
                                }
                            }
                        }
                    }
                }
                this.opp.Box_Folder_Created__c = true;
                update this.opp;
                if(frup != null)
                    insert frup;

             } catch (Exception e){
                CloudBoxErrorLog.addError('CloudBoxUtilities.createMappedFolderOpportunity','Error Creating Opportunity Box Folder',e.getMessage()); 
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'There has been an error while attempting to create the Box Folder.');
                ApexPages.addMessage(myMsg);
                return null;
             }        
        }

        PageReference ref = new PageReference('/' + this.oppId);
        ref.setRedirect(true);
        return ref;    
    }
    
    public PageReference returnToOpportunity(){
        PageReference ref = new PageReference('/' + this.oppId);
        ref.setRedirect(true);
        return ref;  
    }
    
    public static Box_Templates__mdt getBoxTemplate(String templateName){
        System.debug('Call to box templates - name: ' + templateName);
        List<Box_Templates__mdt> templates = [SELECT MasterLabel, BoxGroupId__c, TargetFolderId__c, TemplateFolderId__c FROM Box_Templates__mdt];
        for(Box_Templates__mdt t : templates){
            if(t.MasterLabel == templateName)
                return t;
        }   
        return null; 
    }  

    public class DummyException extends Exception{}
}

 
Salah Odeh 10Salah Odeh 10

Test Class

@isTest
public class Controller_createBoxOppFolderTest {

    static testMethod void testCreateOpportunityFolderErrs(){
        BoxEnterprise__c boxSettings = new BoxEnterprise__c();
        boxSettings.Name = 'Test Settings';
        boxSettings.ClientSecret__c = '1nsmbaju7zf1SFFTR5yJHu5pGTjmb7ru';
        boxSettings.ClientId__c = 's9xn3a9jggelm9n3xhr6y6z2pyai1y6r';
        boxSettings.State__c = 'state';
        boxSettings.ReturnURI__c = 'https://cloudconstruction.com/apex/BoxCallback';
        boxSettings.isActive__c = true;
        boxSettings.AuthType__c = 'Oauth';
        insert boxSettings;  
        
        BoxAuthentication__c boxAuthTokens = new BoxAuthentication__c();
        boxAuthTokens.BoxEnterprise__c = boxSettings.Id;
        boxAuthTokens.Name = 'Oauth: ' + Date.today();
        boxAuthTokens.AuthToken__c = '123456789';
        boxAuthTokens.RefreshToken__c = '12345678910123';
        boxAuthTokens.AuthTokenExpires__c = Datetime.now().addSeconds(6000);     
        boxAuthTokens.RefreshTokenExpires__c = Datetime.now().addDays(60);
        boxAuthTokens.IsActive__c = true;  
        insert boxAuthTokens;
        
        List<RecordType> recTypes = [Select Name, Id From RecordType where sObjectType='Opportunity' and isActive=true];
        Map<String, Id> recTypeMap = new Map<String, Id>();
        for(RecordType rt : recTypes){
            recTypeMap.put(rt.Name, rt.Id);
        }
        Opportunity opp = new Opportunity(Name = 'Test Opportunity', 
                                      RecordTypeId = recTypeMap.get('Opportunity Lead'),
                                      bthousetracker__Project_Street__c = '123 Main Street',
                                      bthousetracker__Project_City__c = 'Springfield',
                                      bthousetracker__Project_State__c = 'CA',
                                      bthousetracker__Project_Zip_Postal_Code__c = '90505', 
                                      StageName = 'Planning',
                                      Acquisition_Price__c = 10.00,
                                      Proforma_After_Repair_Value__c = 20.00,
                                      CloseDate = System.today(),
                                      Box_Folder_Created__c = false);
        insert opp;
        PageReference pref = Page.createBoxOpportunityFolder;
        Test.setCurrentPage(pref);
        ApexPages.currentPage().getParameters().put('id', opp.Id);
        Controller_createBoxOpportunityFolder creator = new Controller_createBoxOpportunityFolder();        
        Test.StartTest(); 
        Test.setMock(HttpCalloutMock.class, new Mock());
        creator.testError = true;
        creator.createFolder();
        Opportunity o = [SELECT ID, Name, Box_Folder_Created__c, Acquisition_Documentation_Email_Upload__c,Acquisition_Documentation_Share_URL__c,Construction_Documentation_Share_URL__c,Disposition_Documentation_Email_Upload__c,Disposition_Documentation_Share_URL__c,Financials_Email_Upload__c,Financials_Share_URL__c,Material_Purchase_Orders_Email_Upload__c,Subcontracts_Email_Upload__c,Subcontracts_Share_URL__c FROM Opportunity WHERE ID =:opp.Id];
        creator.returnToOpportunity(); 
        Box_Templates__mdt template = Controller_createBoxOpportunityFolder.getBoxTemplate('notemplate');
        System.assertEquals(null, template); 
        Test.StopTest();    
    }
  
    
    static testMethod void testCreateOpportunityFolder(){
        BoxEnterprise__c boxSettings = new BoxEnterprise__c();
        boxSettings.Name = 'Test Settings';
        boxSettings.ClientSecret__c = '1nsmbaju7zf1SFFTR5yJHu5pGTjmb7ru';
        boxSettings.ClientId__c = 's9xn3a9jggelm9n3xhr6y6z2pyai1y6r';
        boxSettings.State__c = 'state';
        boxSettings.ReturnURI__c = 'https://cloudconstruction.com/apex/BoxCallback';
        boxSettings.isActive__c = true;
        boxSettings.AuthType__c = 'Oauth';
        insert boxSettings;  
        
        BoxAuthentication__c boxAuthTokens = new BoxAuthentication__c();
        boxAuthTokens.BoxEnterprise__c = boxSettings.Id;
        boxAuthTokens.Name = 'Oauth: ' + Date.today();
        boxAuthTokens.AuthToken__c = '123456789';
        boxAuthTokens.RefreshToken__c = '12345678910123';
        boxAuthTokens.AuthTokenExpires__c = Datetime.now().addSeconds(6000);     
        boxAuthTokens.RefreshTokenExpires__c = Datetime.now().addDays(60);
        boxAuthTokens.IsActive__c = true;  
        insert boxAuthTokens;
        
        List<RecordType> recTypes = [Select Name, Id From RecordType where sObjectType='Opportunity' and isActive=true];
        Map<String, Id> recTypeMap = new Map<String, Id>();
        for(RecordType rt : recTypes){
            recTypeMap.put(rt.Name, rt.Id);
        }
        Opportunity opp = new Opportunity(Name = 'Test Opportunity', 
                                      RecordTypeId = recTypeMap.get('Opportunity Lead'),
                                      bthousetracker__Project_Street__c = '123 Main Street',
                                      bthousetracker__Project_City__c = 'Springfield',
                                      bthousetracker__Project_State__c = 'CA',
                                      bthousetracker__Project_Zip_Postal_Code__c = '90505', 
                                      StageName = 'Planning',
                                      Acquisition_Price__c = 10.00,
                                      Proforma_After_Repair_Value__c = 20.00,
                                      CloseDate = System.today(),
                                      Box_Folder_Created__c = false);
        insert opp;
        PageReference pref = Page.createBoxOpportunityFolder;
        Test.setCurrentPage(pref);
        ApexPages.currentPage().getParameters().put('id', opp.Id);
        Controller_createBoxOpportunityFolder creator = new Controller_createBoxOpportunityFolder();        
        Test.StartTest(); 
        Test.setMock(HttpCalloutMock.class, new Mock());
        creator.testError = false;
        creator.createFolder();
        Opportunity o = [SELECT ID, Name, Box_Folder_Created__c, Acquisition_Documentation_Email_Upload__c,Acquisition_Documentation_Share_URL__c,Construction_Documentation_Share_URL__c,Disposition_Documentation_Email_Upload__c,Disposition_Documentation_Share_URL__c,Financials_Email_Upload__c,Financials_Share_URL__c,Material_Purchase_Orders_Email_Upload__c,Subcontracts_Email_Upload__c,Subcontracts_Share_URL__c FROM Opportunity WHERE ID =:opp.Id];
        System.assertEquals('acquisi.xkh8l3mrm1ejo64q@u.box.com', o.Acquisition_Documentation_Email_Upload__c);
        System.assertEquals('https://app.box.com/s/bk1nbxq15nyu0t0lovhkfmpose7bxfhr', o.Construction_Documentation_Share_URL__c);
        System.assertEquals(true, o.Box_Folder_Created__c);  
        Test.StopTest();    
    }

    static testMethod void testCreateOppFolderErrAlreadyCrtd(){
        BoxEnterprise__c boxSettings = new BoxEnterprise__c();
        boxSettings.Name = 'Test Settings';
        boxSettings.ClientSecret__c = '1nsmbaju7zf1SFFTR5yJHu5pGTjmb7ru';
        boxSettings.ClientId__c = 's9xn3a9jggelm9n3xhr6y6z2pyai1y6r';
        boxSettings.State__c = 'state';
        boxSettings.ReturnURI__c = 'https://cloudconstruction.com/apex/BoxCallback';
        boxSettings.isActive__c = true;
        boxSettings.AuthType__c = 'Oauth';
        insert boxSettings;  
        
        BoxAuthentication__c boxAuthTokens = new BoxAuthentication__c();
        boxAuthTokens.BoxEnterprise__c = boxSettings.Id;
        boxAuthTokens.Name = 'Oauth: ' + Date.today();
        boxAuthTokens.AuthToken__c = '123456789';
        boxAuthTokens.RefreshToken__c = '12345678910123';
        boxAuthTokens.AuthTokenExpires__c = Datetime.now().addSeconds(6000);     
        boxAuthTokens.RefreshTokenExpires__c = Datetime.now().addDays(60);
        boxAuthTokens.IsActive__c = true;  
        insert boxAuthTokens;
        
        List<RecordType> recTypes = [Select Name, Id From RecordType where sObjectType='Opportunity' and isActive=true];
        Map<String, Id> recTypeMap = new Map<String, Id>();
        for(RecordType rt : recTypes){
            recTypeMap.put(rt.Name, rt.Id);
        }
        Opportunity opp = new Opportunity(Name = 'Test Opportunity', 
                                      RecordTypeId = recTypeMap.get('Opportunity Lead'),
                                      bthousetracker__Project_Street__c = '123 Main Street',
                                      bthousetracker__Project_City__c = 'Springfield',
                                      bthousetracker__Project_State__c = 'CA',
                                      bthousetracker__Project_Zip_Postal_Code__c = '90505', 
                                      StageName = 'Planning',
                                      Acquisition_Price__c = 10.00,
                                      Proforma_After_Repair_Value__c = 20.00,
                                      CloseDate = System.today(),
                                      Box_Folder_Created__c = true);
        insert opp;
        PageReference pref = Page.createBoxOpportunityFolder;
        Test.setCurrentPage(pref);
        ApexPages.currentPage().getParameters().put('id', opp.Id);
        Controller_createBoxOpportunityFolder creator = new Controller_createBoxOpportunityFolder();        
        Test.StartTest(); 
        Test.setMock(HttpCalloutMock.class, new Mock());
        creator.createFolder();
        Opportunity o = [SELECT ID, Name, Box_Folder_Created__c, Acquisition_Documentation_Email_Upload__c,Acquisition_Documentation_Share_URL__c,Construction_Documentation_Share_URL__c,Disposition_Documentation_Email_Upload__c,Disposition_Documentation_Share_URL__c,Financials_Email_Upload__c,Financials_Share_URL__c,Material_Purchase_Orders_Email_Upload__c,Subcontracts_Email_Upload__c,Subcontracts_Share_URL__c FROM Opportunity WHERE ID =:opp.Id];
        System.assertEquals(null, o.Acquisition_Documentation_Email_Upload__c);  
        Test.StopTest();    
    }
    
    static testMethod void testCreateOppFolderErrExitFrup(){
        BoxEnterprise__c boxSettings = new BoxEnterprise__c();
        boxSettings.Name = 'Test Settings';
        boxSettings.ClientSecret__c = '1nsmbaju7zf1SFFTR5yJHu5pGTjmb7ru';
        boxSettings.ClientId__c = 's9xn3a9jggelm9n3xhr6y6z2pyai1y6r';
        boxSettings.State__c = 'state';
        boxSettings.ReturnURI__c = 'https://cloudconstruction.com/apex/BoxCallback';
        boxSettings.isActive__c = true;
        boxSettings.AuthType__c = 'Oauth';
        insert boxSettings;  
        
        BoxAuthentication__c boxAuthTokens = new BoxAuthentication__c();
        boxAuthTokens.BoxEnterprise__c = boxSettings.Id;
        boxAuthTokens.Name = 'Oauth: ' + Date.today();
        boxAuthTokens.AuthToken__c = '123456789';
        boxAuthTokens.RefreshToken__c = '12345678910123';
        boxAuthTokens.AuthTokenExpires__c = Datetime.now().addSeconds(6000);     
        boxAuthTokens.RefreshTokenExpires__c = Datetime.now().addDays(60);
        boxAuthTokens.IsActive__c = true;  
        insert boxAuthTokens;
        
        List<RecordType> recTypes = [Select Name, Id From RecordType where sObjectType='Opportunity' and isActive=true];
        Map<String, Id> recTypeMap = new Map<String, Id>();
        for(RecordType rt : recTypes){
            recTypeMap.put(rt.Name, rt.Id);
        }
        Opportunity opp = new Opportunity(Name = 'Test Opportunity', 
                                      RecordTypeId = recTypeMap.get('Opportunity Lead'),
                                      bthousetracker__Project_Street__c = '123 Main Street',
                                      bthousetracker__Project_City__c = 'Springfield',
                                      bthousetracker__Project_State__c = 'CA',
                                      bthousetracker__Project_Zip_Postal_Code__c = '90505', 
                                      StageName = 'Planning',
                                      Acquisition_Price__c = 10.00,
                                      Proforma_After_Repair_Value__c = 20.00,
                                      CloseDate = System.today(),
                                      Box_Folder_Created__c = false);
        insert opp;
        
        box__FRUP__c frup = new  box__FRUP__c(box__Folder_ID__c = '123456', box__Record_ID__c = opp.Id);
        insert frup;        
       
        PageReference pref = Page.createBoxOpportunityFolder;
        Test.setCurrentPage(pref);
        ApexPages.currentPage().getParameters().put('id', opp.Id);
        Controller_createBoxOpportunityFolder creator = new Controller_createBoxOpportunityFolder();        
        Test.StartTest(); 
        Test.setMock(HttpCalloutMock.class, new Mock());
        creator.createFolder();
        Opportunity o = [SELECT ID, Name, Box_Folder_Created__c, Acquisition_Documentation_Email_Upload__c,Acquisition_Documentation_Share_URL__c,Construction_Documentation_Share_URL__c,Disposition_Documentation_Email_Upload__c,Disposition_Documentation_Share_URL__c,Financials_Email_Upload__c,Financials_Share_URL__c,Material_Purchase_Orders_Email_Upload__c,Subcontracts_Email_Upload__c,Subcontracts_Share_URL__c FROM Opportunity WHERE ID =:opp.Id];
        System.assertEquals(null, o.Acquisition_Documentation_Email_Upload__c);  
        Test.StopTest();    
    }
    
    static testMethod void testCreateOppFolderErrDupeName(){
        BoxEnterprise__c boxSettings = new BoxEnterprise__c();
        boxSettings.Name = 'Test Settings';
        boxSettings.ClientSecret__c = '1nsmbaju7zf1SFFTR5yJHu5pGTjmb7ru';
        boxSettings.ClientId__c = 's9xn3a9jggelm9n3xhr6y6z2pyai1y6r';
        boxSettings.State__c = 'state';
        boxSettings.ReturnURI__c = 'https://cloudconstruction.com/apex/BoxCallback';
        boxSettings.isActive__c = true;
        boxSettings.AuthType__c = 'Oauth';
        insert boxSettings;  
        
        BoxAuthentication__c boxAuthTokens = new BoxAuthentication__c();
        boxAuthTokens.BoxEnterprise__c = boxSettings.Id;
        boxAuthTokens.Name = 'Oauth: ' + Date.today();
        boxAuthTokens.AuthToken__c = '123456789';
        boxAuthTokens.RefreshToken__c = '12345678910123';
        boxAuthTokens.AuthTokenExpires__c = Datetime.now().addSeconds(6000);     
        boxAuthTokens.RefreshTokenExpires__c = Datetime.now().addDays(60);
        boxAuthTokens.IsActive__c = true;  
        insert boxAuthTokens;
        
        List<RecordType> recTypes = [Select Name, Id From RecordType where sObjectType='Opportunity' and isActive=true];
        Map<String, Id> recTypeMap = new Map<String, Id>();
        for(RecordType rt : recTypes){
            recTypeMap.put(rt.Name, rt.Id);
        }
        Opportunity opp = new Opportunity(Name = 'Test Opportunity', 
                                      RecordTypeId = recTypeMap.get('Opportunity Lead'),
                                      bthousetracker__Project_Street__c = '123 Main Street',
                                      bthousetracker__Project_City__c = 'Springfield',
                                      bthousetracker__Project_State__c = 'CA',
                                      bthousetracker__Project_Zip_Postal_Code__c = '90505', 
                                      StageName = 'Planning',
                                      Acquisition_Price__c = 10.00,
                                      Proforma_After_Repair_Value__c = 20.00,
                                      CloseDate = System.today(),
                                      Box_Folder_Created__c = true);
        insert opp;
        
        box__FRUP__c frup = new  box__FRUP__c(box__Folder_ID__c = '123456', box__Record_ID__c = opp.Id);
        insert frup;
        
        Opportunity opp2 = new Opportunity(Name = 'Test Opportunity', 
                                      RecordTypeId = recTypeMap.get('Opportunity Lead'),
                                      bthousetracker__Project_Street__c = '123 Main Street',
                                      bthousetracker__Project_City__c = 'Springfield',
                                      bthousetracker__Project_State__c = 'CA',
                                      bthousetracker__Project_Zip_Postal_Code__c = '90505', 
                                      StageName = 'Planning',
                                      Acquisition_Price__c = 10.00,
                                      Proforma_After_Repair_Value__c = 20.00,
                                      CloseDate = System.today(),
                                      Box_Folder_Created__c = false);
        insert opp2;
        
        PageReference pref = Page.createBoxOpportunityFolder;
        Test.setCurrentPage(pref);
        ApexPages.currentPage().getParameters().put('id', opp2.Id);
        Controller_createBoxOpportunityFolder creator = new Controller_createBoxOpportunityFolder();        
        Test.StartTest(); 
        Test.setMock(HttpCalloutMock.class, new Mock());
        creator.createFolder();
        Opportunity o = [SELECT ID, Name, Box_Folder_Created__c, Acquisition_Documentation_Email_Upload__c,Acquisition_Documentation_Share_URL__c,Construction_Documentation_Share_URL__c,Disposition_Documentation_Email_Upload__c,Disposition_Documentation_Share_URL__c,Financials_Email_Upload__c,Financials_Share_URL__c,Material_Purchase_Orders_Email_Upload__c,Subcontracts_Email_Upload__c,Subcontracts_Share_URL__c FROM Opportunity WHERE ID =:opp.Id];
        System.assertEquals(null, o.Acquisition_Documentation_Email_Upload__c);
        Test.StopTest();    
    }    
}
 
Abhishek BansalAbhishek Bansal
Hi Salah,

Its not possible to check the coverage just by looking at the code. We need to test this in your org, so if possible please contact me on
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790

We can connect on a call and check the coverage.

Thanks,
Abhishek Bansal
Salah Odeh 10Salah Odeh 10
Hi Abhishek,

Thanks for the response. Below are screenshots of what is not covered in the test class. Any help will be appreciated.
User-added imageUser-added imageUser-added image
Abhishek BansalAbhishek Bansal
Hi Salah,

Looking at the screenshots it is clear that the line no. 47 is throwing error everytime and that is the reason no lines are covered after that. Please use debug statements before this line and make sure that all the pararemeters that you are passing in this method are setup correctly:

CloudBox.FolderFile folderFile = CloudBoxPlatformApi.cloneAndParentFolderFile(this.opp.Name, opportunityTemplate.TemplateFolderId__c, opportunityTemplate.TargetFolderId__c);

Please check if you are getting correct values for the opportunityTemplate.TemplateFolderId__c and opportunityTemplate.TargetFolderId__c
Once this method does not throw any error other lines will also be covered.

Let me know if you need some more information or help on this.

Thanks,
Abhishek Bansal.