@Test public void extractDOI() throws IOException, MalformedDOIException { String response = IOUtils.toString(getClass().getResourceAsStream("crossRefReply.json"), StandardCharsets.UTF_8); DOI doi = new DOIResolverImpl().extractDOI(response); assertThat(doi.toString(), is("10.1002/(sici)1098-2345(1997)42:1<1::aid-ajp1>3.0.co;2-0")); }
DOI extractDOI(String response) throws IOException, MalformedDOIException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(response); DOI doi = null; if (jsonNode.has("message")) { JsonNode msg = jsonNode.get("message"); if (msg.has("items")) { for (JsonNode items : msg.get("items")) { if (hasReasonableMatchScore(items)) { doi = DOI.create(items.get("DOI").asText()); } } } } return doi; }
DOIResolverImpl implements DOIResolver { DOI extractDOI(String response) throws IOException, MalformedDOIException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(response); DOI doi = null; if (jsonNode.has("message")) { JsonNode msg = jsonNode.get("message"); if (msg.has("items")) { for (JsonNode items : msg.get("items")) { if (hasReasonableMatchScore(items)) { doi = DOI.create(items.get("DOI").asText()); } } } } return doi; } }
DOIResolverImpl implements DOIResolver { DOI extractDOI(String response) throws IOException, MalformedDOIException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(response); DOI doi = null; if (jsonNode.has("message")) { JsonNode msg = jsonNode.get("message"); if (msg.has("items")) { for (JsonNode items : msg.get("items")) { if (hasReasonableMatchScore(items)) { doi = DOI.create(items.get("DOI").asText()); } } } } return doi; } DOIResolverImpl();  DOIResolverImpl(String baseURL); }
DOIResolverImpl implements DOIResolver { DOI extractDOI(String response) throws IOException, MalformedDOIException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(response); DOI doi = null; if (jsonNode.has("message")) { JsonNode msg = jsonNode.get("message"); if (msg.has("items")) { for (JsonNode items : msg.get("items")) { if (hasReasonableMatchScore(items)) { doi = DOI.create(items.get("DOI").asText()); } } } } return doi; } DOIResolverImpl();  DOIResolverImpl(String baseURL); @Override Map<String, DOI> resolveDoiFor(Collection<String> references); @Override DOI resolveDoiFor(final String reference); String findCitationForDOI(DOI doi); void setMinMatchScore(double minMatchScore); }
DOIResolverImpl implements DOIResolver { DOI extractDOI(String response) throws IOException, MalformedDOIException { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(response); DOI doi = null; if (jsonNode.has("message")) { JsonNode msg = jsonNode.get("message"); if (msg.has("items")) { for (JsonNode items : msg.get("items")) { if (hasReasonableMatchScore(items)) { doi = DOI.create(items.get("DOI").asText()); } } } } return doi; } DOIResolverImpl();  DOIResolverImpl(String baseURL); @Override Map<String, DOI> resolveDoiFor(Collection<String> references); @Override DOI resolveDoiFor(final String reference); String findCitationForDOI(DOI doi); void setMinMatchScore(double minMatchScore);  }