Package org.sonar.api.batch

Examples of org.sonar.api.batch.DecoratorContext


    when(context.getMeasure(CoreMetrics.UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.UNCOVERED_CONDITIONS, (double) uncoveredConditions));
    return context;
  }

  private static DecoratorContext mockNewContext(Measure newLines, Measure newUncoveredConditions, Measure newUncoveredLines, Measure newConditions) {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.NEW_LINES_TO_COVER)).thenReturn(newLines);
    when(context.getMeasure(CoreMetrics.NEW_UNCOVERED_LINES)).thenReturn(newUncoveredLines);
    when(context.getMeasure(CoreMetrics.NEW_UNCOVERED_CONDITIONS)).thenReturn(newUncoveredConditions);
    when(context.getMeasure(CoreMetrics.NEW_CONDITIONS_TO_COVER)).thenReturn(newConditions);
    return context;
  }
View Full Code Here


    assertThat(metrics).containsOnly(CoreMetrics.UNCOVERED_LINES, CoreMetrics.LINES_TO_COVER, CoreMetrics.NEW_UNCOVERED_LINES, CoreMetrics.NEW_LINES_TO_COVER);
  }

  @Test
  public void lineCoverage() {
    DecoratorContext context = mockContext(50, 10);

    decorator.decorate(project, context);

    // 50-10 covered lines / 50 lines
    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 80.0);
View Full Code Here

    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 80.0);
  }

  @Test
  public void zeroCoveredLines() {
    DecoratorContext context = mockContext(50, 50);

    decorator.decorate(project, context);

    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 0.0);
  }
View Full Code Here

    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 0.0);
  }

  @Test
  public void allCoveredLines() {
    DecoratorContext context = mockContext(50, 00);

    decorator.decorate(project, context);

    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 100.0);
  }
View Full Code Here

    verify(context).saveMeasure(CoreMetrics.LINE_COVERAGE, 100.0);
  }

  @Test
  public void noLineCoverageIfNoLines() {
    DecoratorContext context = mock(DecoratorContext.class);

    decorator.decorate(project, context);

    verify(context, never()).saveMeasure(eq(CoreMetrics.LINE_COVERAGE), anyDouble());
  }
View Full Code Here

    verify(context, never()).saveMeasure(eq(CoreMetrics.LINE_COVERAGE), anyDouble());
  }

  private static DecoratorContext mockContext(int lines, int uncoveredLines) {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.LINES_TO_COVER)).thenReturn(new Measure(CoreMetrics.LINES_TO_COVER, (double) lines));
    when(context.getMeasure(CoreMetrics.UNCOVERED_LINES)).thenReturn(new Measure(CoreMetrics.UNCOVERED_LINES, (double) uncoveredLines));
    return context;
  }
View Full Code Here

public class NewCoverageAggregatorTest {

  @Test
  public void shouldNotSaveDataWhenNoMeasures() {
    NewCoverageAggregator aggregator = new NewCoverageAggregator();
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getChildrenMeasures(CoreMetrics.NEW_LINES_TO_COVER)).thenReturn(Collections.<Measure>emptyList());

    aggregator.aggregate(context, CoreMetrics.NEW_LINES_TO_COVER, 3);

    verify(context, never()).saveMeasure(Matchers.<Measure>anyObject());
  }
View Full Code Here

  }

  @Test
  public void shouldNotsetZeroWhenNoValueOnPeriod() {
    NewCoverageAggregator aggregator = new NewCoverageAggregator();
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getChildrenMeasures(CoreMetrics.NEW_LINES_TO_COVER)).thenReturn(Arrays.asList(newMeasure(null, 3.0, 2.0), newMeasure(null, 13.0, null)));

    aggregator.aggregate(context, CoreMetrics.NEW_LINES_TO_COVER, 3);

    verify(context).saveMeasure(argThat(new ArgumentMatcher<Measure>() {
      @Override
View Full Code Here

  }

  @Test
  public void shouldSumValues() {
    NewCoverageAggregator aggregator = new NewCoverageAggregator();
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getChildrenMeasures(CoreMetrics.NEW_LINES_TO_COVER)).thenReturn(Arrays.asList(newMeasure(null, 3.0, 2.0), newMeasure(null, 13.0, null)));

    aggregator.aggregate(context, CoreMetrics.NEW_LINES_TO_COVER, 3);

    verify(context).saveMeasure(argThat(new ArgumentMatcher<Measure>() {
      @Override
View Full Code Here

      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);
    decorator.decorate(new Directory("org/foo"), context);

    verify(analyser).analyseLevel(Arrays.asList(1200.0, 1300.0, 1150.0, 1400.0));
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.DecoratorContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.