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);
}
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();
}
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());
}
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);
}
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);
}
Aggregations