Package org.sonar.api.resources

Examples of org.sonar.api.resources.Library


    assertThat(ComponentKeys.createEffectiveKey(project, project)).isEqualTo("my_project");

    Directory dir = Directory.create("src/org/foo", "org/foo");
    assertThat(ComponentKeys.createEffectiveKey(project, dir)).isEqualTo("my_project:src/org/foo");

    Library library = new Library("junit:junit", "4.7");
    assertThat(ComponentKeys.createEffectiveKey(project, library)).isEqualTo("junit:junit");

    InputFile file = new DefaultInputFile("foo", "foo/Bar.php");
    assertThat(ComponentKeys.createEffectiveKey("my_project", file)).isEqualTo("my_project:foo/Bar.php");
  }
View Full Code Here


  private Resource toResource(InputDependency dependency, SensorContext context) {
    Project project = new Project(dependency.key());
    Resource result = context.getResource(project);
    if (result == null || !((Project) result).getAnalysisVersion().equals(dependency.version())) {
      Library lib = new Library(project.getKey(), dependency.version());
      context.saveResource(lib);
      result = context.getResource(lib);
    }
    return result;
  }
View Full Code Here

  protected static Resource toResource(final Project project, Artifact artifact, SensorContext context) {
    Project depWithBranch = Project.createFromMavenIds(artifact.getGroupId(), artifact.getArtifactId(), project.getBranch());
    Resource result = context.getResource(depWithBranch);
    if (result == null || !((Project) result).getAnalysisVersion().equals(artifact.getBaseVersion())) {
      Library lib = Library.createFromMavenIds(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion());
      context.saveResource(lib);
      result = context.getResource(lib);
    }
    return result;
  }
View Full Code Here

    assertThat(index.getParent(fileRef)).isInstanceOf(Directory.class);
  }

  @Test
  public void shouldIndexLibraryOutsideProjectTree() {
    Library lib = new Library("junit", "4.8");
    assertThat(index.index(lib)).isTrue();

    Library reference = new Library("junit", "4.8");
    assertThat(index.getResource(reference).getQualifier()).isEqualTo(Qualifiers.LIBRARY);
    assertThat(index.isIndexed(reference, true)).isTrue();
    assertThat(index.isExcluded(reference)).isFalse();
  }
View Full Code Here

    index.setCurrentProject(moduleB1, null);
    index.index(file);

    // Emulate another project having library dependency on moduleA
    index.addResource(new Library(moduleA.getKey(), "1.0"));

    checkTables("shouldSaveNewMultiModulesProjectAndLibrary",
      new String[] {"build_date", "created_at", "authorization_updated_at", "uuid", "project_uuid", "module_uuid", "module_uuid_path"}, "projects", "snapshots");

    // Need to enable snapshot to make resource visible using ComponentMapper
View Full Code Here

          + "{\"k\":\"oro:oro\",\"v\":\"2.0.8\",\"s\":\"compile\",\"d\":[]}]");

    Project project = new Project("foo");
    sensor.analyse(project, sensorContext);

    Library antlr = new Library("antlr:antlr", "2.7.2");
    verify(sensorContext).saveResource(eq(antlr));
    Library commonsFU = new Library("commons-fileupload:commons-fileupload", "1.1.1");
    verify(sensorContext).saveResource(eq(commonsFU));
    Library commonsIo = new Library("commons-io:commons-io", "1.1");
    verify(sensorContext).saveResource(eq(commonsIo));
    Library junit = new Library("junit:junit", "3.8.1");
    verify(sensorContext).saveResource(eq(junit));

    verify(sensorContext).saveDependency(new Dependency(project, antlr).setUsage("compile").setWeight(1));
    verify(sensorContext).saveDependency(new Dependency(commonsFU, commonsIo).setUsage("compile").setWeight(1));
    verify(sensorContext).saveDependency(new Dependency(project, junit).setUsage("test").setWeight(1));
View Full Code Here

  public void shouldSaveNewLibrary() {
    setupData("shared");

    ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), snapshotCache, resourceCache);
    persister.saveProject(singleProject, null);
    persister.saveResource(singleProject, new Library("junit:junit", "4.8.2").setEffectiveKey("junit:junit"));
    persister.saveResource(singleProject, new Library("junit:junit", "4.8.2").setEffectiveKey("junit:junit"));// do nothing, already saved
    persister.saveResource(singleProject, new Library("junit:junit", "3.2").setEffectiveKey("junit:junit"));

    checkTables("shouldSaveNewLibrary", new String[] {"build_date", "created_at", "authorization_updated_at", "uuid", "project_uuid", "module_uuid", "module_uuid_path"},
      "projects", "snapshots");

    // Need to enable snapshot to make resource visible using ComponentMapper
View Full Code Here

TOP

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

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.