0

I am trying to increase my code coverage, I have only provided parts of my code that I am trying to cover. I have to create a List to be able to pass over my values into the method. My Errors I have listed below.

  • Expecting'<' but was '('
  • Invalid type: AccountParameter
  • method does not exist or incorrect signature void handleNewAccounts(List) from the type ProcessHandlerShowAccounts

    @isTest
    public class ProcessHandlerShowAccountsTest {
     @isTest static void testCallout() {
    
        ProcessHandlerShowAccounts.AccountParameter testAccount = new ProcessHandlerShowAccounts.AccountParameter();
        testAccount.accountId = '0010Z00000schfZZZZ';
        testAccount.name = 'create';
    //I get my 1st two errors here
        LIST<AccountParameter> testActLst = new LIST();
    //I get my last error here
        ProcessHandlerShowAccounts.handleNewAccounts(testActLst);
    
    }
    
    }
    

Method I am trying to call lives within this Class

public class ProcessHandlerShowAccounts 
{
    public class AccountParameter
    {
        @InvocableVariable(required=true)
        public Id accountId;
        @InvocableVariable(required=true)
        public String name;
    }

 public static void handleNewAccounts(AccountParameter [] accountParameters) 
    {

webServiceCallOut(accountParameters[0].accountId,accountParameters[0].name);      
    isAlreadyRun=true;    
    }  

}
1
  • 3
    Please don't edit the answer back in to the question; this makes the answer seem useless.
    – sfdcfox
    Jun 20, 2018 at 13:58

1 Answer 1

3

You have to provide the fully qualified parameterized type name to the new operator:

List<AccountParameter> testActLst = new List<AccountParameter>();

You can't instantiate the type List as such.

That's what these errors are telling you. It found a ( where it was expecting <, from the type name. Then it got confused about the type of your variable, and found there's no method handleNewAccounts that takes a List, because you cannot have an untyped List.

7
  • Let me update my code, does this work?
    – nameishi
    Jun 20, 2018 at 13:33
  • My code fails, am i properly adding values within my List?
    – nameishi
    Jun 20, 2018 at 13:37
  • As written, your code does not add anything to the List. You must call List.add().
    – David Reed
    Jun 20, 2018 at 13:38
  • But dont I have to specify accountId from name? or just do List.add('0010Z00000schfZZZZ')
    – nameishi
    Jun 20, 2018 at 13:40
  • 1
    You need to add testAccount to your list.
    – David Reed
    Jun 20, 2018 at 13:41

You must log in to answer this question.

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