Search in sources :

Example 6 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class DaoIntegrationTest method initDeafultTestSuiteMock.

protected void initDeafultTestSuiteMock() {
    TestSuite sample = TestSuiteBuilder.createEmptyTestSuite();
    when(testSuiteMock.getName()).thenReturn(sample.getName());
    when(testSuiteMock.getId()).thenReturn(sample.getId());
    when(testSuiteMock.getGuid()).thenReturn(sample.getGuid());
    when(testSuiteMock.getStartDate()).thenReturn(sample.getStartDate());
    when(testSuiteMock.getWarningTime()).thenReturn(sample.getWarningTime());
    when(testSuiteMock.getCriticalTime()).thenReturn(sample.getCriticalTime());
    when(testSuiteMock.getState()).thenReturn(sample.getState());
    when(testSuiteMock.getBrowserInfo()).thenReturn(sample.getBrowserInfo());
    when(testSuiteMock.getTestCases()).thenReturn(sample.getTestCases());
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite)

Example 7 with TestSuite

use of org.sakuli.datamodel.TestSuite 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)

Example 8 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class AbstractOutputBuilderTest method testGetTextPlaceHolderTestSuite.

@Test
public void testGetTextPlaceHolderTestSuite() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.OK).withTestSuiteFolder(Paths.get("folder")).buildExample();
    final PlaceholderMap textPlaceholder = testling.getTextPlaceholder(testSuite);
    assertEquals(textPlaceholder.get(STATE), "OK");
    assertEquals(textPlaceholder.get(STATE_SHORT), "[OK]");
    assertEquals(textPlaceholder.get(STATE_DESC), "ok");
    assertEquals(textPlaceholder.get(SUITE_SUMMARY), "{{state_description}} ({{duration}}s)");
    assertEquals(textPlaceholder.get(NAME), testSuite.getName());
    assertEquals(textPlaceholder.get(ID), testSuite.getId());
    assertEquals(textPlaceholder.get(DURATION), "120.00");
    assertEquals(textPlaceholder.get(START_DATE), AbstractOutputBuilder.dateFormat.format(testSuite.getStartDate()));
    assertEquals(textPlaceholder.get(STOP_DATE), AbstractOutputBuilder.dateFormat.format(testSuite.getStopDate()));
    assertEquals(textPlaceholder.get(WARN_THRESHOLD), "0");
    assertEquals(textPlaceholder.get(CRITICAL_THRESHOLD), "0");
    assertEquals(textPlaceholder.get(ERROR_MESSAGE), "");
    assertEquals(textPlaceholder.get(SUITE_FOLDER), "folder");
    assertEquals(textPlaceholder.get(HOST), "localhost");
    assertEquals(textPlaceholder.get(BROWSER_INFO), "firefox");
    assertEquals(textPlaceholder.get(TD_CSS_CLASS), "serviceOK");
    //assert empty fields
    assertEquals(textPlaceholder.get(CASE_FILE), "");
    assertEquals(textPlaceholder.get(CASE_LAST_URL), "");
    assertEquals(textPlaceholder.get(CASE_START_URL), "");
    assertEquals(textPlaceholder.get(STEP_INFORMATION), "");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 9 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class AbstractPerformanceDataBuilderTest method testGetPerformanceDataWithPreParsedSteps.

