Search in sources :

Example 16 with TestCaseStepExampleBuilder

use of org.sakuli.builder.TestCaseStepExampleBuilder 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)

Example 17 with TestCaseStepExampleBuilder

use of org.sakuli.builder.TestCaseStepExampleBuilder 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)

Example 18 with TestCaseStepExampleBuilder

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

the class AbstractPerformanceDataBuilderTest method testGetPerformanceData.

@Test
public void testGetPerformanceData() 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(Arrays.asList(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 TestCaseStepExampleBuilder().withName("step2").withState(TestCaseStepState.OK).withStartDate(DateUtils.addSeconds(startDate, 11)).withStopDate(DateUtils.addSeconds(startDate, 19)).withWarningTime(10).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.OK).withId("case with no steps").withStartDate(DateUtils.addSeconds(startDate, 25)).withStopDate(DateUtils.addSeconds(startDate, 40)).withWarningTime(0).withCriticalTime(0).withTestCaseSteps(null).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=8.00s;10;;; " + "c_002__state=0;;;; " + "c_002_case_with_no_steps=15.00s;;;;");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) BaseTest(org.sakuli.BaseTest) Test(org.testng.annotations.Test)

Example 19 with TestCaseStepExampleBuilder

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

the class CheckMKTemplateOutputBuilderTest method testWarnInStep.

@Test
public void testWarnInStep() throws Exception {
    doReturn("example_xfce").when(testSuite).getId();
    doReturn(TestSuiteState.WARNING_IN_STEP).when(testSuite).getState();
    doReturn(300).when(testSuite).getWarningTime();
    doReturn(400).when(testSuite).getCriticalTime();
    doReturn(44.75f).when(testSuite).getDuration();
    doReturn(new DateTime(1970, 1, 1, 10, 31, 0).toDate()).when(testSuite).getStartDate();
    doReturn(new DateTime(1970, 1, 1, 10, 31, 44, 750).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, 31, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 31, 13, 830).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, 31, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 31, 1, 80).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 31, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 31, 7, 140).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 31, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 31, 1, 550).toDate()).buildExample())).buildExample(), new TestCaseExampleBuilder().withState(TestCaseState.WARNING_IN_STEP).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 31, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 31, 33, 430).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, 31, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 31, 0, 930).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.WARNING).withName("Calculation_(case2)").withWarningTime(1).withStartDate(new DateTime(1970, 1, 1, 10, 31, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 31, 7, 20).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 31, 0, 30).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 31, 1, 420).toDate()).buildExample())).buildExample()));
    doReturn(testCaseAsSortedSet).when(testSuite).getTestCasesAsSortedSet();
    String output = testling.createOutput();
    Assert.assertEquals(output, loadExpectedOutput(TestSuiteState.WARNING_IN_STEP.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

TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)19 Test (org.testng.annotations.Test)19 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)17 BaseTest (org.sakuli.BaseTest)15 TestCase (org.sakuli.datamodel.TestCase)11 DateTime (org.joda.time.DateTime)9 TreeSet (java.util.TreeSet)7 TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)6 TestSuite (org.sakuli.datamodel.TestSuite)6 Path (java.nio.file.Path)4 SakuliException (org.sakuli.exceptions.SakuliException)4 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)3 SakuliExceptionWithScreenshot (org.sakuli.exceptions.SakuliExceptionWithScreenshot)3 GearmanProperties (org.sakuli.services.forwarder.gearman.GearmanProperties)3 Date (java.util.Date)2 Future (java.util.concurrent.Future)1 GearmanJobServerConnection (org.gearman.common.GearmanJobServerConnection)1 LoggerTest (org.sakuli.LoggerTest)1 TestCaseStepState (org.sakuli.datamodel.state.TestCaseStepState)1 SakuliActionException (org.sakuli.exceptions.SakuliActionException)1