Search in sources :

Example 1 with DaoTestSuite

use of org.sakuli.services.forwarder.database.dao.DaoTestSuite 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());
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) DaoTestSuite(org.sakuli.services.forwarder.database.dao.DaoTestSuite) DaoTestCase(org.sakuli.services.forwarder.database.dao.DaoTestCase) TestCase(org.sakuli.datamodel.TestCase) DaoTestCaseStep(org.sakuli.services.forwarder.database.dao.DaoTestCaseStep) TestCaseStep(org.sakuli.datamodel.TestCaseStep) Test(org.testng.annotations.Test)

Aggregations

TestCase (org.sakuli.datamodel.TestCase)1 TestCaseStep (org.sakuli.datamodel.TestCaseStep)1 TestSuite (org.sakuli.datamodel.TestSuite)1 DaoTestCase (org.sakuli.services.forwarder.database.dao.DaoTestCase)1 DaoTestCaseStep (org.sakuli.services.forwarder.database.dao.DaoTestCaseStep)1 DaoTestSuite (org.sakuli.services.forwarder.database.dao.DaoTestSuite)1 Test (org.testng.annotations.Test)1