I have a RestResource class that is called by our backend to perform a specific action. The problem is that when I attempt to test for this class, I run into a snag. The Class accepts a JSON file from our backend and puts into a custom list I create within the class. Here's a snippet:

global with sharing class Ecomm_Webhook_Rest {
global class Subscription {
    public String itemId;
    public String licenseId;
    public Integer quantity;
    public String interval;
    public String sku;
global class RemovedSubscription {
    public String removedId;

global static void determineWhatNeedsToBeUpdated(
List<Subscription> subscriptions, 
List<RemovedSubscription> removedSubscriptions,
) { // code here

The test method I've attempted:

static testMethod void test() {
    List<Ecomm_Webhook_Rest.Subscription> subs = new List<restClass.Subscription>();
    List<Ecomm_Webhook_Rest.RemovedSubscription> removed = new List<restClass.RemovedSubscription>();

    Ecomm_Webhook_Rest.determineWhatNeedsToBeUpdated(subs, removed);


I've attempted different lists to send, but each time I keep getting incorrect signature. What could I do to solve this?

Error message:

enter image description here

Turns out there's nothing wrong with the above. What WAS wrong is something not shown here (I removed it thinking it wasn't the issue). I was sending a Date instead of String.

  • Can you post the exact error message? Mar 7 '18 at 15:28

You need to use the proper method name.

Instead of:

Ecomm_Webhook_Rest.determineWhatNeedsToBeUpdated(subs, removed);


Ecomm_Webhook_Rest.restMethod(subs, removed); 

Alternatively (perhaps better) you can rename restMethod to determineWhatNeedsToBeUpdated.

  • I actually just renamed it to ask the question to be less confusing but forgot to edit the second portion. In my test, they have the same method names. I'll edit now to be consistent. With the proper method and class names, I'm getting the error
    – Juan
    Mar 7 '18 at 15:21
  • 1
    Please edit your question to also include the error message verbatim.
    – Adrian Larson
    Mar 7 '18 at 15:25
  • 1
    I just realized what was wrong. It's not related to anything I posted here. I removed a bunch of parameters that were being sent by the test method thinking the Lists were the issue. Turns out I was passing a Date type instead of String type. The Lists weren't the issue at all. Posting the error message is what led me to realize this, so thank you for that!
    – Juan
    Mar 7 '18 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.