Search in sources :

Example 1 with Person

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

the class FramedElementTest method testSettingProperties.

@Test
public void testSettingProperties() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person marko = framedGraph.getVertex(1, Person.class);
    assertEquals(marko.getName(), "marko");
    marko.setName("pavel");
    assertEquals(marko.getName(), "pavel");
    assertEquals(marko.getAge(), new Integer(29));
    marko.setAge(31);
    assertEquals(marko.getAge(), new Integer(31));
    CreatedInfo markoCreatedLopInfo = framedGraph.getEdge(9, CreatedInfo.class);
    assertEquals(markoCreatedLopInfo.getWeight(), 0.4f, 0.1f);
    markoCreatedLopInfo.setWeight(99.0f);
    assertEquals(markoCreatedLopInfo.getWeight(), 99.0f, 0.1f);
    markoCreatedLopInfo.setWeight(0.4f);
    // Same with deprecated Domain/Range annotations:
    Created markoCreatedLop = framedGraph.getEdge(9, Direction.OUT, Created.class);
    assertEquals(markoCreatedLop.getWeight(), 0.4f, 0.1f);
    markoCreatedLop.setWeight(99.0f);
    assertEquals(markoCreatedLop.getWeight(), 99.0f, 0.1f);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) Person(com.tinkerpop.frames.domain.classes.Person) Created(com.tinkerpop.frames.domain.incidences.Created) Test(org.junit.Test)

Example 2 with Person

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

the class FramedElementTest method testUnhandledMethodNoAnnotation.

@Test(expected = UnhandledMethodException.class)
public void testUnhandledMethodNoAnnotation() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person marko = framedGraph.getVertex(1, Person.class);
    marko.unhandledNoAnnotation();
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) Person(com.tinkerpop.frames.domain.classes.Person) Test(org.junit.Test)

Example 3 with Person

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

the class FramedElementTest method testToString.

@Test
public void testToString() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person marko = framedGraph.getVertex(1, Person.class);
    assertEquals("v[1]", marko.toString());
    CreatedInfo markoCreatedLopInfo = framedGraph.getEdge(9, CreatedInfo.class);
    assertEquals("e[9][1-created->3]", markoCreatedLopInfo.toString());
    // Using deprecated Domain/Range annotations:
    Created markoCreatedLop = framedGraph.getEdge(9, Direction.OUT, Created.class);
    assertEquals("e[9][1-created->3]", markoCreatedLop.toString());
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) Person(com.tinkerpop.frames.domain.classes.Person) Created(com.tinkerpop.frames.domain.incidences.Created) Test(org.junit.Test)

Example 4 with Person

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

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

the class FramedGraphTest method testFrameVertices.

public void testFrameVertices() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    int counter = 0;
    for (Person person : framedGraph.getVertices("name", "marko", Person.class)) {
        counter++;
        assertEquals(person.getName(), "marko");
    }
    assertEquals(counter, 1);
    counter = 0;
    for (Project project : framedGraph.frameVertices(graph.getVertices("lang", "java"), Project.class)) {
        counter++;
        assertTrue(project.getName().equals("lop") || project.getName().equals("ripple"));
    }
    assertEquals(counter, 2);
}
Also used : Project(com.tinkerpop.frames.domain.classes.Project) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) Person(com.tinkerpop.frames.domain.classes.Person)

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