コード例 #1
0
  {
    m_sampleModelViewsStubFactory.setResult(
        "getCumulativeStatisticsView", m_statisticsServices.getSummaryStatisticsView());
    m_sampleModelViewsStubFactory.setResult("getTestStatisticsQueries", m_testStatisticsQueries);
    m_sampleModelViewsStubFactory.setResult("getNumberFormat", new DecimalFormat("0.0"));

    m_sampleModelStubFactory.setResult(
        "getTotalCumulativeStatistics", m_statisticsServices.getStatisticsSetFactory().create());
  }
コード例 #2
0
  public void testWithData() throws Exception {
    final Timer timer = new StubTimer();

    final SampleModelImplementation sampleModelImplementation =
        new SampleModelImplementation(
            new ConsoleProperties(m_resources, m_file),
            m_statisticsServices,
            timer,
            m_resources,
            null);

    final CumulativeStatisticsTableModel model =
        new CumulativeStatisticsTableModel(
            sampleModelImplementation, m_sampleModelViews, m_resources, m_swingDispatcherFactory);

    model.newTests(null, new ModelTestIndex());

    assertEquals(1, model.getRowCount());
    assertNull(model.getForeground(0, 0));
    assertNull(model.getBackground(0, 0));

    final Test[] tests = {
      new StubTest(1, "test 1"), new StubTest(2, "test 2"),
    };

    sampleModelImplementation.registerTests(Arrays.asList(tests));

    assertEquals(3, model.getRowCount());
    assertNull(model.getForeground(0, 0));
    assertNull(model.getBackground(0, 0));
    assertEquals("t3st 1", model.getValueAt(0, 0));
    assertEquals("test 1", model.getValueAt(0, 1));
    assertEquals("0", model.getValueAt(0, 3));
    assertNull(model.getForeground(0, 3));
    assertNull(model.getForeground(2, 3));

    final StatisticsSet statistics = m_statisticsServices.getStatisticsSetFactory().create();
    statistics.addValue(m_statisticsServices.getStatisticsIndexMap().getLongIndex("errors"), 1);

    final TestStatisticsMap testStatisticsMap = new TestStatisticsMap();
    testStatisticsMap.put(tests[0], statistics);
    sampleModelImplementation.addTestReport(testStatisticsMap);

    assertEquals("1", model.getValueAt(0, 3));
    assertEquals(Color.RED, model.getForeground(0, 3));
    assertNull(model.getForeground(0, 2));
    assertEquals(Color.RED, model.getForeground(2, 3));
  }