use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.
the class RegionImplTest method testResolveTakeScreenshotFolderFallback.
@Test
public void testResolveTakeScreenshotFolderFallback() throws Exception {
TestCase tc = mock(TestCase.class);
Path examplePath = Paths.get(BaseTest.TEST_FOLDER_PATH + File.separator + "NO_tc.js");
when(tc.getTcFile()).thenReturn(examplePath);
when(loader.getCurrentTestCase()).thenReturn(tc);
TestSuite ts = mock(TestSuite.class);
when(ts.getTestSuiteFolder()).thenReturn(Paths.get(BaseTest.TEST_FOLDER_PATH));
when(loader.getTestSuite()).thenReturn(ts);
Path result = RegionImpl.resolveTakeScreenshotFolder("test", loader);
assertEquals(result.toString(), Paths.get(BaseTest.TEST_FOLDER_PATH) + File.separator + "test");
verify(loader).getTestSuite();
verify(loader).getCurrentTestCase();
}
use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.
the class TestSuiteExampleBuilder method buildExample.
public TestSuite buildExample() {
TestSuite testSuite = new TestSuite();
testSuite.setName("Unit Test Sample Test Suite");
testSuite.setId(id);
testSuite.setStartDate(startDate);
testSuite.setStopDate(stopDate);
testSuite.setWarningTime(warningTime);
testSuite.setCriticalTime(criticalTime);
testSuite.setState(state);
testSuite.setHost(host);
testSuite.setBrowserInfo("Firefox Test Browser");
testSuite.addException(exception);
testSuite.setTestSuiteFolder(folder);
testSuite.setBrowserInfo(browserInfo);
for (TestCase testCase : testCases) {
testSuite.addTestCase(testCase.getId(), testCase);
}
return testSuite;
}
use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.
the class NagiosOutputBuilderTest method testFormatTestSuiteTableExceptionWithScreenshot.
@Test
public void testFormatTestSuiteTableExceptionWithScreenshot() throws Exception {
Path screenshotPath = Paths.get(NagiosOutputBuilder.class.getResource("computer.png").toURI());
Date startDate = new Date();
TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withState(TestSuiteState.ERRORS).withStartDate(startDate).withException(new SakuliExceptionWithScreenshot("TEST-ERROR", screenshotPath)).withStopDate(DateUtils.addSeconds(startDate, 120)).buildExample();
String result = testling.formatTestSuiteTableStateMessage(testSuiteExample, gearmanProperties.getTemplateSuiteTable());
String lastRun = AbstractOutputBuilder.dateFormat.format(testSuiteExample.getStopDate());
final String separator = "<div";
assertEquals(result.substring(0, result.indexOf(separator)), "<tr valign=\"top\"><td class=\"serviceCRITICAL\">[CRIT] Sakuli suite \"sakuli-123\"" + " (120.00s) EXCEPTION: 'TEST-ERROR'. (Last suite run: " + lastRun + ")");
String screenshotHash = result.substring(result.indexOf(ScreenshotDiv.DEFAULT_SAKULI_SCREENSHOT_DIV_ID) + ScreenshotDiv.DEFAULT_SAKULI_SCREENSHOT_DIV_ID.length());
screenshotHash = screenshotHash.substring(0, screenshotHash.indexOf("\">"));
String start_1 = "<div id=\"sakuli_screenshot" + screenshotHash + "\">" + "<div id=\"openModal_sakuli_screenshot" + screenshotHash + "\" class=\"modalDialog\">" + "<a href=\"#close\" title=\"Close\" class=\"close\">Close X</a>" + "<a href=\"#openModal_sakuli_screenshot" + screenshotHash + "\"><img class=\"screenshot\" src=\"";
String start = start_1 + "data:image/png;base64,";
String end = "</a></div></div></td></tr>";
String substring = result.substring(result.indexOf(separator));
assertEquals(substring.substring(0, start.length()), start);
assertEquals(substring.substring(substring.length() - end.length()), end);
//now check the remove function
String resultWithOutBase64Data = ScreenshotDivConverter.removeBase64ImageDataString(substring);
assertEquals(resultWithOutBase64Data, start_1 + "\" >" + end);
}
use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.
the class NagiosOutputBuilderTest method testFormatTestSuiteTableException.
@Test
public void testFormatTestSuiteTableException() throws Exception {
Date startDate = new Date();
TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withState(TestSuiteState.ERRORS).withStartDate(startDate).withException(new SakuliException("TEST-ERROR")).withStopDate(DateUtils.addSeconds(startDate, 120)).buildExample();
String result = testling.formatTestSuiteTableStateMessage(testSuiteExample, gearmanProperties.getTemplateSuiteTable());
String lastRun = AbstractOutputBuilder.dateFormat.format(testSuiteExample.getStopDate());
assertEquals(result, "<tr valign=\"top\"><td class=\"serviceCRITICAL\">[CRIT] Sakuli suite \"sakuli-123\"" + " (120.00s) EXCEPTION: 'TEST-ERROR'. (Last suite run: " + lastRun + ")</td></tr>");
}
use of org.sakuli.datamodel.TestSuite in project sakuli by ConSol.
the class Icinga2OutputBuilderTest method testBuildOk.
@Test
public void testBuildOk() throws Exception {
TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.OK).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").buildExample())).buildExample();
ReflectionTestUtils.setField(testling, "testSuite", testSuite);
Assert.assertEquals(testling.build(), "[OK] Sakuli suite \"TEST-SUITE-ID\" ok (120.00s). (Last suite run: 17.08.14 14:02:00)\n" + "[OK] case \"TEST-CASE-ID\" ran in 3.00s - ok");
}
Aggregations