use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class DaoTestCaseImpl method getScreenshotAsSqlLobValue.
/**
* Determine the first available screenshot inside of the testcase and respectively in the assigned steps.
* For Details of the transformation, see {@link org.springframework.jdbc.support.lob.LobHandler}.
*
* @return a {@link SqlLobValue}
*/
protected SqlLobValue getScreenshotAsSqlLobValue(TestCase testCase) {
try {
Path screenShotPath = testCase.getScreenShotPath();
if (screenShotPath == null) {
//get first step exception
for (TestCaseStep step : testCase.getStepsAsSortedSet()) {
if (step.getScreenShotPath() != null) {
screenShotPath = step.getScreenShotPath();
break;
}
}
}
if (screenShotPath != null) {
final InputStream blobIs = Files.newInputStream(screenShotPath);
final int length = (int) screenShotPath.toFile().length();
return new SqlLobValue(blobIs, length, lobHandler);
}
return null;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class CacheHandlingResultServiceImpl method removeCachedInitSteps.
protected void removeCachedInitSteps() {
for (TestCase tc : testSuite.getTestCases().values()) {
List<TestCaseStep> filteredSteps = new ArrayList<>();
for (TestCaseStep step : tc.getSteps()) {
if (step.getState() != null && step.getState().isFinishedWithoutErrors()) {
filteredSteps.add(step);
} else {
logger.debug("remove cached and not called step '{}'", step.getId());
}
}
tc.setSteps(filteredSteps);
}
}
use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class AbstractOutputBuilder method generateTestCaseScreenshotsHTML.
/**
* Generates '<div></div>' tag for the screenshots included in the {@link TestCase} and the suppressed {@link TestCaseStep}s.
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
protected String generateTestCaseScreenshotsHTML(TestCase testCase) {
StringBuilder sb = new StringBuilder();
ScreenshotDiv caseDiv = screenshotDivConverter.convert(testCase.getException());
if (caseDiv != null) {
sb.append(caseDiv.getPayloadString());
}
for (TestCaseStep step : testCase.getStepsAsSortedSet()) {
ScreenshotDiv stepDiv = screenshotDivConverter.convert(step.getException());
if (stepDiv != null) {
sb.append(stepDiv.getPayloadString());
}
}
return sb.toString();
}
use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class AbstractPerformanceDataBuilder method addTestCaseStepPerformanceData.
/**
* Generates the performance data for assigned {@link TestCaseStep}s as an {@link String}.
*
* @param data already produced performance data
* @param testCaseSteps {@link SortedSet} of {@link TestCaseStep}s
* @param countOfTestCase current count of the parent {@link TestCase}
* @return formatted payload string
*/
protected static String addTestCaseStepPerformanceData(String data, SortedSet<TestCaseStep> testCaseSteps, int countOfTestCase) {
int j = 1;
for (TestCaseStep step : testCaseSteps) {
final String stepName = String.format("s_%03d_%03d_%s", countOfTestCase, j, step.getId());
if (step.getState().isFinishedWithoutErrors()) {
data = addPerformanceDataRow(data, stepName, step.getDuration(), step.getWarningTime(), 0);
} else {
//add data performance data with unknown state
data = addUnknownPerformanceDataRow(data, stepName);
}
j++;
}
return data;
}
use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class TestCaseActionTest method testAddTestCaseStep.
@Test
public void testAddTestCaseStep() throws Throwable {
sample.setWarningTime(0);
sample.setCriticalTime(0);
long now = new Date().getTime();
testling.addTestCaseStep("step for JUnit", "" + (now - 3000), "" + now, //warning
2);
TestCaseStep step = testSuiteMock.getTestCases().get(sample.getId()).getSteps().get(0);
assertNotNull(step);
assertEquals(step.getName(), "step_for_JUnit");
assertEquals(step.getDuration(), 3.0f, "duration is not correct");
assertEquals(step.getState(), TestCaseStepState.WARNING);
testling.addTestCaseStep("step2 for JUnit", "" + (now + 300), "" + (now + 4300), //no warning
5);
TestCaseStep step2 = testSuiteMock.getTestCases().get(sample.getId()).getSteps().get(1);
assertNotNull(step2);
assertEquals(step2.getName(), "step2_for_JUnit");
assertEquals(step2.getDuration(), 4.0f, "duration is not correct");
assertEquals(step2.getState(), TestCaseStepState.OK);
}
Aggregations