I am trying to write a test method that calls a method in my class to get some configuration data. The method in my class returns a Map. From my test method, when I call the method in my class, I get an error which happens when I call APIService.getSystemSettings();
System.NullPointerException: Attempt to de-reference a null object
My code is below:
private class APIServiceTest {
@isTest static void APITest() {
Map<String,String> envSettings = new Map<String,String>();
envSettings = APIService.getSystemSettings();
}
}
Here is the class which contains the method I am calling:
public class APIService {
static API_Settings__c apiSettings = API_Settings__c.getValues('apisettings')
static Map<String,String> envSettings = new Map<String,String>();
public static Map<String,String> getSystemSettings() {
envSettings.put('customerURL', apiSettings.customer_url__c);
}
}
Most of my methods in APIService are methods annotateded with @Future(Callout=true) so that is why most of the variables are declared as static methods.
I am trying to determine why I am getting this error and what is needed to fix it.