Search in sources :

Example 16 with TestSuiteExampleBuilder

use of org.sakuli.builder.TestSuiteExampleBuilder 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>");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) SakuliException(org.sakuli.exceptions.SakuliException) Date(java.util.Date) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 17 with TestSuiteExampleBuilder

use of org.sakuli.builder.TestSuiteExampleBuilder 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");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 18 with TestSuiteExampleBuilder

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

the class Icinga2OutputBuilderTest method testBuildCritical.

@Test
public void testBuildCritical() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.CRITICAL_IN_SUITE).withCriticalTime(100).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.OK).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" critical (120.00s/crit at 100s). (Last suite run: 17.08.14 14:02:00)\n" + "[OK] case \"TEST-CASE-ID\" ran in 3.00s - ok");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 19 with TestSuiteExampleBuilder

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

the class Icinga2OutputBuilderTest method testBuildWarningInCase.

@Test
public void testBuildWarningInCase() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.WARNING_IN_CASE).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.WARNING).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[WARN] Sakuli suite \"TEST-SUITE-ID\" warning in case, case \"Unit Test Case\" over runtime (3.00s/warn at 4s). (Last suite run: 17.08.14 14:02:00)\n" + "[WARN] case \"TEST-CASE-ID\" over runtime (3.00s/warn at 4s)");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 20 with TestSuiteExampleBuilder

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

the class Icinga2OutputBuilderTest method testBuildErrorInStep.

@Test
public void testBuildErrorInStep() 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).withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withException(new SakuliException("MY-TEST-ERROR-IN-STEP")).buildExample())).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" (120.00s) EXCEPTION: 'CASE \"TEST-CASE-ID\": STEP \"step_for_unit_test\": MY-TEST-ERROR-IN-STEP'. (Last suite run: 17.08.14 14:02:00)\n" + "[CRIT] case \"TEST-CASE-ID\" EXCEPTION: STEP \"step_for_unit_test\": MY-TEST-ERROR-IN-STEP");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) SakuliException(org.sakuli.exceptions.SakuliException) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test)

Aggregations

TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)23 TestSuite (org.sakuli.datamodel.TestSuite)21 Test (org.testng.annotations.Test)21 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)15 SakuliException (org.sakuli.exceptions.SakuliException)8 BaseTest (org.sakuli.BaseTest)6 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)6 Date (java.util.Date)3 Path (java.nio.file.Path)2 NagiosOutput (org.sakuli.services.forwarder.gearman.model.NagiosOutput)2 BeforeMethod (org.testng.annotations.BeforeMethod)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 SakuliActionException (org.sakuli.exceptions.SakuliActionException)1 SakuliExceptionHandler (org.sakuli.exceptions.SakuliExceptionHandler)1 SakuliExceptionWithScreenshot (org.sakuli.exceptions.SakuliExceptionWithScreenshot)1 NagiosCachedCheckResult (org.sakuli.services.forwarder.gearman.model.NagiosCachedCheckResult)1