Search in sources :

Example 6 with ScreenshotDiv

use of org.sakuli.services.forwarder.gearman.model.ScreenshotDiv in project sakuli by ConSol.

the class AbstractOutputBuilder method getTextPlaceholder.

protected PlaceholderMap getTextPlaceholder(TestSuite testSuite) {
    PlaceholderMap placeholderMap = new PlaceholderMap();
    OutputState outputState = OutputState.lookupSakuliState(testSuite.getState());
    ScreenshotDiv screenshotDiv = screenshotDivConverter.convert(testSuite.getException());
    placeholderMap.put(STATE, outputState.name());
    placeholderMap.put(STATE_SHORT, outputState.getShortState());
    placeholderMap.put(STATE_DESC, testSuite.getState().getNagiosStateDescription());
    placeholderMap.put(SUITE_SUMMARY, generateStateSummary(testSuite.getState()));
    placeholderMap.put(NAME, testSuite.getName());
    placeholderMap.put(ID, testSuite.getId());
    placeholderMap.put(DURATION, String.format(Locale.ENGLISH, "%.2f", testSuite.getDuration()));
    placeholderMap.put(START_DATE, (testSuite.getStartDate() == null) ? "xx" : dateFormat.format(testSuite.getStartDate()));
    placeholderMap.put(STOP_DATE, (testSuite.getStopDate() == null) ? "xx" : dateFormat.format(testSuite.getStopDate()));
    placeholderMap.put(WARN_THRESHOLD, String.valueOf(testSuite.getWarningTime()));
    placeholderMap.put(CRITICAL_THRESHOLD, String.valueOf(testSuite.getCriticalTime()));
    placeholderMap.put(ERROR_SCREENSHOT, screenshotDiv != null ? screenshotDiv.getPayloadString() : null);
    placeholderMap.put(ERROR_MESSAGE, testSuite.getExceptionMessages(true));
    placeholderMap.put(SUITE_FOLDER, testSuite.getTestSuiteFolder() != null ? testSuite.getTestSuiteFolder().toString() : null);
    placeholderMap.put(HOST, testSuite.getHost());
    placeholderMap.put(BROWSER_INFO, testSuite.getBrowserInfo());
    placeholderMap.put(TD_CSS_CLASS, "service" + outputState.name());
    placeholderMap.put(CASE_INFORMATION, generateCaseInformation(testSuite.getTestCasesAsSortedSet()));
    placeholderMap.put(STEP_INFORMATION, testSuite.getTestCasesAsSortedSet().stream().map(c -> generateStepInformation(c.getStepsAsSortedSet())).collect(Collectors.joining()));
    return placeholderMap;
}
Also used : ScreenshotDiv(org.sakuli.services.forwarder.gearman.model.ScreenshotDiv)

Example 7 with ScreenshotDiv

use of org.sakuli.services.forwarder.gearman.model.ScreenshotDiv in project sakuli by ConSol.

the class ScreenshotDivConverter method convert.

public ScreenshotDiv convert(Throwable 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;
}
Also used : ScreenshotDiv(org.sakuli.services.forwarder.gearman.model.ScreenshotDiv)

Aggregations

ScreenshotDiv (org.sakuli.services.forwarder.gearman.model.ScreenshotDiv)7 Test (org.testng.annotations.Test)4 NoSuchFileException (java.nio.file.NoSuchFileException)2 Path (java.nio.file.Path)2 SakuliExceptionWithScreenshot (org.sakuli.exceptions.SakuliExceptionWithScreenshot)2 SakuliForwarderException (org.sakuli.exceptions.SakuliForwarderException)2 TreeSet (java.util.TreeSet)1 DateTime (org.joda.time.DateTime)1 BaseTest (org.sakuli.BaseTest)1 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)1 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)1 TestCase (org.sakuli.datamodel.TestCase)1 TestCaseStep (org.sakuli.datamodel.TestCaseStep)1 SakuliException (org.sakuli.exceptions.SakuliException)1