use of org.sakuli.services.forwarder.database.dao.DaoTestCaseStep 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());
}
Aggregations