コード例 #1
0
  @Test
  public void storeProjectWithOneExtensionAndRetrieveAsUser() throws Exception {
    final ProjectVersionRef project =
        new SimpleProjectVersionRef("org.apache.maven", "maven-core", "3.0.3");
    final ProjectVersionRef ext =
        new SimpleProjectVersionRef("org.apache.maven.wagon", "wagon-provider-webdav", "2.0");

    final EProjectDirectRelationships rels =
        new EProjectDirectRelationships.Builder(sourceUri, project)
            .withExtension(ext, false)
            .build();

    graph.storeRelationships(rels.getExactAllRelationships());

    final Set<ProjectRelationship<?, ?>> exts =
        graph.findDirectRelationshipsTo(ext, false, RelationshipType.EXTENSION);

    assertThat(exts.size(), equalTo(1));
    assertThat(exts.iterator().next().getDeclaring(), equalTo(project));
  }
コード例 #2
0
  @Test
  public void storeProjectWithOnePluginAndVerifyAnyUsageRelationship() throws Exception {
    final ProjectVersionRef project =
        new SimpleProjectVersionRef("org.apache.maven", "maven-core", "3.0.3");
    final ProjectVersionRef plugin =
        new SimpleProjectVersionRef("org.apache.maven.plugins", "maven-compiler-plugin", "2.3.2");

    final EProjectDirectRelationships rels =
        new EProjectDirectRelationships.Builder(sourceUri, project)
            .withPlugin(plugin, false, false)
            .build();

    graph.storeRelationships(rels.getExactAllRelationships());

    final Set<ProjectRelationship<?, ?>> storedRels =
        graph.findDirectRelationshipsTo(plugin, false, RelationshipType.PLUGIN);

    assertThat(storedRels.size(), equalTo(1));

    final ProjectVersionRef declaring = storedRels.iterator().next().getDeclaring();

    assertThat(declaring, equalTo(project));
  }
コード例 #3
0
  @Test
  public void storeProjectWithOneDependencyAndRetrieveAsDependent() throws Exception {
    final EProjectDirectRelationships rels =
        new EProjectDirectRelationships.Builder(
                sourceUri, new SimpleProjectVersionRef("org.apache.maven", "maven-core", "3.0.3"))
            .withDependency(
                new SimpleProjectVersionRef("org.apache.maven", "maven-artifact", "3.0.3"),
                null,
                null,
                null,
                false,
                false)
            .build();

    graph.storeRelationships(rels.getExactAllRelationships());

    final Set<ProjectRelationship<?, ?>> dependents =
        graph.findDirectRelationshipsTo(
            rels.getDependencies().get(0).getTarget(), false, RelationshipType.DEPENDENCY);

    assertThat(dependents, notNullValue());
    assertThat(dependents.size(), equalTo(1));
    assertThat(dependents.iterator().next().getDeclaring(), equalTo(rels.getProjectRef()));
  }