1

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?

1
  • 3
    Hi @Balaji, The signature of the method is to accept List<Sobjects>, But you are passing the list <String>. Can you try passing List<Sobject> to the method. Jun 8, 2022 at 6:11

1 Answer 1

1

The signature of the method is to accept List<Sobjects>, But you are passing the list <String>. Can you try passing List<Sobject> to the method.

You must log in to answer this question.

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