InterestTermsJSONObjectMapper { public Results<Topic> mapToResults(String json) throws IOException { return AsahFaroBackendJSONObjectMapper.mapToResults( json, Rels.INTEREST_TOPICS, Topic.class); }  Topic map(String json); Results<Topic> mapToResults(String json);  }
@Test public void testMapToResults() throws Exception { Results<Topic> results = _interestTermsJSONObjectMapper.mapToResults( _read("get-interests-terms.json")); Assert.assertEquals(3, results.getTotal()); List<Topic> topics = results.getItems(); Topic topic = topics.get(0); Assert.assertEquals(7, topic.getId()); Assert.assertEquals(0.08653350323695352, topic.getWeight(), _DELTA); List<Topic.TopicTerm> topicTerms = topic.getTerms(); Topic.TopicTerm topicTerm = topicTerms.get(0); Assert.assertEquals("javascript", topicTerm.getKeyword()); Assert.assertEquals(0.0945945945945946, topicTerm.getWeight(), _DELTA); }
@Test public void testMapToResultsWithNoResults() throws Exception { Results<Topic> results = _interestTermsJSONObjectMapper.mapToResults( _read("get-interests-terms-no-results.json")); Assert.assertEquals(0, results.getTotal()); List<Topic> topics = results.getItems(); Assert.assertEquals(topics.toString(), 0, topics.size()); }