• Nathaniel Neblett 18
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
public without sharing class dedupeLeadProductInterest {
public class FlowInputs {
        @InvocableVariable public String varCombinedProductUnMod;
        @InvocableVariable public String LeadId;
    }

    @InvocableMethod
    public static void updateLead (List<FlowInputs> requests) {
    
    
     List<Id> LeadIds = new List<Id>();
        for (FlowInputs request : requests) {
            LeadIds.add(request.LeadId);
        }
        
        
        List<Lead> leads = [SELECT Id FROM Lead WHERE Id IN : LeadIds];

        List<Lead> LeadsToUpdate = new List<Lead>();

        for (FlowInputs request : requests) {
        
             for (Lead MyLead : leads) {
             
                if (MyLead.Id == request.LeadId) {

                String varCombinedProductUnMod = request.varCombinedProductUnMod;
                String LeadId = request.LeadId;
                List<String> duplicateRemoveList = new List<String>(new Set<String>(varCombinedProductUnMod.split(';')));
                String varApexModifiedCombinedProd = String.join(duplicateRemoveList, ';');

                MyLead.Product_Interest__c = varApexModifiedCombinedProd;
                LeadsToUpdate.add(MyLead);

        }
      }
    }
       database.update(LeadsToUpdate); 
    } 
}

 

Looking for some help to write a test class for the above invocable method used in an apex action from flow.  Unsure how to go about writing a test class for flow inputs. Thanks in advanced

Hey. I'm looking for some help with writing a test class for a custom controller that I am using in a VF page. The class code is below. The visualforce page is very light weight as it simply references the content in the static resources using the method in the controller. Everything works like a dream but I am struggling with creating the test class for the the controller.  Please help me write the test class as I am looking to deploy to a production org but cannot because the code coverage for the class is 0% 

Thanks 



public class RelNotesStaticResCtrl {

    public String textFromWinter20ReleaseNotesSummary
  {
    get {
        StaticResource sr1 = [
                select Body
                from StaticResource
                where Name = 'Winter20ReleaseNotesSummary'
                ];
        return sr1.Body.toString();
    }
}

    public String textFromCurrentReleaseNotesHTML
  {
    get {
        StaticResource sr2 = [
                select Body
                from StaticResource
                where Name = 'CurrentReleaseNotesHTML'
                ];
        return sr2.Body.toString();
    }
}




public without sharing class dedupeLeadProductInterest {
public class FlowInputs {
        @InvocableVariable public String varCombinedProductUnMod;
        @InvocableVariable public String LeadId;
    }

    @InvocableMethod
    public static void updateLead (List<FlowInputs> requests) {
    
    
     List<Id> LeadIds = new List<Id>();
        for (FlowInputs request : requests) {
            LeadIds.add(request.LeadId);
        }
        
        
        List<Lead> leads = [SELECT Id FROM Lead WHERE Id IN : LeadIds];

        List<Lead> LeadsToUpdate = new List<Lead>();

        for (FlowInputs request : requests) {
        
             for (Lead MyLead : leads) {
             
                if (MyLead.Id == request.LeadId) {

                String varCombinedProductUnMod = request.varCombinedProductUnMod;
                String LeadId = request.LeadId;
                List<String> duplicateRemoveList = new List<String>(new Set<String>(varCombinedProductUnMod.split(';')));
                String varApexModifiedCombinedProd = String.join(duplicateRemoveList, ';');

                MyLead.Product_Interest__c = varApexModifiedCombinedProd;
                LeadsToUpdate.add(MyLead);

        }
      }
    }
       database.update(LeadsToUpdate); 
    } 
}

 

Looking for some help to write a test class for the above invocable method used in an apex action from flow.  Unsure how to go about writing a test class for flow inputs. Thanks in advanced

Hey. I'm looking for some help with writing a test class for a custom controller that I am using in a VF page. The class code is below. The visualforce page is very light weight as it simply references the content in the static resources using the method in the controller. Everything works like a dream but I am struggling with creating the test class for the the controller.  Please help me write the test class as I am looking to deploy to a production org but cannot because the code coverage for the class is 0% 

Thanks 



public class RelNotesStaticResCtrl {

    public String textFromWinter20ReleaseNotesSummary
  {
    get {
        StaticResource sr1 = [
                select Body
                from StaticResource
                where Name = 'Winter20ReleaseNotesSummary'
                ];
        return sr1.Body.toString();
    }
}

    public String textFromCurrentReleaseNotesHTML
  {
    get {
        StaticResource sr2 = [
                select Body
                from StaticResource
                where Name = 'CurrentReleaseNotesHTML'
                ];
        return sr2.Body.toString();
    }
}