use of org.sakuli.builder.TestCaseExampleBuilder 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.TestCaseExampleBuilder 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.TestCaseExampleBuilder in project sakuli by ConSol.
the class AbstractOutputBuilderTest method testGetTextPlaceHolderTestCase.
@Test
public void testGetTextPlaceHolderTestCase() throws Exception {
TestCase testCase = new TestCaseExampleBuilder().withState(TestCaseState.OK).withTestCaseFile(Paths.get("folder/_tc.js")).buildExample();
final PlaceholderMap textPlaceholder = testling.getTextPlaceholder(testCase);
assertEquals(textPlaceholder.get(STATE), "OK");
assertEquals(textPlaceholder.get(STATE_SHORT), "[OK]");
assertEquals(textPlaceholder.get(STATE_DESC), "ok");
assertEquals(textPlaceholder.get(NAME), testCase.getName());
assertEquals(textPlaceholder.get(ID), testCase.getId());
assertEquals(textPlaceholder.get(DURATION), "3.00");
assertEquals(textPlaceholder.get(STOP_DATE), AbstractOutputBuilder.dateFormat.format(testCase.getStopDate()));
assertEquals(textPlaceholder.get(START_DATE), AbstractOutputBuilder.dateFormat.format(testCase.getStartDate()));
assertEquals(textPlaceholder.get(WARN_THRESHOLD), "4");
assertEquals(textPlaceholder.get(CRITICAL_THRESHOLD), "5");
assertEquals(textPlaceholder.get(ERROR_MESSAGE), "");
assertEquals(textPlaceholder.get(CASE_FILE), String.format("folder%s_tc.js", File.separator));
assertEquals(textPlaceholder.get(CASE_LAST_URL), "http://www.last-url.com");
assertEquals(textPlaceholder.get(CASE_START_URL), "http://www.start-url.com");
assertEquals(textPlaceholder.get(STEP_INFORMATION), "");
assertEquals(textPlaceholder.get(TD_CSS_CLASS), "serviceOK");
//assert empty fields
assertEquals(textPlaceholder.get(SUITE_SUMMARY), "");
assertEquals(textPlaceholder.get(SUITE_FOLDER), "");
assertEquals(textPlaceholder.get(HOST), "");
assertEquals(textPlaceholder.get(BROWSER_INFO), "");
}
use of org.sakuli.builder.TestCaseExampleBuilder 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.builder.TestCaseExampleBuilder in project sakuli by ConSol.
the class CheckMKTemplateOutputBuilderTest method testOK.
@Test
public void testOK() throws Exception {
doReturn("example_xfce").when(testSuite).getId();
doReturn(TestSuiteState.OK).when(testSuite).getState();
doReturn(300).when(testSuite).getWarningTime();
doReturn(400).when(testSuite).getCriticalTime();
doReturn(44.99f).when(testSuite).getDuration();
doReturn(new DateTime(1970, 1, 1, 10, 30, 0).toDate()).when(testSuite).getStartDate();
doReturn(new DateTime(1970, 1, 1, 10, 30, 44, 99).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, 30, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 30, 14, 20).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, 30, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 30, 1, 160).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 30, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 30, 7, 290).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 30, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 30, 1, 500).toDate()).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.OK).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 30, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 30, 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, 30, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 30, 1, 30).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 30, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 30, 7, 80).toDate()).buildExample(), new TestCaseStepExampleBuilder().withName("Editor_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 30, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 30, 1, 390).toDate()).buildExample())).buildExample()));
doReturn(testCaseAsSortedSet).when(testSuite).getTestCasesAsSortedSet();
String output = testling.createOutput();
Assert.assertEquals(output, loadExpectedOutput(TestCaseState.OK.name()));
}
Aggregations