Examples of DecoratorContext


Examples of org.sonar.api.batch.DecoratorContext

  @Test
  public void should_count_elements_for_new_code() {
    Measure newLines = measureWithVariation(1, 100.0);
    Measure newConditions = measureWithVariation(1, 1.0);
    DecoratorContext context = mockNewContext(newLines, null, null, newConditions);

    long count = decorator.countElementsForNewCode(context, 1);

    assertThat(count).isEqualTo(101).isEqualTo(100 + 1);
  }
View Full Code Here

Examples of org.sonar.api.batch.DecoratorContext

  public void should_count_covered_elements_for_new_code() {
    Measure newLines = measureWithVariation(1, 100.0);
    Measure newUncoveredConditions = measureWithVariation(1, 10.0);
    Measure newUncoveredLines = measureWithVariation(1, 5.0);
    Measure newConditions = measureWithVariation(1, 1.0);
    DecoratorContext context = mockNewContext(newLines, newUncoveredConditions, newUncoveredLines, newConditions);

    long count = decorator.countCoveredElementsForNewCode(context, 1);

    assertThat(count).isEqualTo(86).isEqualTo(100 + 1 - 10 - 5);
  }
View Full Code Here

Examples of org.sonar.api.batch.DecoratorContext

    assertThat(count).isEqualTo(86).isEqualTo(100 + 1 - 10 - 5);
  }

  private static DecoratorContext mockContext(int lines, int uncoveredLines, int conditions, int uncoveredConditions) {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.OVERALL_LINES_TO_COVER)).thenReturn(new Measure(CoreMetrics.OVERALL_LINES_TO_COVER, (double) lines));
    when(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_LINES)).thenReturn(new Measure(CoreMetrics.OVERALL_UNCOVERED_LINES, (double) uncoveredLines));
    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

Examples of org.sonar.api.batch.DecoratorContext

    when(context.getMeasure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS)).thenReturn(new Measure(CoreMetrics.OVERALL_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_OVERALL_LINES_TO_COVER)).thenReturn(newLines);
    when(context.getMeasure(CoreMetrics.NEW_OVERALL_UNCOVERED_LINES)).thenReturn(newUncoveredLines);
    when(context.getMeasure(CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS)).thenReturn(newUncoveredConditions);
    when(context.getMeasure(CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER)).thenReturn(newConditions);
    return context;
  }
View Full Code Here

Examples of org.sonar.api.batch.DecoratorContext

public class CommentDensityDecoratorTest {

  @Test
  public void densityIsBalancedByNcloc() {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 300.0));
    when(context.getMeasure(CoreMetrics.COMMENT_LINES)).thenReturn(new Measure(CoreMetrics.COMMENT_LINES, 200.0));
    CommentDensityDecorator decorator = new CommentDensityDecorator();
    decorator.decorate(null, context);
    // 200 / (200 + 300) = 40%
    verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.COMMENT_LINES_DENSITY, 40.0)));
  }
View Full Code Here

Examples of org.sonar.api.batch.DecoratorContext

    verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.COMMENT_LINES_DENSITY, 40.0)));
  }

  @Test
  public void noDensityIfUnknownComments() {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 300.0));
    CommentDensityDecorator decorator = new CommentDensityDecorator();
    decorator.decorate(null, context);
    verify(context, never()).saveMeasure(argThat(new IsMeasure(CoreMetrics.COMMENT_LINES_DENSITY)));
  }
View Full Code Here

Examples of org.sonar.api.batch.DecoratorContext

    verify(context, never()).saveMeasure(argThat(new IsMeasure(CoreMetrics.COMMENT_LINES_DENSITY)));
  }

  @Test
  public void noDensityIfZeroNcloc() {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 0.0));
    when(context.getMeasure(CoreMetrics.COMMENT_LINES)).thenReturn(new Measure(CoreMetrics.COMMENT_LINES, 0.0));
    CommentDensityDecorator decorator = new CommentDensityDecorator();
    decorator.decorate(null, context);
    verify(context, never()).saveMeasure(argThat(new IsMeasure(CoreMetrics.COMMENT_LINES_DENSITY)));
  }
View Full Code Here

Examples of org.sonar.api.batch.DecoratorContext

    verify(context, never()).saveMeasure(argThat(new IsMeasure(CoreMetrics.COMMENT_LINES_DENSITY)));
  }

  @Test
  public void zeroDensityWhenZeroComments() {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getMeasure(CoreMetrics.NCLOC)).thenReturn(new Measure(CoreMetrics.NCLOC, 40.0));
    when(context.getMeasure(CoreMetrics.COMMENT_LINES)).thenReturn(new Measure(CoreMetrics.COMMENT_LINES, 0.0));
    CommentDensityDecorator decorator = new CommentDensityDecorator();
    decorator.decorate(null, context);
    verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.COMMENT_LINES_DENSITY, 0.0)));
  }
View Full Code Here

Examples of org.sonar.api.batch.DecoratorContext

  @Test
  public void doNotInsertZeroOnFiles() {
    DirectoriesDecorator decorator = new DirectoriesDecorator();
    Resource file = new File("foo.php");
    DecoratorContext context = mock(DecoratorContext.class);

    decorator.decorate(file, context);

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

Examples of org.sonar.api.batch.DecoratorContext

  @Test
  public void directoryCountsForOne() {
    DirectoriesDecorator decorator = new DirectoriesDecorator();
    Resource directory = new Directory("org/foo");
    DecoratorContext context = mock(DecoratorContext.class);
    decorator.decorate(directory, context);
    verify(context).saveMeasure(CoreMetrics.DIRECTORIES, 1.0);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.