I'm using the json2apex (http://json2apex.herokuapp.com/) function to build a class to I can deserialize the JSON created by this call: http://services.pbs.org/callsigns/zip/77050.json
It works nicely (though I do have to replace the $ signs I get back in the results)
But when I use the simple test method it generates, it doesn't cover any of the class...what I am missing?
EDIT: Here's the class the jsontoapex creates, with the testmethod at the end. I'm sure it that test method used to provide coverage for the class, but doesn't seem to any more...
public class StationFinder_bfc {
public class links {
public String type;
public String relationship;
public String self;
public String elements;
public String callsign;
public String common_name;
public String short_common_name;
public List<links_X> links;
}
public class links_X {
public String type;
public String mailing_state;
public String short_common_name;
public String relationship;
public String self;
public String mailing_city;
public String created;
public String common_name;
public String edited;
public String elements;
}
public String type;
public String self;
public List<items> items;
public String elements;
public class items {
public Integer confidence;
public String type;
public Integer rank;
public String self;
public List<links> links;
}
public static StationFinder_bfc parse(String json) {
return (StationFinder_bfc) System.JSON.deserialize(json, StationFinder_bfc.class);
}
static testMethod void testParse() {
String json = '{\"$type\": \"application/vnd.pbs-collection+json\", \"$self\": \"http://services.pbs.org/callsigns/zip/77050.json\", \"$items\": [{\"confidence\": 100, \"$type\": \"application/vnd.pbs-resource+json\", \"$class\": \"CallSign2ZipMapping\", \"rank\": 1, \"$self\": \"http://services.pbs.org/callsigns/zip/77050/KUHT.json\", \"$links\": [{\"callsign\": \"KUHT\", \"$links\": [{\"$type\": \"application/vnd.pbs-resource+json\", \"mailing_state\": \"TX\", \"short_common_name\": \"Houston\", \"$class\": \"Station\", \"$relationship\": \"parent\", \"$self\": \"http://services.pbs.org/station/36.json\", \"mailing_city\": \"Houston\", \"$created\": \"2012-11-12T04:54:52-05:00\", \"$links\": [{\"$type\": \"application/vnd.pbs-collection+json\", \"$relationship\": \"children\", \"$self\": \"http://services.pbs.org/callsigns/station/36.json\", \"$elements\": \"Callsign\", \"$accepts\": [{\"$type\": \"application/vnd.pbs-resource+json\", \"$class\": \"Callsign\"}]}, {\"$relationship\": \"flagship\", \"$type\": \"application/vnd.pbs-resource+json\", \"$class\": \"Callsign\", \"callsign\": \"KUHT\", \"$self\": \"http://services.pbs.org/callsign/KUHT.json\"}], \"common_name\": \"KUHT / Channel 8\", \"$edited\": \"2012-11-12T04:54:52-05:00\"}, {\"$type\": \"application/vnd.pbs-collection+json\", \"$relationship\": \"children\", \"$elements\": \"Feed\", \"$self\": \"http://services.pbs.org/feeds/callsign/KUHT.json\"}], \"$type\": \"application/vnd.pbs-resource+json\", \"$class\": \"Callsign\", \"$relationship\": \"related\", \"$self\": \"http://services.pbs.org/callsign/KUHT.json\"}]}], \"$elements\": \"CallSign2ZipMapping\", \"$accepts\": [{\"$type\": \"application/vnd.pbs-resource+json\", \"$class\": \"CallSign2ZipMapping\"}]}';
String sBody = json.replace('$','');
StationFinder_bfc obj = parse(sBody);
System.assert(obj != null);
}
}