JsonExtractorUtils { public static String extractEmailFromProfile(JsonNode node) { return !node.get("email").isNull() && StringUtils.isNotBlank(node.get("email").asText()) ? node.get("email").asText() : node.get("agent").get("email").asText(); }  static String extractEmailFromProfile(JsonNode node);  }
@Test public void shouldExtractMailFromProfile() throws IOException { String email = extractEmailFromProfile(profileNode()); assertEquals("agent@sictiam.fr", email); }
@Test public void shouldExtractMailFromAgent() throws IOException { String email = extractEmailFromProfile(profileWithAgentNode()); assertEquals("dev@sictiam.fr", email); }