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());
}
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());
}
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), "");
}
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;;;;");
}
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();
}
Aggregations