ValidationReportUtils { public static String getValidateFilename(final String reportJSON) { if (!isJSONValid(reportJSON)) { return StringUtils.EMPTY; } try { final String documentName = JsonPath.read(reportJSON, "$.validationReport.validationConclusion.validatedDocument.filename"); return documentName == null ? "" : documentName; } catch (final PathNotFoundException ex) { LOGGER.warn("filename not present in JSON: ", ex); return StringUtils.EMPTY; } }  static String getValidateFilename(final String reportJSON); static List<String> getValidationWarnings(final String jsonValidationResult); static String getOverallValidationResult(final String reportJSON); static String handleMissingJSON(); static boolean isJSONValid(String json);  }
@Test public void documentNameJsonKeyPresentReturnsDocumentNameValue() throws Exception { final String json = "{\"validationReport\":{\"validationConclusion\":{\"validatedDocument\":{\"filename\":\"valid_value.bdoc\"}}}}"; assertEquals("valid_value.bdoc", ValidationReportUtils.getValidateFilename(json)); }
@Test public void documentNameJsonKeyNotPresentReturnsEmptyString() throws Exception { final String json = "{\"randomKey\": \"randomValue\"}"; assertEquals("", ValidationReportUtils.getValidateFilename(json)); }
@Test public void documentNameJsonKeyIsNullReturnsEmptyString() throws Exception { final String json = "{\"filename\": null}"; assertEquals("", ValidationReportUtils.getValidateFilename(json)); }
@Test public void givenNullToValidateFilenameReturnsEmptyString() throws Exception { assertThat(ValidationReportUtils.getValidateFilename(null)).isEqualTo(""); }