Search in sources :

Example 16 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class NagiosOutputBuilderTest method testGetStatusSummary.

@Test
public void testGetStatusSummary() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.OK).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").buildExample())).buildExample();
    String lastRun = AbstractOutputBuilder.dateFormat.format(testSuite.getStopDate());
    String expectedHTML = "[OK] Sakuli suite \"TEST-SUITE-ID\" ok (120.00s). (Last suite run: " + lastRun + ")\\\\n" + String.format(ScreenshotDiv.STYLE_TEMPLATE, testling.getOutputScreenshotDivWidth()) + "<table style=\"border-collapse: collapse;\">" + "<tr valign=\"top\">" + "<td class=\"serviceOK\">[OK] Sakuli suite \"TEST-SUITE-ID\" ok (120.00s). (Last suite run: " + lastRun + ")" + "</td>" + "</tr>" + "<tr valign=\"top\">" + "<td class=\"serviceOK\">[OK] case \"TEST-CASE-ID\" ran in 3.00s - ok</td>" + "</tr>" + "</table>";
    String statusSummary = testling.getStatusSummary(testSuite, gearmanProperties);
    assertEquals(statusSummary, expectedHTML);
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    ReflectionTestUtils.setField(testling, "gearmanProperties", gearmanProperties);
    NagiosOutput output = testling.build();
    String substringStatusSummary = output.getOutputString().substring(0, output.getOutputString().indexOf("|"));
    assertEquals(substringStatusSummary, expectedHTML);
}
Also used : NagiosOutput(org.sakuli.services.forwarder.gearman.model.NagiosOutput) TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 17 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class Icinga2OutputBuilderTest method testBuildErrorInCase.

@Test
public void testBuildErrorInCase() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.ERRORS).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.ERRORS).withException(new SakuliException("MY-TEST-ERROR-CASE")).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" (120.00s) EXCEPTION: 'CASE \"TEST-CASE-ID\": MY-TEST-ERROR-CASE'. (Last suite run: 17.08.14 14:02:00)\n" + "[CRIT] case \"TEST-CASE-ID\" EXCEPTION: MY-TEST-ERROR-CASE");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) SakuliException(org.sakuli.exceptions.SakuliException) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 18 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class CheckMKTemplateOutputBuilderTest method testCritInSuite.

@Test
public void testCritInSuite() throws Exception {
    doReturn("example_xfce").when(testSuite).getId();
    doReturn(TestSuiteState.CRITICAL_IN_SUITE).when(testSuite).getState();
    doReturn(30).when(testSuite).getWarningTime();
    doReturn(40).when(testSuite).getCriticalTime();
    doReturn(44.81f).when(testSuite).getDuration();
    doReturn(new DateTime(1970, 1, 1, 10, 33, 0).toDate()).when(testSuite).getStartDate();
    doReturn(new DateTime(1970, 1, 1, 10, 33, 44, 810).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, 33, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 33, 13, 910).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, 33, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 33, 1, 160).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 33, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 33, 7, 250).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 33, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 33, 1, 450).toDate()).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.OK).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 33, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 33, 23, 550).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, 33, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 33, 1, 50).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 33, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 33, 17, 30).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 33, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 33, 21, 390).toDate()).buildExample())).buildExample()));
    doReturn(testCaseAsSortedSet).when(testSuite).getTestCasesAsSortedSet();
    String output = testling.createOutput();
    Assert.assertEquals(output, loadExpectedOutput(TestSuiteState.CRITICAL_IN_SUITE.name()));
}
Also used : TestCase(org.sakuli.datamodel.TestCase) TreeSet(java.util.TreeSet) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) DateTime(org.joda.time.DateTime) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 19 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class CheckMKTemplateOutputBuilderTest method testCritInCase.