@Test
public void testGetPerformanceDataWithPreParsedSteps() throws Exception {
    Date startDate = new GregorianCalendar(2014, 14, 7, 13, 0).getTime();
    TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withStartDate(startDate).withStopDate(DateUtils.addSeconds(startDate, 120)).withWarningTime(100).withCriticalTime(150).withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withState(TestCaseState.WARNING_IN_STEP).withId("case-warning").withStartDate(startDate).withStopDate(DateUtils.addSeconds(startDate, 20)).withWarningTime(19).withCriticalTime(25).withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withName("step1").withState(TestCaseStepState.WARNING).withStartDate(startDate).withStopDate(DateUtils.addSeconds(startDate, 10)).withWarningTime(9).buildExample(), new TestCaseStepBuilder("step2_not_started").withState(TestCaseStepState.INIT).build())).buildExample())).buildExample();
    testSuiteExample.refreshState();
    assertEquals(AbstractPerformanceDataBuilder.getTestSuitePerformanceData(testSuiteExample), "suite__state=1;;;; " + "suite__warning=100s;;;; " + "suite__critical=150s;;;; " + "suite_sakuli-123=120.00s;100;150;; " + "c_001__state=1;;;; " + "c_001__warning=19s;;;; " + "c_001__critical=25s;;;; " + "c_001_case-warning=20.00s;19;25;; " + "s_001_001_step1=10.00s;9;;; " + "s_001_002_step2_not_started=U;;;;");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) TestCaseStepBuilder(org.sakuli.datamodel.builder.TestCaseStepBuilder) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) BaseTest(org.sakuli.BaseTest) Test(org.testng.annotations.Test)

Example 10 with TestSuite

use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.

the class TeardownServiceHelperTest method testInvokeAllTeardwonServices.

@Test
public void testInvokeAllTeardwonServices() throws Exception {
    assertEquals(BeanLoader.loadMultipleBeans(TeardownService.class).size(), 5);
    DatabaseResultServiceImpl databaseResultService = mockDatabaseResultService();
    GearmanResultServiceImpl gearmanResultService = mockGearmanResultService();
    CacheHandlingResultServiceImpl cacheHandlingResultService = mockCacheHandlingResultService();
    LogCleanUpResultServiceImpl logCleanUpResultService = mockLogCleanUpResultService();
    TestSuite testSuite = BeanLoader.loadBean(TestSuite.class);
    testSuite.setState(TestSuiteState.RUNNING);
    TeardownServiceHelper.invokeTeardownServices();
    assertEquals(testSuite.getState(), TestSuiteState.OK);
    assertTrue(testSuite.getStopDate().after(testSuite.getStartDate()));
    verify(databaseResultService).saveAllResults();
    verify(databaseResultService).refreshStates();
    verify(gearmanResultService).saveAllResults();
    verify(gearmanResultService).refreshStates();
    verify(cacheHandlingResultService).saveAllResults();
    verify(cacheHandlingResultService).refreshStates();
    verify(logCleanUpResultService).triggerAction();
}
Also used : GearmanResultServiceImpl(org.sakuli.services.forwarder.gearman.GearmanResultServiceImpl) CacheHandlingResultServiceImpl(org.sakuli.services.common.CacheHandlingResultServiceImpl) TestSuite(org.sakuli.datamodel.TestSuite) DatabaseResultServiceImpl(org.sakuli.services.forwarder.database.DatabaseResultServiceImpl) LogCleanUpResultServiceImpl(org.sakuli.services.common.LogCleanUpResultServiceImpl) Test(org.testng.annotations.Test)

Aggregations

TestSuite (org.sakuli.datamodel.TestSuite)41 Test (org.testng.annotations.Test)34 TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)21 BaseTest (org.sakuli.BaseTest)15 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)15 TestCase (org.sakuli.datamodel.TestCase)13 SakuliException (org.sakuli.exceptions.SakuliException)7 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)6 TestCaseStep (org.sakuli.datamodel.TestCaseStep)6 Path (java.nio.file.Path)5 Date (java.util.Date)5 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)2 SakuliInitException (org.sakuli.exceptions.SakuliInitException)2 FileNotFoundException (java.io.FileNotFoundException)1 Entry (java.util.Map.Entry)1 Future (java.util.concurrent.Future)1 GearmanJobServerConnection (org.gearman.common.GearmanJobServerConnection)1 DateTime (org.joda.time.DateTime)1 Matchers.anyString (org.mockito.Matchers.anyString)1 LoggerTest (org.sakuli.LoggerTest)1