Ejemplo n.º 1
0
  @Test
  public void includeCurrentMeasures() throws ParseException {
    TendencyAnalyser analyser = mock(TendencyAnalyser.class);
    TimeMachineQuery query =
        new TimeMachineQuery(null).setMetrics(CoreMetrics.LINES, CoreMetrics.COVERAGE);
    TimeMachine timeMachine = mock(TimeMachine.class);

    when(timeMachine.getMeasuresFields(query))
        .thenReturn(
            Arrays.<Object[]>asList(
                new Object[] {date("2009-12-01"), CoreMetrics.LINES, 1200.0},
                new Object[] {date("2009-12-01"), CoreMetrics.COVERAGE, 80.5},
                new Object[] {date("2009-12-02"), CoreMetrics.LINES, 1300.0},
                new Object[] {date("2009-12-02"), CoreMetrics.COVERAGE, 79.6},
                new Object[] {date("2009-12-15"), CoreMetrics.LINES, 1150.0}));

    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.LINES)).thenReturn(new Measure(CoreMetrics.LINES, 1400.0));
    when(context.getMeasure(CoreMetrics.COVERAGE)).thenReturn(new Measure(CoreMetrics.LINES, 90.0));

    TendencyDecorator decorator = new TendencyDecorator(timeMachine, query, analyser, newConf());
    decorator.decorate(new JavaPackage("org.foo"), context);

    verify(analyser).analyseLevel(Arrays.asList(1200.0, 1300.0, 1150.0, 1400.0));
    verify(analyser).analyseLevel(Arrays.asList(80.5, 79.6, 90.0));
  }
Ejemplo n.º 2
0
  @Test
  public void initQuery() throws ParseException {
    Project project = mock(Project.class);
    when(project.getAnalysisDate()).thenReturn(date("2009-12-25"));

    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findAll())
        .thenReturn(
            Arrays.asList(
                CoreMetrics.LINES,
                CoreMetrics.COVERAGE,
                CoreMetrics.COVERAGE_LINE_HITS_DATA,
                CoreMetrics.PROFILE));

    TendencyDecorator decorator = new TendencyDecorator(null, metricFinder, newConf());

    TimeMachineQuery query = decorator.initQuery(project);
    assertThat(query.getMetrics().size(), is(2));
    assertThat(query.getMetrics(), hasItems(CoreMetrics.LINES, CoreMetrics.COVERAGE));
    assertThat(query.getFrom(), is(date("2009-11-25")));
    assertThat(query.isToCurrentAnalysis(), is(true));
  }