@Test
public void testCritInCase() throws Exception {
    doReturn("example_xfce").when(testSuite).getId();
    doReturn(TestSuiteState.CRITICAL_IN_CASE).when(testSuite).getState();
    doReturn(300).when(testSuite).getWarningTime();
    doReturn(400).when(testSuite).getCriticalTime();
    doReturn(46.96f).when(testSuite).getDuration();
    doReturn(new DateTime(1970, 1, 1, 10, 35, 0).toDate()).when(testSuite).getStartDate();
    doReturn(new DateTime(1970, 1, 1, 10, 35, 46, 960).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, 35, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 35, 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, 35, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 35, 1, 280).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 35, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 35, 7, 310).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 35, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 35, 1, 470).toDate()).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.CRITICAL).withWarningTime(2).withCriticalTime(3).withStartDate(new DateTime(1970, 1, 1, 10, 35, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 35, 33, 700).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, 35, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 35, 1, 80).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 35, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 35, 7, 120).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 35, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 35, 1, 440).toDate()).buildExample())).buildExample()));
    doReturn(testCaseAsSortedSet).when(testSuite).getTestCasesAsSortedSet();
    String output = testling.createOutput();
    Assert.assertEquals(output, loadExpectedOutput(TestSuiteState.CRITICAL_IN_CASE.name()));
}
Also used : TestCase(org.sakuli.datamodel.TestCase) TreeSet(java.util.TreeSet) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) DateTime(org.joda.time.DateTime) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 20 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class CheckMKTemplateOutputBuilderTest method testWarnInCase.

@Test
public void testWarnInCase() throws Exception {
    doReturn("example_xfce").when(testSuite).getId();
    doReturn(TestSuiteState.WARNING_IN_CASE).when(testSuite).getState();
    doReturn(300).when(testSuite).getWarningTime();
    doReturn(400).when(testSuite).getCriticalTime();
    doReturn(42.84f).when(testSuite).getDuration();
    doReturn(new DateTime(1970, 1, 1, 10, 34, 0).toDate()).when(testSuite).getStartDate();
    doReturn(new DateTime(1970, 1, 1, 10, 34, 42, 840).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, 34, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 34, 14, 30).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, 34, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 34, 1, 160).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 34, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 34, 7, 340).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 34, 0, 30).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 34, 1, 460).toDate()).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.WARNING).withWarningTime(2).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 34, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 34, 33, 540).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, 34, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 34, 0, 940).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 34, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 34, 7, 140).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 34, 0, 30).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 34, 1, 390).toDate()).buildExample())).buildExample()));
    doReturn(testCaseAsSortedSet).when(testSuite).getTestCasesAsSortedSet();
    String output = testling.createOutput();
    Assert.assertEquals(output, loadExpectedOutput(TestSuiteState.WARNING_IN_CASE.name()));
}
Also used : TestCase(org.sakuli.datamodel.TestCase) TreeSet(java.util.TreeSet) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) DateTime(org.joda.time.DateTime) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Aggregations

TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)29 Test (org.testng.annotations.Test)29 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)17 BaseTest (org.sakuli.BaseTest)15 TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)15 TestSuite (org.sakuli.datamodel.TestSuite)15 TestCase (org.sakuli.datamodel.TestCase)14 TreeSet (java.util.TreeSet)7 DateTime (org.joda.time.DateTime)7 SakuliException (org.sakuli.exceptions.SakuliException)7 Path (java.nio.file.Path)6 SakuliExceptionWithScreenshot (org.sakuli.exceptions.SakuliExceptionWithScreenshot)5 GearmanProperties (org.sakuli.services.forwarder.gearman.GearmanProperties)4 Date (java.util.Date)2 SqlLobValue (org.springframework.jdbc.core.support.SqlLobValue)2 Future (java.util.concurrent.Future)1 GearmanJobServerConnection (org.gearman.common.GearmanJobServerConnection)1 LoggerTest (org.sakuli.LoggerTest)1 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)1 TestCaseStepState (org.sakuli.datamodel.state.TestCaseStepState)1