use of org.sakuli.builder.TestCaseStepExampleBuilder in project sakuli by ConSol.
the class Icinga2OutputBuilderTest method testBuildWarningInStep.
@Test
public void testBuildWarningInStep() throws Exception {
TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.WARNING_IN_STEP).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withStopDate(DateUtils.addSeconds(new Date(), 4)).withState(TestCaseState.WARNING_IN_STEP).withWarningTime(5).withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withName("TEST-STEP-ID").withWarningTime(2).withState(TestCaseStepState.WARNING).buildExample())).buildExample())).buildExample();
ReflectionTestUtils.setField(testling, "testSuite", testSuite);
Assert.assertEquals(testling.build(), "[WARN] Sakuli suite \"TEST-SUITE-ID\" warning in step, step \"TEST-STEP-ID\" over runtime (3.00s/warn at 2s). (Last suite run: 17.08.14 14:02:00)\n" + "[WARN] case \"TEST-CASE-ID\" (4.00s) ok, step \"TEST-STEP-ID\" over runtime (3.00s/warn at 2s)");
}
use of org.sakuli.builder.TestCaseStepExampleBuilder in project sakuli by ConSol.
the class CheckMKTemplateOutputBuilderTest method testWarnInSuite.
@Test
public void testWarnInSuite() throws Exception {
doReturn("example_xfce").when(testSuite).getId();
doReturn(TestSuiteState.WARNING_IN_SUITE).when(testSuite).getState();
doReturn(3).when(testSuite).getWarningTime();
doReturn(400).when(testSuite).getCriticalTime();
doReturn(46.94f).when(testSuite).getDuration();
doReturn(new DateTime(1970, 1, 1, 10, 32, 0).toDate()).when(testSuite).getStartDate();
doReturn(new DateTime(1970, 1, 1, 10, 32, 46, 940).toDate()).when(testSuite).getStopDate();
SortedSet<TestCase> testCaseAsSortedSet = new TreeSet<>(Arrays.asList(new TestCaseExampleBuilder().withState(TestCaseState.OK).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 32, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 32, 14, 130).toDate()).withId("case1").withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Test_Sahi_landing_page").withWarningTime(5).withStartDate(new DateTime(1970, 1, 1, 10, 32, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 32, 1, 210).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 32, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 32, 7, 410).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 32, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 32, 1, 430).toDate()).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.OK).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 32, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 32, 23, 580).toDate()).withId("case2").withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Test_Sahi_landing_page_(case2)").withWarningTime(5).withStartDate(new DateTime(1970, 1, 1, 10, 32, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 32, 1, 60).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 32, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 32, 7, 80).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 32, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 32, 1, 360).toDate()).buildExample())).buildExample()));
doReturn(testCaseAsSortedSet).when(testSuite).getTestCasesAsSortedSet();
String output = testling.createOutput();
Assert.assertEquals(output, loadExpectedOutput(TestSuiteState.WARNING_IN_SUITE.name()));
}
use of org.sakuli.builder.TestCaseStepExampleBuilder in project sakuli by ConSol.
the class CheckMKTemplateOutputBuilderTest method testException.
@Test
public void testException() throws Exception {
doReturn("example_xfce").when(testSuite).getId();
doReturn(TestSuiteState.ERRORS).when(testSuite).getState();
doReturn(300).when(testSuite).getWarningTime();
doReturn(400).when(testSuite).getCriticalTime();
doReturn(44.80f).when(testSuite).getDuration();
doReturn(new DateTime(1970, 1, 1, 10, 36, 0).toDate()).when(testSuite).getStartDate();
doReturn(new DateTime(1970, 1, 1, 10, 36, 44, 800).toDate()).when(testSuite).getStopDate();
when(testSuite.getExceptionMessages(anyBoolean())).thenCallRealMethod();
when(testSuite.getException()).thenCallRealMethod();
SortedSet<TestCase> testCaseAsSortedSet = new TreeSet<>(Arrays.asList(new TestCaseExampleBuilder().withState(TestCaseState.OK).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 14, 200).toDate()).withId("case1").withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Test_Sahi_landing_page").withWarningTime(5).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 1, 140).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 7, 540).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 1, 470).toDate()).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.ERRORS).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 36, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 23, 550).toDate()).withId("case2").withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withName("Test_Sahi_landing_page_(case2)").withWarningTime(5).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 1, 50).toDate()).withException(new SakuliException("_highlight(_link(\"xSL Manager\")); TypeError: el is undefined Sahi.prototype._highlight@http://sahi.example.com/_s_/spr/concat.js:1210:9 @http://sahi.example.com/_s_/spr/concat.js line 3607 > eval:1:1 Sahi.prototype.ex@http://sahi.example.com/_s_/spr/concat.js:3607:9 Sahi.prototype.ex@http://sahi.example.com/_s_/spr/sakuli/inject.js:46:12 @http://sahi.example.com/_s_/spr/concat.js:3373:5 <a href='/_s_/dyn/Log_getBrowserScript?href=/root/sakuli/example_test_suites/example_xfce/case2/sakuli_demo.js&n=1210'><b>Click for browser script</b></a>")).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 36, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 17, 30).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 36, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 21, 390).toDate()).buildExample())).buildExample()));
doReturn(testCaseAsSortedSet).when(testSuite).getTestCasesAsSortedSet();
ScreenshotDiv screenshotDiv = new ScreenshotDiv();
screenshotDiv.setId("sakuli_screenshot243575009");
screenshotDiv.setFormat("jpg");
screenshotDiv.setBase64screenshot("/9j/4AAQSkZJRgABAgAAAQABAAD9k=");
doReturn(screenshotDiv).when(screenshotDivConverter).convert(notNull(Throwable.class));
String output = testling.createOutput();
Assert.assertEquals(output, loadExpectedOutput(TestSuiteState.ERRORS.name()));
}
use of org.sakuli.builder.TestCaseStepExampleBuilder in project sakuli by ConSol.
the class DaoTestCaseImplTest method testGetScreenshotAsSqlLobValueTestCase.
@Test
public void testGetScreenshotAsSqlLobValueTestCase() throws Exception {
Path screenshotPath = Paths.get(this.getClass().getResource("computer.png").toURI());
TestCase testCase = new TestCaseExampleBuilder().withException(null).withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withException(new SakuliExceptionWithScreenshot("test-exception", screenshotPath)).buildExample())).buildExample();
SqlLobValue result = testling.getScreenshotAsSqlLobValue(testCase);
assertNotNull(result);
}
use of org.sakuli.builder.TestCaseStepExampleBuilder 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;;;;");
}
Aggregations