Package org.sonar.api.batch

Examples of org.sonar.api.batch.DecoratorContext


    when(resource.getQualifier()).thenReturn(Qualifiers.PROJECT);
  }

  @Test
  public void shouldSaveBranchCoverage() {
    DecoratorContext context = mockContext(20, 15);

    decorator.decorate(resource, context);

    verify(context).saveMeasure(CoreMetrics.IT_BRANCH_COVERAGE, 25.0);
  }
View Full Code Here


    verify(context).saveMeasure(CoreMetrics.IT_BRANCH_COVERAGE, 25.0);
  }

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

    decorator.decorate(resource, context);

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

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

    DecoratorContext context = mock(DecoratorContext.class);
    TendencyDecorator decorator = new TendencyDecorator(timeMachine, query, analyser);
    decorator.decorate(new Directory("org/foo"), context);

    verify(analyser, never()).analyseLevel(anyList());
  }
View Full Code Here

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

  private static DecoratorContext mockContext(int conditions, int uncoveredConditions) {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER)).thenReturn(new Measure(CoreMetrics.IT_CONDITIONS_TO_COVER, (double) conditions));
    when(context.getMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.IT_UNCOVERED_CONDITIONS, (double) uncoveredConditions));
    return context;
  }
View Full Code Here

    File file = new File("foo.c");
    Issuable issuable = mock(Issuable.class);
    when(perspectives.as(Issuable.class, file)).thenReturn(issuable);
    when(issuable.resolvedIssues()).thenReturn(Arrays.<Issue>asList(falsePositive, fixed));

    DecoratorContext context = mock(DecoratorContext.class);
    decorator.decorate(file, context);

    verify(context).saveMeasure(CoreMetrics.FALSE_POSITIVE_ISSUES, 1.0);
  }
View Full Code Here

  @Test
  public void should_ignore_classes_and_methods() {
    JavaClass javaClass = JavaClass.create("Foo.java");
    when(perspectives.as(Issuable.class, javaClass)).thenReturn(null);

    DecoratorContext context = mock(DecoratorContext.class);
    decorator.decorate(javaClass, context);

    verifyZeroInteractions(context);
  }
View Full Code Here

    when(resource.getQualifier()).thenReturn(Qualifiers.PROJECT);
  }

  @Test
  public void shouldSaveBranchCoverage() {
    DecoratorContext context = mockContext(20, 15);

    decorator.decorate(resource, context);

    verify(context).saveMeasure(CoreMetrics.OVERALL_BRANCH_COVERAGE, 25.0);
  }
View Full Code Here

    verify(context).saveMeasure(CoreMetrics.OVERALL_BRANCH_COVERAGE, 25.0);
  }

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

    decorator.decorate(resource, context);

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

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

  private static DecoratorContext mockContext(int conditions, int uncoveredConditions) {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER)).thenReturn(new Measure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER, (double) conditions));
    when(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, (double) uncoveredConditions));
    return context;
  }
View Full Code Here

        CoreMetrics.NEW_OVERALL_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.OVERALL_LINE_COVERAGE, 80.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.