コード例 #1
0
  @Test
  public void testUpdate() {
    SingleConsole singleConsole =
        new SingleConsole(12345) {
          @Override
          public long getCurrentRunningTime() {
            return 2000;
          }

          @Override
          public Map<String, Object> getStatictisData() {
            Map<String, Object> newMap = new HashMap<String, Object>();
            Map<Object, Object> errorMap = new HashMap<Object, Object>();
            errorMap.put("Tests", new Double(testCount));
            errorMap.put("Errors", new Double(errorCount));
            newMap.put("totalStatistics", errorMap);
            return newMap;
          }

          @Override
          protected void updateStatistics(
              StatisticsSet intervalStatisticsSnapshot,
              StatisticsSet cumulatedStatisticsSnapshot) {}

          @Override
          protected Map<String, Object> getStatisticData() {
            return new HashMap<String, Object>();
          }
        };

    singleConsole.update(null, null);
    singleConsole.startSampling(0);

    SampleModelImplementationEx sampleModelMock = mock(SampleModelImplementationEx.class);

    singleConsole.setSampleModel(sampleModelMock);
    StatisticExpression exp = mock(StatisticExpression.class);
    StatisticsSet statisticMock = mock(StatisticsSet.class);
    StatisticsSet statisticCumulatedMock = mock(StatisticsSet.class);
    when(statisticMock.snapshot()).thenReturn(statisticMock);
    when(statisticCumulatedMock.snapshot()).thenReturn(statisticCumulatedMock);
    when(exp.getDoubleValue(any(StatisticsSet.class))).thenReturn(3D);
    when(sampleModelMock.getTPSExpression()).thenReturn(exp);

    singleConsole.update(statisticMock, statisticCumulatedMock);
    singleConsole.update(statisticMock, statisticCumulatedMock);
  }