private void verifyEntityProperties(
     Vertex entityVertex, String entityName, RelationshipType entityType) {
   Assert.assertEquals(entityName, entityVertex.getProperty(RelationshipProperty.NAME.getName()));
   Assert.assertEquals(
       entityType.getName(), entityVertex.getProperty(RelationshipProperty.TYPE.getName()));
   Assert.assertNotNull(entityVertex.getProperty(RelationshipProperty.TIMESTAMP.getName()));
 }
  private void verifyEntityGraph(RelationshipType feedType, String classification) {
    // feeds owned by a user
    List<String> feedNamesOwnedByUser = getFeedsOwnedByAUser(feedType.getName());
    Assert.assertEquals(
        feedNamesOwnedByUser,
        Arrays.asList("impression-feed", "clicks-feed", "imp-click-join1", "imp-click-join2"));

    // feeds classified as secure
    verifyFeedsClassifiedAsSecure(
        feedType.getName(), Arrays.asList("impression-feed", "clicks-feed", "imp-click-join2"));

    // feeds owned by a user and classified as secure
    verifyFeedsOwnedByUserAndClassification(
        feedType.getName(),
        classification,
        Arrays.asList("impression-feed", "clicks-feed", "imp-click-join2"));
  }
  private Vertex getEntityVertex(String entityName, RelationshipType entityType) {
    GraphQuery entityQuery =
        getQuery()
            .has(RelationshipProperty.NAME.getName(), entityName)
            .has(RelationshipProperty.TYPE.getName(), entityType.getName());
    Iterator<Vertex> iterator = entityQuery.vertices().iterator();
    Assert.assertTrue(iterator.hasNext());

    Vertex entityVertex = iterator.next();
    Assert.assertNotNull(entityVertex);

    return entityVertex;
  }
  @Test
  public void storeProjectAndRetrieveAllRelationshipsInOneGo() throws Exception {
    final ProjectVersionRef p =
        new SimpleProjectVersionRef("org.apache.maven", "maven-core", "3.0.3");

    final EProjectDirectRelationships.Builder prb =
        new EProjectDirectRelationships.Builder(sourceUri, p);

    final ProjectVersionRef parent =
        new SimpleProjectVersionRef("org.apache.maven", "maven", "3.0.3");

    int idx = 0;
    int pidx = 0;
    final DependencyRelationship papi =
        new SimpleDependencyRelationship(
            sourceUri,
            p,
            new SimpleArtifactRef(
                "org.apache.maven", "maven-plugin-api", "3.0.3", null, null, false),
            DependencyScope.compile,
            idx++,
            false,
            false);
    final DependencyRelationship art =
        new SimpleDependencyRelationship(
            sourceUri,
            p,
            new SimpleArtifactRef("org.apache.maven", "maven-artifact", "3.0.3", null, null, false),
            DependencyScope.compile,
            idx++,
            false,
            false);
    final PluginRelationship jarp =
        new SimplePluginRelationship(
            sourceUri,
            p,
            new SimpleProjectVersionRef("org.apache.maven.plugins", "maven-jar-plugin", "2.2"),
            pidx++,
            false,
            false);
    final PluginRelationship comp =
        new SimplePluginRelationship(
            sourceUri,
            p,
            new SimpleProjectVersionRef(
                "org.apache.maven.plugins", "maven-compiler-plugin", "2.3.2"),
            pidx++,
            false,
            false);
    final ExtensionRelationship wag =
        new SimpleExtensionRelationship(
            sourceUri,
            p,
            new SimpleProjectVersionRef("org.apache.maven.wagon", "wagon-provider-webdav", "1.0"),
            0,
            false);

    prb.withParent(parent);
    prb.withDependencies(papi, art);
    prb.withPlugins(jarp, comp);
    prb.withExtensions(wag);

    final EProjectDirectRelationships rels = prb.build();

    assertThat(rels.getAllRelationships().size(), equalTo(6));

    graph.storeRelationships(rels.getExactAllRelationships());

    final Set<ProjectRelationship<?, ?>> resulting =
        graph.findDirectRelationshipsFrom(rels.getProjectRef(), false, RelationshipType.values());

    final Set<ProjectVersionRef> targets = RelationshipUtils.targets(resulting);

    assertThat(targets.size(), equalTo(6));
    assertThat(targets.contains(parent), equalTo(true));
    assertThat(targets.contains(papi.getTarget()), equalTo(true));
    assertThat(targets.contains(art.getTarget()), equalTo(true));
    assertThat(targets.contains(jarp.getTarget()), equalTo(true));
    assertThat(targets.contains(comp.getTarget()), equalTo(true));
    assertThat(targets.contains(wag.getTarget()), equalTo(true));
  }
Esempio n. 5
0
  public RelationshipType removeRelationshipTypes2(RelationshipType relationshipTypes2) {
    getRelationshipTypes2().remove(relationshipTypes2);
    relationshipTypes2.setValueListValue2(null);

    return relationshipTypes2;
  }
Esempio n. 6
0
  public RelationshipType addRelationshipTypes2(RelationshipType relationshipTypes2) {
    getRelationshipTypes2().add(relationshipTypes2);
    relationshipTypes2.setValueListValue2(this);

    return relationshipTypes2;
  }
Esempio n. 7
0
  public RelationshipType removeRelationshipTypes1(RelationshipType relationshipTypes1) {
    getRelationshipTypes1().remove(relationshipTypes1);
    relationshipTypes1.setValueListValue1(null);

    return relationshipTypes1;
  }
Esempio n. 8
0
  public RelationshipType addRelationshipTypes1(RelationshipType relationshipTypes1) {
    getRelationshipTypes1().add(relationshipTypes1);
    relationshipTypes1.setValueListValue1(this);

    return relationshipTypes1;
  }