VotesJsonParser implements JsonParser<Votes> { @Override public Votes parse(JSONObject json) throws JSONException { final BasicVotes basicVotes = basicVotesJsonParser.parse(json); final Collection<BasicUser> users = JsonParseUtil.parseJsonArray(json.getJSONArray("voters"), basicUserJsonParser); return new Votes(basicVotes.getSelf(), basicVotes.getVotes(), basicVotes.hasVoted(), users); }  @Override Votes parse(JSONObject json);  }
@Test public void testParse() throws Exception { final VotesJsonParser parser = new VotesJsonParser(); final Votes votes = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/votes/complete.json")); assertEquals(2, Iterables.size(votes.getUsers())); assertEquals(TestConstants.USER1, Iterables.get(votes.getUsers(), 0)); assertFalse(votes.hasVoted()); assertEquals(2, votes.getVotes()); assertEquals(TestUtil.toUri("http: }