0

I have a class that looks the following:

public class ChatBot_GetLocalAndTripID {
    public class ChatBotInput{
        @InvocableVariable(required=true)
        public string SelectedStrips;
    }
    
    public class ChatBotOutput{
        @InvocableVariable(required=true)
        public string LocalCallCenter;
        
        @InvocableVariable(required=true)
        public string TripID;
    }
    
    @InvocableMethod(Label = 'Get Trip Info' description='Get a list of Trips From BO for specific user')
    public static List<ChatBotOutput> GetTrips (List <ChatBotInput> SelectedStrips){
        system.debug(SelectedStrips);
        ChatBotOutput result = new ChatBotOutput();
        result.LocalCallCenter = 'Israel';
        result.TripID = '34344344';
        return new List<ChatBotOutput> {result};         
    }

}

It is expecting a list of ChatBotInput ...

In my test I am getting the error:

Method does not exist or incorrect signature: void GetTrips(List<chatBot_GetLocalAndTripsIDTest.ChatBotInput>) from the type ChatBot_GetLocalAndTripID`

Please explain me what I do not understand here ? here is my test:

@isTest
public class chatBot_GetLocalAndTripsIDTest {
    public class ChatBotInput{
        public string SelectedStrips;
    }

    @isTest static void testMethodCon() {
        List<ChatBotInput> toInput = new List<ChatBotInput>();
        ChatBotInput SelectedTrip = new ChatBotInput();
        SelectedTrip.SelectedStrips = 'Athens - 2022-06-30';
        toInput.add(SelectedTrip);
        //ChatBotInput result = new ChatBotInput();

        Test.startTest();
      
        system.debug('Start testing');
        ChatBot_GetLocalAndTripID.GetTrips(toInput);

        Test.stopTest();        
    }
}

Working Test:

@isTest
public class chatBot_GetLocalAndTripsIDTest {
    @isTest static void testMethodCon() {
        
        
        List <ChatBot_GetLocalAndTripID.ChatBotInput> finalInput = new List <ChatBot_GetLocalAndTripID.ChatBotInput>();
        ChatBot_GetLocalAndTripID.ChatBotInput toInput = new ChatBot_GetLocalAndTripID.ChatBotInput();
        toInput.SelectedStrips = 'Athens - 2022-06-30';
        finalInput.add(toInput);
        Test.startTest();
      
        system.debug('Start testing');
        ChatBot_GetLocalAndTripID.GetTrips(finalInput);

        Test.stopTest();        
    }
    

}
1
  • Why do you appear to have a nested method declaration? And why have you hidden the ChatBotInput definition by redeclaring it in the test?
    – Phil W
    Dec 4, 2022 at 21:14

1 Answer 1

0

public class ChatBotInput shadows the other ChatBotInput class. Remove that class from your unit test class. Your unit test should reference either ChatBot_GetLocalAndTripID.ChatBotInput or ChatBotInput, depending on if the class is a nested class or top-level class, respectively.

1
  • I used ChatBot_GetLocalAndTripID.ChatBotInput and this one worked. I ll update my question with my working code. Thx again @sfdcfox
    – Ben2pop
    Dec 5, 2022 at 7:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .