Search in sources :

Example 1 with Knows

use of com.tinkerpop.frames.domain.incidences.Knows in project frames by tinkerpop.

the class FramedEdgeTest method setup.

@Before
public void setup() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    framedGraph = new FramedGraphFactory().create(graph);
    marko = framedGraph.getVertex(1, Person.class);
    vadas = framedGraph.getVertex(2, Person.class);
    peter = framedGraph.getVertex(6, Person.class);
    josh = framedGraph.getVertex(4, Person.class);
    knows = framedGraph.getEdge(7, Knows.class);
    lop = framedGraph.getVertex(3, Project.class);
}
Also used : Project(com.tinkerpop.frames.domain.classes.Project) Graph(com.tinkerpop.blueprints.Graph) Knows(com.tinkerpop.frames.domain.incidences.Knows) Person(com.tinkerpop.frames.domain.classes.Person) Before(org.junit.Before)

Example 2 with Knows

use of com.tinkerpop.frames.domain.incidences.Knows in project frames by tinkerpop.

the class FramedGraphTest method testCreateFrameForNonexistantElements.

public void testCreateFrameForNonexistantElements() {
    Graph graph = new TinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person vertex = framedGraph.getVertex(-1, Person.class);
    Assert.assertNull(vertex);
    vertex = framedGraph.frame((Vertex) null, Person.class);
    Assert.assertNull(vertex);
    Knows edge = framedGraph.getEdge(-1, Knows.class);
    Assert.assertNull(edge);
    edge = framedGraph.frame((Edge) null, Knows.class);
    Assert.assertNull(edge);
}
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) Knows(com.tinkerpop.frames.domain.incidences.Knows) Person(com.tinkerpop.frames.domain.classes.Person) Edge(com.tinkerpop.blueprints.Edge)

Example 3 with Knows

use of com.tinkerpop.frames.domain.incidences.Knows in project frames by tinkerpop.

the class FramedVertexTest method testAddingIncidences.

@Test
public void testAddingIncidences() {
    CreatedInfo markoCreatedRipple = marko.addCreatedInfo(ripple);
    assertEquals(newHashSet(markoCreatedRipple, markoCreatedLop), newHashSet(marko.getCreated()));
    assertNull(markoCreatedRipple.getWeight());
    markoCreatedRipple.setWeight(0.0f);
    assertEquals(0.0f, markoCreatedRipple.getWeight(), 0.01f);
    Knows markoKnowsPeter = marko.addKnows(peter);
    assertEquals(newHashSet(markoKnowsPeter, markoKnowsVadas, markowKnowsJosh), newHashSet(marko.getKnows()));
    assertNull(markoKnowsPeter.getWeight());
    markoKnowsPeter.setWeight(1.0f);
    assertEquals(1.0f, markoKnowsPeter.getWeight(), 0.01f);
}
Also used : CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) Knows(com.tinkerpop.frames.domain.incidences.Knows) Test(org.junit.Test)

Example 4 with Knows

use of com.tinkerpop.frames.domain.incidences.Knows 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 5 with Knows

use of com.tinkerpop.frames.domain.incidences.Knows in project frames by tinkerpop.

the class FramedVertexTest method testFramingInterfaces.

@Test
public void testFramingInterfaces() {
    StandalonePerson marko = framedGraph.frame(graph.getVertex(1), StandalonePerson.class);
    assertTrue(marko instanceof VertexFrame);
    for (Knows knows : marko.getKnows()) {
        assertTrue(knows instanceof EdgeFrame);
    }
}
Also used : Knows(com.tinkerpop.frames.domain.incidences.Knows) Test(org.junit.Test)

Aggregations

Knows (com.tinkerpop.frames.domain.incidences.Knows)8 Test (org.junit.Test)6 Person (com.tinkerpop.frames.domain.classes.Person)5 Edge (com.tinkerpop.blueprints.Edge)3 Graph (com.tinkerpop.blueprints.Graph)3 Vertex (com.tinkerpop.blueprints.Vertex)3 FramedGraph (com.tinkerpop.frames.FramedGraph)2 FramedGraphFactory (com.tinkerpop.frames.FramedGraphFactory)2 GraphQuery (com.tinkerpop.blueprints.GraphQuery)1 Predicate (com.tinkerpop.blueprints.Predicate)1 TransactionalGraph (com.tinkerpop.blueprints.TransactionalGraph)1 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)1 FramedGraphConfiguration (com.tinkerpop.frames.FramedGraphConfiguration)1 Project (com.tinkerpop.frames.domain.classes.Project)1 CreatedInfo (com.tinkerpop.frames.domain.incidences.CreatedInfo)1 AbstractModule (com.tinkerpop.frames.modules.AbstractModule)1 TypeResolver (com.tinkerpop.frames.modules.TypeResolver)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1