### Question:
User { public void fromJson(String json) throws IOException, Exception { this.attributes.clear(); JsonFactory f = new JsonFactory(); JsonParser p = f.createJsonParser(json); while (p.nextToken() != JsonToken.END_OBJECT) { String field = p.getCurrentName(); if ("id".equals(field)) { p.nextToken(); String id = p.getText(); this.id = id; } else if ("role".equals(field)) { p.nextToken(); this.role = role; } else if ("username".equals(field)) { p.nextToken(); String username = p.getText(); this.username = username; } else if ("password".equals(field)) { p.nextToken(); String password = p.getText(); this.password = password; } else if ("attributes".equals(field)) { p.nextToken(); while (p.nextToken() != JsonToken.END_OBJECT) { String attribute = p.getCurrentName(); p.nextToken(); String value = p.getText(); this.attributes.put(attribute, value); } } else { log.debug("unexpected token while parsing user"); log.debug("field = " + field); } } } User(); static String toJson(Collection<User> users); String getId(); void setId(String id); String getRole(); void setRole(String role); String getUsername(); void setUsername(String username); String getPassword(); void setPassword(String password); String getToken(); void setToken(String token); Map<String, String> getAttributes(); void fromJson(String json); String toJson();  }### Answer:
@Test public void testFromJson() { try { User user = new User(); user.fromJson(this.json); assertEquals("orange_julius", user.getUsername()); assertTrue(user.getAttributes().containsKey("email")); assertEquals("Orange Julius", user.getAttributes().get("name")); } catch (IOException e) { fail(e.toString()); } catch (URISyntaxException e) { fail(e.toString()); } catch (Exception e) { fail(e.toString()); } }