responseSize = ParsedResponse.results.size();
if(tResults.keySet().size()>0){
for(Results re : ParsedResponse.results){
customObj tLocs = new customObj(Building_Name__c=re.buildingname,
Street_Name__c = re.streetName,
country__c = re.country,
state__c = re.state,
city__c = re.city,
Zip_Code__c = re.postal,
external_id__c = re.externalkey
);
public class GetResponseBodyClass {
public List<Results> results;
}
public class Results {
public String street;
public String country;
public String state;
public String city;
public String postal;
}
Below is the test class-
@isTest
private class apiSync_Test{
@isTest
private static void insertTls(){
apiSync.GetResponseBodyClass tl = new apiSync.GetResponseBodyClass();
HttpResponse resp = new HttpResponse();
resp.setHeader('Content-Type', 'application/json');
resp.setStatusCode(200);
resp.setBody(apiSync_Test.getResponse());
QueueHttpMock mock = new QueueHttpMock();
mock.addResponse(resp);
Test.setMock(HttpCalloutMock.class,mock);
}
public static string getResponse()
{
apiSync.GetResponseBodyClass rbc = new apiSync.GetResponseBodyClass();
rbc.total = 500;
rbc.page = 1;
// rbc.results = ({buildingname='TEST';street='ONE';uniqueKey='65776'},{buildingname='TEST';street='TWO';uniqueKey='57767'});
return JSON.serialize(rbc);
}
}
List<Results> results
in your test class? Please edit to clarify.