I'm writing a test class and am testing different methods from the class that I am wanting to test. I'm testing an APEX class where most of the methods are lists, being populated by SOQL queries. To test these, I've been creating methods that create test data, and then at the end of the method, they call an instance of a class. Here's an example of what i'm talking about.
@isTest static void testgetProducts() {
//Create new bundle
Bundle__c b = new Bundle__c();
b.Name = 'Test bundle';
b.Experience__c = 'CX';
b.Bundle__c = '0';
b.Active__c = TRUE;
insert b;
//Create new bundle product
Product_Bundle_Junction__c bp = new Product_Bundle_Junction__c();
bp.Name = 'Test Bundle Product';
bp.Related_Bundle__c = b.Id;
insert bp;
List<Product_Bundle_Junction__c> newquery = originalClass.getProductsMethod(b.Id);
}
And the parameter of the getProductsMethod is only passing in a string, so it'd look like this.
public static List<Product_Bundle_Junction__c> getProductsMethod(Id bundleId)
All the above code works great. Where I am stuck is I don't know in what format do I pass in a list as a parameter value? For example:
public static List<Product2> getSystemProductsMethod(list<string> productIds)
Instead of a string being passed in, a list of type string is being passed in. So what would the syntax be in the test class in calling that method and passing in a test list? I've tried...
List<Product2> newClassClass = originalClass.getSystemProductsMethod('Test List Item');
And that hasn't worked. I've tried other variations but those haven't worked. Do I need to create a list outside of my test method?