示例#1
0
  @Test(expected = SonarException.class)
  public void shouldFailIfAddingSameMeasures() {
    Bucket fileBucket = new Bucket(javaFile);
    Measure measure = new Measure(ncloc).setValue(1200.0);
    fileBucket.addMeasure(measure);

    measure = new Measure(ncloc).setValue(500.0);
    fileBucket.addMeasure(measure);
  }
示例#2
0
 @Test
 public void shouldCacheViolations() {
   Bucket fileBucket = new Bucket(javaFile);
   Violation violation =
       Violation.create(Rule.create("checkstyle", "rule1", "Rule one"), javaFile);
   fileBucket.addViolation(violation);
   assertThat(fileBucket.getViolations().size(), is(1));
   assertThat(fileBucket.getViolations(), hasItem(violation));
 }
示例#3
0
  @Test
  public void shouldAddNewMeasure() {
    Bucket fileBucket = new Bucket(javaFile);
    Measure measure = new Measure(ncloc).setValue(1200.0);
    fileBucket.addMeasure(measure);

    assertThat(fileBucket.getMeasures(MeasuresFilters.all()).size(), is(1));
    assertThat(fileBucket.getMeasures(MeasuresFilters.metric(ncloc)), is(measure));
  }
示例#4
0
  @Test
  public void shouldManageRelationships() {
    Bucket packageBucket = new Bucket(javaPackage);
    Bucket fileBucket = new Bucket(javaFile);
    fileBucket.setParent(packageBucket);

    assertThat(fileBucket.getParent(), is(packageBucket));
    assertThat(packageBucket.getChildren().size(), is(1));
    assertThat(packageBucket.getChildren(), hasItem(fileBucket));
  }