Package org.sonar.api.resources

Examples of org.sonar.api.resources.Directory


  @Test
  public void should_get_measures() throws Exception {
    MeasureCache cache = new MeasureCache(caches, metricFinder, techDebtModel);
    Project p = new Project("struts");
    Resource dir = new Directory("foo/bar").setEffectiveKey("struts:foo/bar");
    Resource file1 = new File("foo/bar/File1.txt").setEffectiveKey("struts:foo/bar/File1.txt");
    Resource file2 = new File("foo/bar/File2.txt").setEffectiveKey("struts:foo/bar/File2.txt");

    assertThat(cache.entries()).hasSize(0);
View Full Code Here


  @Test
  public void shouldIndexParentOfDeprecatedFiles() {
    File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
    assertThat(index.index(file)).isTrue();

    Directory reference = Directory.create("src/org/foo", "org/foo");
    assertThat(index.getResource(reference).getName()).isEqualTo("src/org/foo");
    assertThat(index.isIndexed(reference, true)).isTrue();
    assertThat(index.isExcluded(reference)).isFalse();
    assertThat(index.getChildren(reference)).hasSize(1);
    assertThat(index.getParent(reference)).isInstanceOf(Project.class);
View Full Code Here

    assertThat(index.getParent(reference)).isInstanceOf(Project.class);
  }

  @Test
  public void shouldIndexTreeOfResources() {
    Directory directory = Directory.create("src/org/foo", "org/foo");
    File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", Java.INSTANCE, false);

    assertThat(index.index(directory)).isTrue();
    assertThat(index.index(file, directory)).isTrue();
View Full Code Here

    assertThat(index.isExcluded(reference)).isFalse();
  }

  @Test
  public void shouldNotIndexResourceIfParentNotIndexed() {
    Directory directory = Directory.create("src/org/other", "org/other");
    File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);

    assertThat(index.index(file, directory)).isFalse();

    File fileRef = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
View Full Code Here

    assertThat(distribution.getPersistenceMode().useDatabase(), is(true));
  }

  @Test
  public void shouldPersistWhenScopeHigherThanMinimun() throws Exception {
    when(context.getResource()).thenReturn(new Directory("org/foo"));

    initContextWithChildren();
    formula.setMinimumScopeToPersist(Scopes.FILE);

    Measure distribution = formula.calculate(data, context);
View Full Code Here

    fileLineMeasures = new DefaultFileLinesContext(index, resource);
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldNotAllowCreationForDirectory() {
    new DefaultFileLinesContext(index, new Directory("key"));
  }
View Full Code Here

    setupData("shared");

    DefaultResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), snapshotCache, resourceCache);
    persister.saveProject(multiModuleProject, null);
    persister.saveProject(moduleA, multiModuleProject);
    persister.saveResource(moduleA, new Directory("org/foo").setEffectiveKey("a:org/foo"));
    persister.saveResource(moduleA, new File("org/foo/MyClass.java").setEffectiveKey("a:org/foo/MyClass.java"));
    persister.clear();

    assertThat(persister.getSnapshotsByResource().size(), is(2));
    assertThat(persister.getSnapshotsByResource().get(multiModuleProject), notNullValue());
View Full Code Here

TOP

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

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.