### Question:
ScreenshotDivConverter { public ScreenshotDiv convert(Exception e) { if (e != null) { String base64String = extractScreenshotAsBase64(e); String format = extractScreenshotFormat(e); if (base64String != null && format != null) { ScreenshotDiv screenshotDiv = new ScreenshotDiv(); screenshotDiv.setFormat(format); screenshotDiv.setBase64screenshot(base64String); screenshotDiv.setId(ScreenshotDiv.DEFAULT_SAKULI_SCREENSHOT_DIV_ID + screenshotDiv.hashCode()); return screenshotDiv; } } return null; }  static String removeBase64ImageDataString(String string); ScreenshotDiv convert(Exception e); static final String REGEX_SRC_DATA_IMAGE_BASE64; }### Answer:
@Test public void testBuild() throws Exception { final ScreenshotDivConverter screenshotDivConverter = new ScreenshotDivConverter(); assertNull(screenshotDivConverter.convert(null)); }
@Test public void testWithException() throws Exception { Path screenshotPath = Paths.get(ScreenshotDivConverter.class.getResource("computer.png").toURI()); assertTrue(Files.exists(screenshotPath)); ScreenshotDiv result = testling.convert(new SakuliExceptionWithScreenshot("test", screenshotPath)); assertNotNull(result); assertEquals(result.getId(), ScreenshotDiv.DEFAULT_SAKULI_SCREENSHOT_DIV_ID + result.hashCode()); assertEquals(result.getBase64screenshot(), base64String); assertEquals(result.getFormat(), "png"); verify(sakuliExceptionHandler, never()).handleException(any(Exception.class)); }
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") @Test public void testThrowException() throws Exception { Path screenshotPath = Paths.get("computerNOTVALID.png"); ArgumentCaptor<Exception> excpCaptor = ArgumentCaptor.forClass(Exception.class); doNothing().when(sakuliExceptionHandler).handleException(excpCaptor.capture()); ScreenshotDiv result = testling.convert(new SakuliExceptionWithScreenshot("test", screenshotPath)); assertNull(result); verify(sakuliExceptionHandler).handleException(any(SakuliForwarderCheckedException.class)); Exception excp = excpCaptor.getValue(); assertTrue(excp instanceof SakuliForwarderCheckedException); assertEquals(excp.getMessage(), "error during the BASE64 encoding of the screenshot 'computerNOTVALID.png'"); assertTrue(excp.getSuppressed()[0] instanceof NoSuchFileException); }