Package org.sonar.api.resources

Examples of org.sonar.api.resources.Project


    verify(resourcePermissions, never()).grantDefaultRoles(project);
  }

  @Test
  public void doNotApplySecurityOnModules() {
    Project project = new Project("project");
    Project module = new Project("module").setParent(project);
    module.setId(10);
    when(resourcePermissions.hasRoles(project)).thenReturn(false);

    decorator.decorate(module, null);

    verify(resourcePermissions, never()).grantDefaultRoles(module);
View Full Code Here


    verify(resourcePermissions, never()).grantDefaultRoles(module);
  }

  @Test
  public void grantDefaultRolesWhenNoPermissions() {
    Project project = new Project("project");
    project.setId(10);
    when(resourcePermissions.hasRoles(project)).thenReturn(false);

    decorator.decorate(project, null);

    verify(resourcePermissions).grantDefaultRoles(project);
View Full Code Here

    DefaultInputDir inputDir = new DefaultInputDir("struts", "src/main/java/org/apache/struts");
    DeprecatedDefaultInputFile inputFile = new DeprecatedDefaultInputFile("struts", "src/main/java/org/apache/struts/Action.java");
    inputFile.setStatus(InputFile.Status.CHANGED);
    InputPathCache fileCache = mock(InputPathCache.class);
    when(fileCache.all()).thenReturn(Arrays.<InputPath>asList(inputDir, inputFile));
    Project rootModule = new Project("struts");
    Project moduleA = new Project("struts-core");
    moduleA.setParent(rootModule).setPath("core");
    Project moduleB = new Project("struts-ui");
    moduleB.setParent(rootModule).setPath("ui");
    jsonReport = new JsonReport(settings, fs, server, ruleFinder, issueCache, mock(EventBus.class),
      mode, userFinder, rootModule, fileCache);
  }
View Full Code Here

  ModuleInputFileCache moduleInputFileCache = mock(ModuleInputFileCache.class);

  @Test
  public void test_equals_and_hashCode() throws Exception {
    DefaultModuleFileSystem foo1 = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("foo"), settings, fileIndexer, initializer, componentIndexer);
    DefaultModuleFileSystem foo2 = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("foo"), settings, fileIndexer, initializer, componentIndexer);
    DefaultModuleFileSystem bar = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("bar"), settings, fileIndexer, initializer, componentIndexer);
    DefaultModuleFileSystem branch = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("bar", "branch", "My project"), settings, fileIndexer, initializer, componentIndexer);

    assertThat(foo1.moduleKey()).isEqualTo("foo");
    assertThat(branch.moduleKey()).isEqualTo("bar:branch");
    assertThat(foo1.equals(foo1)).isTrue();
    assertThat(foo1.equals(foo2)).isTrue();
View Full Code Here

  }

  @Test
  public void default_source_encoding() {
    DefaultModuleFileSystem fs = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("foo"), settings, fileIndexer, initializer, componentIndexer);

    assertThat(fs.sourceCharset()).isEqualTo(Charset.defaultCharset());
    assertThat(fs.isDefaultJvmEncoding()).isTrue();
  }
View Full Code Here

  @Test
  public void source_encoding_is_set() {
    settings.setProperty(CoreProperties.ENCODING_PROPERTY, "Cp1124");
    DefaultModuleFileSystem fs = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("foo"), settings, fileIndexer, initializer, componentIndexer);

    assertThat(fs.encoding()).isEqualTo(Charset.forName("Cp1124"));
    assertThat(fs.sourceCharset()).isEqualTo(Charset.forName("Cp1124"));

    // This test fails when default Java encoding is "IBM AIX Ukraine". Sorry for that.
View Full Code Here

    File javaTest = new File(basedir, "src/test/java");
    javaTest.mkdirs();
    when(initializer.tests()).thenReturn(Arrays.asList(javaTest, additionalTest));

    DefaultModuleFileSystem fs = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("foo"), settings, fileIndexer, initializer, componentIndexer);

    assertThat(fs.baseDir().getCanonicalPath()).isEqualTo(basedir.getCanonicalPath());
    assertThat(fs.workingDir().getCanonicalPath()).isEqualTo(workingDir.getCanonicalPath());
    assertThat(fs.buildDir().getCanonicalPath()).isEqualTo(buildDir.getCanonicalPath());
    assertThat(fs.sourceDirs()).hasSize(2);
View Full Code Here

    when(initializer.baseDir()).thenReturn(basedir);
    when(initializer.workingDir()).thenReturn(basedir);
    when(initializer.sources()).thenReturn(Arrays.asList(new File(basedir, "src/main/java")));

    DefaultModuleFileSystem fs = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("foo"), settings, fileIndexer, initializer, componentIndexer);

    File existingDir = temp.newFolder("new_folder");
    File notExistingDir = new File(existingDir, "not_exist");

    fs.resetDirs(existingDir, existingDir,
View Full Code Here

  }

  @Test
  public void should_search_input_files() throws Exception {
    DefaultModuleFileSystem fs = new DefaultModuleFileSystem(moduleInputFileCache,
      new Project("foo"), settings, fileIndexer, initializer, componentIndexer);

    File mainFile = temp.newFile();
    InputFile mainInput = new DeprecatedDefaultInputFile("foo", "Main.java").setFile(mainFile).setType(InputFile.Type.MAIN);
    InputFile testInput = new DeprecatedDefaultInputFile("foo", "Test.java").setFile(temp.newFile()).setType(InputFile.Type.TEST);
    when(moduleInputFileCache.inputFiles()).thenReturn(Lists.newArrayList(mainInput, testInput));
View Full Code Here

  }

  @Test
  public void countProjectDirectories() {
    DirectoriesDecorator decorator = new DirectoriesDecorator();
    Resource project = new Project("project");
    DecoratorContext context = mock(DecoratorContext.class);

    when(context.getChildrenMeasures(CoreMetrics.DIRECTORIES)).thenReturn(Arrays.<Measure>asList(
      new Measure(CoreMetrics.DIRECTORIES, 1.0),
      new Measure(CoreMetrics.DIRECTORIES, 1.0),
View Full Code Here

TOP

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

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.