User { public User read(String json) throws IOException { getJsonMapper().readerForUpdating(this).readValue(json); return this; } protected  User();  User(String userName);  User(String userName, String password);  User(String userName, String password, boolean authenticated);  User(String userName, String password, boolean authenticated, String serverUrl); String getDbName(); String asJSON(); String asEncryptedJSON(); User read(String json); User load(); void save(); boolean exists(); static User readFromJSON(String json); static final ObjectMapper JSON_MAPPER; static final String UNAUTHENTICATED_DB_KEY; static final String UNAUTHENTICATED_DB_NAME; }
@Test public void shouldReadDataFromServerResponse() throws IOException { User user = new User("testUser", "testPassword"); String json = "{ \"session\": { \"link\": { \"rel\": \"session\", \"uri\": \"/sessions/83407cc8a01fb202f25458476e5cb36d\" }, \"token\": \"83407cc8a01fb202f25458476e5cb36d\" }, \"db_key\": \"6127d30bea89f2fb\", \"organisation\": \"N/A\" }"; user.read(json); assertThat(user.getDbKey(), equalTo("6127d30bea89f2fb")); assertThat(user.getOrganisation(), equalTo("N/A")); }