@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;;;;"); }
protected static String getTestSuitePerformanceData(TestSuite testSuite) { OutputState outputState = OutputState.lookupSakuliState(testSuite.getState()); String data = ""; data = addPerformanceDataRow(data, "suite__state", String.valueOf(outputState.getErrorCode()), null, null); data = addPerformanceDataRow4Threshold(data, "suite", testSuite.getWarningTime(), testSuite.getCriticalTime()); final String suiteName = "suite_" + testSuite.getId(); if (testSuite.getState() != null && testSuite.getState().isFinishedWithoutErrors()) { data = addPerformanceDataRow(data, suiteName, testSuite.getDuration(), testSuite.getWarningTime(), testSuite.getCriticalTime()); } else { data = addUnknownPerformanceDataRow(data, suiteName); } data = addTestCasePerformanceData(data, testSuite.getTestCasesAsSortedSet()); return data; }
AbstractPerformanceDataBuilder { protected static String getTestSuitePerformanceData(TestSuite testSuite) { OutputState outputState = OutputState.lookupSakuliState(testSuite.getState()); String data = ""; data = addPerformanceDataRow(data, "suite__state", String.valueOf(outputState.getErrorCode()), null, null); data = addPerformanceDataRow4Threshold(data, "suite", testSuite.getWarningTime(), testSuite.getCriticalTime()); final String suiteName = "suite_" + testSuite.getId(); if (testSuite.getState() != null && testSuite.getState().isFinishedWithoutErrors()) { data = addPerformanceDataRow(data, suiteName, testSuite.getDuration(), testSuite.getWarningTime(), testSuite.getCriticalTime()); } else { data = addUnknownPerformanceDataRow(data, suiteName); } data = addTestCasePerformanceData(data, testSuite.getTestCasesAsSortedSet()); return data; } }
AbstractPerformanceDataBuilder { protected static String getTestSuitePerformanceData(TestSuite testSuite) { OutputState outputState = OutputState.lookupSakuliState(testSuite.getState()); String data = ""; data = addPerformanceDataRow(data, "suite__state", String.valueOf(outputState.getErrorCode()), null, null); data = addPerformanceDataRow4Threshold(data, "suite", testSuite.getWarningTime(), testSuite.getCriticalTime()); final String suiteName = "suite_" + testSuite.getId(); if (testSuite.getState() != null && testSuite.getState().isFinishedWithoutErrors()) { data = addPerformanceDataRow(data, suiteName, testSuite.getDuration(), testSuite.getWarningTime(), testSuite.getCriticalTime()); } else { data = addUnknownPerformanceDataRow(data, suiteName); } data = addTestCasePerformanceData(data, testSuite.getTestCasesAsSortedSet()); return data; }  }
AbstractPerformanceDataBuilder { protected static String getTestSuitePerformanceData(TestSuite testSuite) { OutputState outputState = OutputState.lookupSakuliState(testSuite.getState()); String data = ""; data = addPerformanceDataRow(data, "suite__state", String.valueOf(outputState.getErrorCode()), null, null); data = addPerformanceDataRow4Threshold(data, "suite", testSuite.getWarningTime(), testSuite.getCriticalTime()); final String suiteName = "suite_" + testSuite.getId(); if (testSuite.getState() != null && testSuite.getState().isFinishedWithoutErrors()) { data = addPerformanceDataRow(data, suiteName, testSuite.getDuration(), testSuite.getWarningTime(), testSuite.getCriticalTime()); } else { data = addUnknownPerformanceDataRow(data, suiteName); } data = addTestCasePerformanceData(data, testSuite.getTestCasesAsSortedSet()); return data; }   }
AbstractPerformanceDataBuilder { protected static String getTestSuitePerformanceData(TestSuite testSuite) { OutputState outputState = OutputState.lookupSakuliState(testSuite.getState()); String data = ""; data = addPerformanceDataRow(data, "suite__state", String.valueOf(outputState.getErrorCode()), null, null); data = addPerformanceDataRow4Threshold(data, "suite", testSuite.getWarningTime(), testSuite.getCriticalTime()); final String suiteName = "suite_" + testSuite.getId(); if (testSuite.getState() != null && testSuite.getState().isFinishedWithoutErrors()) { data = addPerformanceDataRow(data, suiteName, testSuite.getDuration(), testSuite.getWarningTime(), testSuite.getCriticalTime()); } else { data = addUnknownPerformanceDataRow(data, suiteName); } data = addTestCasePerformanceData(data, testSuite.getTestCasesAsSortedSet()); return data; }    }