I have a requirement to remove the duplicate objects from a list at several places in my integration code and I have developed a method in the Util class to remove the duplicate objects from the list. The code in the Util.cls is below.
public static List<SObject> removeDuplicatesFromList(List<SObject> lstSObjects) {
return new List<SObject>(new Set<SObject>(lstSObjects));
}
Below is my test method in the TestUtil class.
static void testMethod testRemoveDuplicatesFromList() {
Test.startTest();
List<String> strList = new List<String>{'abc', 'def', 'ghi', 'jkl', 'jkl'};
List<String> resultStrList = Util.removeDuplicatesFromList(strList);
System.assertEquals(4, resultStrList.size());
Test.stopTest();
}
However, I am unable to save the TestUtil class with the above test method and I am getting the below error.
Method does not exist or incorrect signature: void removeDuplicatesFromList(List) from the type Util.
The Util class has the method definition to return a List, but the error message shows a method with void return type does not exist.
Can someone help and let me know what I am missing?