Reputation: 11
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)"
Upvotes: -1
Views: 278
Reputation: 11
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();
}
Upvotes: 0
Reputation: 19622
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');
Upvotes: 0