SessionJsonParser implements JsonParser<Session> { @Override public Session parse(JSONObject json) throws JSONException { final URI userUri = JsonParseUtil.getSelfUri(json); final String username = json.getString("name"); final LoginInfo loginInfo = loginInfoJsonParser.parse(json.getJSONObject("loginInfo")); return new Session(userUri, username, loginInfo); }  @Override Session parse(JSONObject json);  }
@Test public void testParse() throws Exception { SessionJsonParser parser = new SessionJsonParser(); final Session session = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/session/valid.json")); assertEquals(TestConstants.USER_ADMIN.getSelf(), session.getUserUri()); assertEquals("admin", session.getUsername()); assertEquals(new LoginInfo(12, 413, TestUtil.toDateTime("2010-09-14T16:15:47.554+0200"), TestUtil.toDateTime("2010-09-14T16:48:33.002+0200")), session.getLoginInfo()); }