@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); }
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; }
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; } }
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; }  }
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); }
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; }