-1

This is my aura method to retrieve fields for dual list box.

@AuraEnabled
        public static List <String> getProperties(sObject objObject, string sFieldAPI) {
            List < String > lstOptions = new list < String > ();
            Schema.sObjectType objType = objObject.getSObjectType();
            Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
            map <String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
            list < Schema.PicklistEntry > values =fieldMap.get(sFieldAPI).getDescribe().getPickListValues();
            for (Schema.PicklistEntry a: values) {
            lstOptions.add(a.getValue());
            }
            lstOptions.sort();
            return lstOptions;
        }

And this is the test class where I'm getting error.

testMethod static void testGetProperties(){
    setupInsertData();
    Test.startTest();
    List<String> Prop = MessageTypeController.getProperties('isArray');
    System.debug('Test Category'+Prop);
    if(Prop!=null){
          System.assertEquals(Prop!=null,true);
    }else{
         System.assertEquals(Prop==null,true);  
    }
    Test.stopTest();
}

The text of the error is:

"Method does not exist or incorrect signature: void getProperties(String)"

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

0

You / your colleague defined getProperties(sObject objObject, string sFieldAPI) but you're trying to call it with getProperties('isArray'). There's no method with 1 parameter (at least not in the code snippet you pasted).

You probably want to call it with something like

MessageTypeController.getProperties(new Opportunity(), 'StageName');
eyescream
  • 18,088
  • 2
  • 34
  • 46
0

With this now it's working:

testMethod static void testGetProperties(){
    setupInsertData();
    Test.startTest();
    skyvvasolutions__MessageType__c msg = new skyvvasolutions__MessageType__c();
    List<String> Prop = MessageTypeController.getProperties(msg, 'skyvvasolutions__Properties__c');
    System.debug('Test Category'+Prop);
    if(Prop!=null){
          System.assertEquals(Prop!=null,true);
    }else{
         System.assertEquals(Prop==null,true);  
    }
    Test.stopTest();
}
Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • So... this is with two parameters, as in my answer, right? ;) – eyescream Jun 07 '22 at 07:39
  • yes it take two parameters but not the way you showed. – Hardik Borad Jun 07 '22 at 08:45
  • Different how? That you have `skyvvasolutions__MessageType__c msg = new skyvvasolutions__MessageType__c()` in separate line? A variable you don't use anywhere else in the test? Or that you made it run on different sObject? lol – eyescream Jun 07 '22 at 09:10
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 07 '22 at 11:24