use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class DatabaseResultServiceImplTest method testSaveResultsInDatabaseWithTestcases.
@Test
public void testSaveResultsInDatabaseWithTestcases() throws Exception {
Integer tcPrimaryKey = 22;
TestCase tc1 = mock(TestCase.class);
TestCaseStep tcs1 = mock(TestCaseStep.class);
when(tc1.getDbPrimaryKey()).thenReturn(tcPrimaryKey);
SortedSet<TestCaseStep> tcStepList = new TreeSet<>(Collections.singleton(tcs1));
when(tc1.getStepsAsSortedSet()).thenReturn(tcStepList);
TestCase tc2 = mock(TestCase.class);
when(tc2.getSteps()).thenReturn(new ArrayList<>());
Map<String, TestCase> testCaseMap = new HashMap<>();
testCaseMap.put("1", tc1);
testCaseMap.put("2", tc2);
testSuite = new TestSuite();
testSuite.setTestCases(testCaseMap);
ReflectionTestUtils.setField(testling, "testSuite", testSuite);
testling.saveAllResults();
verify(daoTestSuite).saveTestSuiteResult();
verify(daoTestSuite).saveTestSuiteToSahiJobs();
verify(daoTestCase).saveTestCaseResult(tc1);
verify(daoTestCase).saveTestCaseResult(tc2);
verify(daoTestCase, times(2)).saveTestCaseResult(any(TestCase.class));
verify(daoTestCaseStep).saveTestCaseSteps(tcStepList, tcPrimaryKey);
verify(daoTestCaseStep).saveTestCaseSteps(any(SortedSet.class), anyInt());
}
use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class SakuliExceptionHandlerTest method testContainsExceptionsSuite.
@Test
public void testContainsExceptionsSuite() throws Exception {
TestSuite ts = new TestSuite();
ts.addException(new SakuliException("bla"));
TestCase tc = new TestCase(null, null);
ts.addTestCase(tc);
TestCaseStep step = new TestCaseStep();
tc.addStep(step);
assertTrue(SakuliExceptionHandler.containsException(ts));
}
use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class SakuliExceptionHandlerTest method testContainsExceptionsStep.
@Test
public void testContainsExceptionsStep() throws Exception {
TestSuite ts = new TestSuite();
TestCase tc = new TestCase(null, null);
ts.addTestCase(tc);
TestCaseStep step = new TestCaseStep();
step.addException(new SakuliException("bla3"));
tc.addStep(step);
assertTrue(SakuliExceptionHandler.containsException(ts));
}
use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class TestCaseAction method findStep.
protected TestCaseStep findStep(String stepName) {
TestCaseStep newStep = new TestCaseStep();
newStep.setId(stepName);
for (TestCaseStep step : loader.getCurrentTestCase().getSteps()) {
if (StringUtils.equals(step.getId(), newStep.getId())) {
return step;
}
}
return newStep;
}
use of org.sakuli.datamodel.TestCaseStep in project sakuli by ConSol.
the class DatabaseResultServiceImpl method saveAllResults.
@Override
public void saveAllResults() {
LOGGER.info("======= SAVE RESULTS TO DATABASE ======");
;
try {
daoTestSuite.saveTestSuiteResult();
daoTestSuite.saveTestSuiteToSahiJobs();
if (!CollectionUtils.isEmpty(testSuite.getTestCases())) {
for (TestCase tc : testSuite.getTestCasesAsSortedSet()) {
//write testcase and steps to DB
daoTestCase.saveTestCaseResult(tc);
LOGGER.info("... try to save all STEPS for test case '" + tc.getId() + "'!");
SortedSet<TestCaseStep> steps = tc.getStepsAsSortedSet();
if (!steps.isEmpty()) {
daoTestCaseStep.saveTestCaseSteps(steps, tc.getDbPrimaryKey());
LOGGER.info("all STEPS for '" + tc.getId() + "' saved!");
} else {
LOGGER.info("no STEPS for '\" + tc.getId() +\"'found => no STEPS saved in DB!");
}
}
}
LOGGER.info("======= FINISHED: SAVE RESULTS TO DATABASE ======");
} catch (Throwable e) {
exceptionHandler.handleException(new SakuliForwarderException(e, String.format("error by saving the results to the database [%s]", testSuite.toString())), true);
}
}
Aggregations