Search in sources :

Example 6 with Person

use of com.tinkerpop.frames.domain.classes.Person in project frames by tinkerpop.

the class FramedGraphTest method testCreateFrame.

public void testCreateFrame() {
    Graph graph = new TinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person person = framedGraph.addVertex(null, Person.class);
    assertEquals(person.asVertex(), graph.getVertices().iterator().next());
    int counter = 0;
    for (Vertex v : graph.getVertices()) {
        counter++;
    }
    assertEquals(counter, 1);
    counter = 0;
    for (Edge e : graph.getEdges()) {
        counter++;
    }
    assertEquals(counter, 0);
    Person person2 = framedGraph.addVertex("aPerson", Person.class);
    assertEquals(person2.asVertex().getId(), "aPerson");
    counter = 0;
    for (Vertex v : graph.getVertices()) {
        counter++;
    }
    assertEquals(counter, 2);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Person(com.tinkerpop.frames.domain.classes.Person) Edge(com.tinkerpop.blueprints.Edge)

Example 7 with Person

use of com.tinkerpop.frames.domain.classes.Person in project frames by tinkerpop.

the class FramedVertexTest method testGetGremlinGroovyParameters.

@Test
public void testGetGremlinGroovyParameters() {
    Person coCreator = marko.getCoCreatorOfAge(32);
    assertEquals(josh, coCreator);
    coCreator = marko.getCoCreatorOfAge(35);
    assertEquals(peter, coCreator);
    assertEquals(marko, getOnlyElement(marko.getKnownRootedFromParam(josh)));
}
Also used : Person(com.tinkerpop.frames.domain.classes.Person) Test(org.junit.Test)

Example 8 with Person

use of com.tinkerpop.frames.domain.classes.Person in project frames by tinkerpop.

the class FramedVertexTest method testAddingTwoAdjacencies.

@Test
public void testAddingTwoAdjacencies() {
    Person person = framedGraph.addVertex(null, Person.class);
    HashSet<Person> people = newHashSet(person.addKnowsNewPerson(), person.addKnowsNewPerson());
    assertEquals(people, newHashSet(person.getKnowsPeople()));
}
Also used : Person(com.tinkerpop.frames.domain.classes.Person) Test(org.junit.Test)

Example 9 with Person

use of com.tinkerpop.frames.domain.classes.Person in project frames by tinkerpop.

the class FramedVertexTest method testAddingAdjacencies.

@Test
public void testAddingAdjacencies() {
    marko.addKnowsPerson(peter);
    Person bryn = marko.addKnowsNewPerson();
    bryn.setName("bryn");
    Knows markoKnowsBryn = framedGraph.frame(graph.getEdge(13), Knows.class);
    Knows markoKnowsPeter = framedGraph.frame(graph.getEdge(0), Knows.class);
    assertEquals(newHashSet(markoKnowsVadas, markowKnowsJosh, markoKnowsPeter, markoKnowsBryn), newHashSet(marko.getKnows()));
    marko.addCreatedProject(ripple);
    assertEquals(newHashSet(lop, ripple), newHashSet(marko.getCreatedProjects()));
}
Also used : Knows(com.tinkerpop.frames.domain.incidences.Knows) Person(com.tinkerpop.frames.domain.classes.Person) Test(org.junit.Test)

Example 10 with Person

use of com.tinkerpop.frames.domain.classes.Person in project frames by tinkerpop.

the class FramedGraphQueryImplTest method testDelegation.

@Test
public void testDelegation() {
    GraphQuery mockGraphQuery = mock(GraphQuery.class);
    FramedGraph framedGraph = new FramedGraphFactory().create(null);
    FramedGraphQueryImpl query = new FramedGraphQueryImpl(framedGraph, mockGraphQuery);
    stub(mockGraphQuery.has("")).toReturn(mockGraphQuery);
    query.has("");
    verify(mockGraphQuery).has("");
    stub(mockGraphQuery.has("", "bar")).toReturn(mockGraphQuery);
    query.has("", "bar");
    verify(mockGraphQuery).has("", "bar");
    Predicate predicate = new Predicate() {

        @Override
        public boolean evaluate(Object first, Object second) {
            return false;
        }
    };
    stub(mockGraphQuery.has("", predicate, "bar")).toReturn(mockGraphQuery);
    query.has("", predicate, "bar");
    verify(mockGraphQuery).has(eq(""), same(predicate), eq("bar"));
    stub(mockGraphQuery.has("", 2, Compare.EQUAL)).toReturn(mockGraphQuery);
    query.has("", 2, Compare.EQUAL);
    verify(mockGraphQuery).has(eq(""), same(2), eq(Compare.EQUAL));
    stub(mockGraphQuery.hasNot("")).toReturn(mockGraphQuery);
    query.hasNot("");
    verify(mockGraphQuery).hasNot(eq(""));
    stub(mockGraphQuery.hasNot("", "bar")).toReturn(mockGraphQuery);
    query.hasNot("", "bar");
    verify(mockGraphQuery).hasNot(eq(""), eq("bar"));
    stub(mockGraphQuery.interval("", "bar", "bif")).toReturn(mockGraphQuery);
    query.interval("", "bar", "bif");
    verify(mockGraphQuery).interval(eq(""), eq("bar"), eq("bif"));
    stub(mockGraphQuery.limit(1)).toReturn(mockGraphQuery);
    query.limit(1);
    verify(mockGraphQuery).limit(1);
    List<Vertex> v = new ArrayList<Vertex>();
    stub(mockGraphQuery.vertices()).toReturn(v);
    query.vertices();
    verify(mockGraphQuery).vertices();
    Iterable<Person> people = query.vertices(Person.class);
    verify(mockGraphQuery, times(2)).vertices();
    assertFalse(people.iterator().hasNext());
    List<Edge> e = new ArrayList<Edge>();
    stub(mockGraphQuery.edges()).toReturn(e);
    query.edges();
    verify(mockGraphQuery).edges();
    Iterable<Knows> knows = query.edges(Knows.class);
    verify(mockGraphQuery, times(2)).edges();
    assertFalse(knows.iterator().hasNext());
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) ArrayList(java.util.ArrayList) Predicate(com.tinkerpop.blueprints.Predicate) FramedGraph(com.tinkerpop.frames.FramedGraph) FramedGraphFactory(com.tinkerpop.frames.FramedGraphFactory) Knows(com.tinkerpop.frames.domain.incidences.Knows) GraphQuery(com.tinkerpop.blueprints.GraphQuery) Person(com.tinkerpop.frames.domain.classes.Person) Edge(com.tinkerpop.blueprints.Edge) Test(org.junit.Test)

Aggregations

Person (com.tinkerpop.frames.domain.classes.Person)25 Test (org.junit.Test)21 Graph (com.tinkerpop.blueprints.Graph)15 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)11 Vertex (com.tinkerpop.blueprints.Vertex)6 Edge (com.tinkerpop.blueprints.Edge)5 FramedGraph (com.tinkerpop.frames.FramedGraph)4 Knows (com.tinkerpop.frames.domain.incidences.Knows)4 FramedGraphFactory (com.tinkerpop.frames.FramedGraphFactory)3 Created (com.tinkerpop.frames.domain.incidences.Created)3 CreatedInfo (com.tinkerpop.frames.domain.incidences.CreatedInfo)3 TransactionalGraph (com.tinkerpop.blueprints.TransactionalGraph)2 FramedGraphConfiguration (com.tinkerpop.frames.FramedGraphConfiguration)2 Project (com.tinkerpop.frames.domain.classes.Project)2 AbstractModule (com.tinkerpop.frames.modules.AbstractModule)2 TypeResolver (com.tinkerpop.frames.modules.TypeResolver)2 HashSet (java.util.HashSet)2 GraphQuery (com.tinkerpop.blueprints.GraphQuery)1 Predicate (com.tinkerpop.blueprints.Predicate)1 CreatedBy (com.tinkerpop.frames.domain.incidences.CreatedBy)1