IndividualJSONObjectMapper { public Results<Individual> mapToResults(String json) throws IOException { return AsahFaroBackendJSONObjectMapper.mapToResults( json, Rels.INDIVIDUAL_SEGMENT_INDIVIDUALS, Individual.class); }  Individual map(String json); Results<Individual> mapToResults(String json);  }
@Test public void testMapToResults() throws Exception { Results<Individual> results = _individualJSONObjectMapper.mapToResults( _read("get-individuals.json")); Assert.assertEquals(2, results.getTotal()); List<Individual> individuals = results.getItems(); Individual individual = individuals.get(0); Assert.assertEquals("337338657439093764", individual.getId()); List<Individual.DataSourceIndividualPK> dataSourceIndividualPKs = individual.getDataSourceIndividualPKs(); Assert.assertEquals( dataSourceIndividualPKs.toString(), 8, dataSourceIndividualPKs.size()); Individual.DataSourceIndividualPK dataSourceIndividualPK = dataSourceIndividualPKs.get(0); Assert.assertEquals( "335470356976861111", dataSourceIndividualPK.getDataSourceId()); Assert.assertEquals( "LIFERAY", dataSourceIndividualPK.getDataSourceType()); List<String> individualPKs = dataSourceIndividualPK.getIndividualPKs(); Assert.assertEquals(individualPKs.toString(), 13, individualPKs.size()); Assert.assertTrue( individualPKs.contains("bd537758-b907-f00f-91c2-b18dd46e3b32")); List<String> individualSegmentIds = individual.getIndividualSegmentIds(); Assert.assertEquals( individualSegmentIds.toString(), 3, individualSegmentIds.size()); Assert.assertEquals("335470926072595570", individualSegmentIds.get(0)); }
@Test(expected = IOException.class) public void testMapToResultsThrowsIOException() throws Exception { _individualJSONObjectMapper.mapToResults("invalid json"); }
@Test public void testMapToResultsWithNoResults() throws Exception { Results<Individual> results = _individualJSONObjectMapper.mapToResults( _read("get-individuals-no-results.json")); Assert.assertEquals(0, results.getTotal()); List<Individual> individuals = results.getItems(); Assert.assertEquals(individuals.toString(), 0, individuals.size()); }