IndividualSegmentJSONObjectMapper { public Results<IndividualSegment> mapToResults(String json) throws IOException { return AsahFaroBackendJSONObjectMapper.mapToResults( json, Rels.INDIVIDUAL_SEGMENTS, IndividualSegment.class); }  IndividualSegment map(String json); Results<IndividualSegment> mapToResults(String json);  }
@Test public void testMapToResults() throws Exception { Results<IndividualSegment> results = _individualSegmentJSONObjectMapper.mapToResults( _read("get-individual-segments.json")); Assert.assertEquals(2, results.getTotal()); List<IndividualSegment> individualSegments = results.getItems(); IndividualSegment individualSegment = individualSegments.get(0); Assert.assertEquals("324849894334623092", individualSegment.getId()); Assert.assertEquals("British Developers", individualSegment.getName()); Assert.assertEquals(8L, individualSegment.getIndividualCount()); Author author = individualSegment.getAuthor(); Assert.assertEquals("132184", author.getId()); }
@Test(expected = IOException.class) public void testMapToResultsThrowsIOException() throws Exception { _individualSegmentJSONObjectMapper.mapToResults("invalid json"); }
@Test public void testMapToResultsWithNoResults() throws Exception { Results<IndividualSegment> results = _individualSegmentJSONObjectMapper.mapToResults( _read("get-individual-segments-no-results.json")); Assert.assertEquals(0, results.getTotal()); List<IndividualSegment> individualSegments = results.getItems(); Assert.assertEquals( individualSegments.toString(), 0, individualSegments.size()); }