SQLReportCodec implements SQLMapCodec<Path, Report> { @Override public Map<String, Object> encodeValue(final Object o) { final Report report = (Report) o; final ExtractionStatus status = report.getStatus(); final Map<String, Object> map = new HashMap<>(); if (successStatus != null && status == ExtractionStatus.SUCCESS) { map.put(statusKey, successStatus); } else if (failureStatus != null && status.getCode() > 0) { map.put(statusKey, failureStatus); } else { map.put(statusKey, status.toString()); } if (null != exceptionKey) { if (report.getException().isPresent()) { map.put(exceptionKey, report.getException().get()); } else { map.put(exceptionKey, null); } } return map; } SQLReportCodec(final DocumentFactory factory, final Options<String> options);   SQLReportCodec(final DocumentFactory factory); @Override Map<String, Object> encodeKey(final Object o); @Override Path decodeKey(final ResultSet rs); @Override Map<String, Object> encodeValue(final Object o); @Override Report decodeValue(final ResultSet rs);  }
@Test public void testEncodeValue() throws Throwable { final Report report = new Report(ExtractionStatus.FAILURE_NOT_PARSED, new IOException("Failed to parse.")); final SQLMapCodec<Path, Report> codec = new SQLReportCodec(documentFactory); final Map<String, Object> map = codec.encodeValue(report); Assert.assertEquals("FAILURE_NOT_PARSED", map.get("extraction_status")); final Object exception = map.get("exception"); Assert.assertNotNull(exception); Assert.assertTrue(exception.toString().contains("Failed to parse.")); }