I am trying to test a scheduled class in apex, but upon running the test method it gives me the following error:
System.JSONException: Unexpected character ('0' (code 48)): was expecting double-quote to start field name at [line:1, column:4]
Class.System.JSON.deserialize: line 15, column 1 Class.retrieveGAdata.main: line 18, column 1 Class.scheduledGoogleAnalytics.execute: line 4, column 1
This is my test method:
public static testMethod void testscheduledGA()
{
Test.startTest();
scheduledGoogleAnalytics sga = new scheduledGoogleAnalytics();
String sch = '20 30 8 10 2 ?';
system.schedule('Test GA check', sch, sga);
Test.stopTest();
}
This is my scheduled class:
global class scheduledGoogleAnalytics implements Schedulable {
global void execute(SchedulableContext SC) {
retrieveGAdata ga = new retrieveGAdata();
ga.main();
}
}
}
And this is line 18 from retrieveGAdata:
JsonGA data = (JsonGA) JSON.deserialize(s, JsonGA.class);
where s is a string response;