Search in sources :

Example 11 with Person

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

the class FrameInitializerTest method testVertexInitialization.

@Test
public void testVertexInitialization() {
    Person person = framedGraph.addVertex(null, Person.class);
    assertEquals("Defaulted", person.getName());
}
Also used : Person(com.tinkerpop.frames.domain.classes.Person) Test(org.junit.Test)

Example 12 with Person

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

the class FramedVertexSetTest method testFramedSet.

public void testFramedSet() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraph<Graph>(graph);
    Set<Vertex> vertices = new HashSet<Vertex>();
    vertices.add(graph.getVertex(1));
    vertices.add(graph.getVertex(4));
    vertices.add(graph.getVertex(6));
    FramedVertexSet<Person> set = new FramedVertexSet<Person>(framedGraph, vertices, Person.class);
    assertEquals(set.size(), 3);
    assertTrue(set.contains(graph.getVertex(1)));
    assertTrue(set.contains(graph.getVertex(4)));
    assertTrue(set.contains(graph.getVertex(6)));
    assertTrue(set.contains(framedGraph.frame(graph.getVertex(1), Person.class)));
    assertTrue(set.contains(framedGraph.frame(graph.getVertex(4), Person.class)));
    assertTrue(set.contains(framedGraph.frame(graph.getVertex(6), Person.class)));
    int counter = 0;
    for (Person person : set) {
        assertTrue(person.asVertex().getId().equals("1") || person.asVertex().getId().equals("4") || person.asVertex().getId().equals("6"));
        counter++;
    }
    assertEquals(counter, 3);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) Graph(com.tinkerpop.blueprints.Graph) FramedGraph(com.tinkerpop.frames.FramedGraph) FramedGraph(com.tinkerpop.frames.FramedGraph) Person(com.tinkerpop.frames.domain.classes.Person) HashSet(java.util.HashSet)

Example 13 with Person

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

the class JavaHandlerTest method testJavaHandlerVertices.

@Test
public void testJavaHandlerVertices() {
    Person person = g.getVertex(1, Person.class);
    String profile = person.getNameAndAge();
    Assert.assertEquals("marko (29)", profile);
    Person person2 = g.getVertex(2, Person.class);
    String profile2 = person2.getNameAndAge();
    Assert.assertEquals("vadas (27)", profile2);
    Set<Person> coCreators = new HashSet<Person>();
    Iterables.addAll(coCreators, person.getCoCreatorsJava());
    Assert.assertEquals(Sets.newHashSet(g.getVertex(4), g.getVertex(6)), coCreators);
}
Also used : Person(com.tinkerpop.frames.domain.classes.Person) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 14 with Person

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

the class FramedElementTest method testRemoveProperties.

@Test
public void testRemoveProperties() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person marko = framedGraph.getVertex(1, Person.class);
    assertEquals(marko.getAge(), new Integer(29));
    marko.removeAge();
    assertNull(marko.getAge());
}
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 15 with Person

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

the class FramedElementTest method testSetPropertiesToNull.

@Test
public void testSetPropertiesToNull() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person marko = framedGraph.getVertex(1, Person.class);
    assertEquals(marko.getAge(), new Integer(29));
    marko.setAge(null);
    assertNull(marko.getAge());
}
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)

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