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:
@RestResource(urlMapping='/restEndpoint/*')
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;
}
@HttpPost
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:
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.