Package org.sonar.api.resources

Examples of org.sonar.api.resources.Resource


   */
  public void clear() {
    Iterator<Map.Entry<Resource, Bucket>> it = buckets.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry<Resource, Bucket> entry = it.next();
      Resource resource = entry.getKey();
      if (!ResourceUtils.isSet(resource)) {
        entry.getValue().clear();
        it.remove();
      }
    }
View Full Code Here


  @CheckForNull
  @Override
  public <M> M getMeasures(Resource resource, MeasuresFilter<M> filter) {
    // Reload resource so that effective key is populated
    Resource indexedResource = getResource(resource);
    if (indexedResource == null) {
      return null;
    }
    Iterable<Measure> unfiltered;
    if (filter instanceof MeasuresFilters.MetricFilter) {
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public List<Violation> getViolations(ViolationQuery violationQuery) {
    Resource resource = violationQuery.getResource();
    if (resource == null) {
      throw new IllegalArgumentException("A resource must be set on the ViolationQuery in order to search for violations.");
    }

    if (!Scopes.isHigherThanOrEquals(resource, Scopes.FILE)) {
View Full Code Here

    assertThat(decorator.shouldComputeVariation(new File("foo/bar.c"))).isFalse();
  }

  @Test
  public void shouldCompareAndSaveVariation() {
    Resource dir = new Directory("org/foo");

    PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class);
    PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1);
    PastSnapshot pastSnapshot3 = new PastSnapshot("days", new Date()).setIndex(3);
View Full Code Here

    rule2.setId(2);

    when(ruleFinder.findByKey(rule1.ruleKey())).thenReturn(rule1);
    when(ruleFinder.findByKey(rule2.ruleKey())).thenReturn(rule2);

    Resource dir = new Directory("org/foo");

    PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class);
    PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1);

    // first past analysis
View Full Code Here

    assertThat(filter.accept(mock(Resource.class), otherMeasure)).isTrue();
  }

  @Test
  public void shouldFilterFileBasedOnPattern() {
    Resource resource = File.create("src/org/polop/File.php", "org/polop/File.php", null, false);
    Measure coverageMeasure = mock(Measure.class);
    when(coverageMeasure.getMetric()).thenReturn(CoreMetrics.LINES_TO_COVER);

    settings.setProperty("sonar.coverage.exclusions", "src/org/polop/*");
    filter.initPatterns();
View Full Code Here

    assertThat(filter.accept(resource, coverageMeasure)).isFalse();
  }

  @Test
  public void shouldNotFilterFileBasedOnPattern() {
    Resource resource = File.create("src/org/polop/File.php", "org/polop/File.php", null, false);
    Measure coverageMeasure = mock(Measure.class);
    when(coverageMeasure.getMetric()).thenReturn(CoreMetrics.COVERAGE);

    settings.setProperty("sonar.coverage.exclusions", "src/org/other/*");
    filter.initPatterns();
View Full Code Here

    fs.add(newInputFile("src/main/java/foo/bar/Foo.java", "sample code", "foo/bar/Foo.java", "java", false));
    Languages languages = new Languages(Java.INSTANCE);
    ComponentIndexer indexer = createIndexer(languages);
    indexer.execute(fs);

    Resource sonarFile = org.sonar.api.resources.File.create("src/main/java/foo/bar/Foo.java", "foo/bar/Foo.java", Java.INSTANCE, false);
    verify(sonarIndex).index(sonarFile);
    verify(sourcePersister).saveSource(sonarFile, "sample code", null);
  }
View Full Code Here

      .setLanguage("java"));
    Languages languages = new Languages(Java.INSTANCE);
    ComponentIndexer indexer = createIndexer(languages);
    indexer.execute(fs);

    Resource sonarFile = org.sonar.api.resources.File.create("src/main/java/foo/bar/Foo.java", "foo/bar/Foo.java", Java.INSTANCE, false);

    verify(sourcePersister).saveSource(eq(sonarFile), argThat(new ArgumentMatcher<String>() {
      @Override
      public boolean matches(Object arg0) {
        String source = (String) arg0;
View Full Code Here

      .setLanguage("java"));
    Languages languages = new Languages(Java.INSTANCE);
    ComponentIndexer indexer = createIndexer(languages);
    indexer.execute(fs);

    Resource sonarFile = org.sonar.api.resources.File.create("/src/main/java/foo/bar/Foo.java", "foo/bar/Foo.java", Java.INSTANCE, false);

    verify(sourcePersister).saveSource(eq(sonarFile), argThat(new ArgumentMatcher<String>() {
      @Override
      public boolean matches(Object arg0) {
        String source = (String) arg0;
View Full Code Here

TOP

Related Classes of org.sonar.api.resources.Resource

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.