Search in sources :

Example 1 with TestCaseExampleBuilder

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

Example 2 with TestCaseExampleBuilder

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

the class Icinga2OutputBuilderTest method testBuildErrorInSuite.

@Test
public void testBuildErrorInSuite() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.ERRORS).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.OK).buildExample())).withException(new SakuliException("MY-TEST-ERROR-SUITE")).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" (120.00s) EXCEPTION: 'MY-TEST-ERROR-SUITE'. (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) SakuliException(org.sakuli.exceptions.SakuliException) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 3 with TestCaseExampleBuilder

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

the class Icinga2OutputBuilderTest method testBuildErrorInCaseMaxLength.

@Test
public void testBuildErrorInCaseMaxLength() 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 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")).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 " + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...\n" + "[CRIT] case \"TEST-CASE-ID\" EXCEPTION: MY-TEST-ERROR-CASE " + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}
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 4 with TestCaseExampleBuilder

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

the class Icinga2OutputBuilderTest method testBuildCriticalInCase.

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

Example 5 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder 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()));
}
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