Search in sources :

Example 1 with Project

use of com.tinkerpop.frames.domain.classes.Project 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)

Example 2 with Project

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

the class FramedVertexTest method testAddAdjacencyIn.

@Test
public void testAddAdjacencyIn() {
    Project rdfAgents = framedGraph.addVertex(null, Project.class);
    rdfAgents.addCreatedByPersonAdjacency(marko);
    assertEquals(marko, getOnlyElement(rdfAgents.getCreatedByPeople()));
}
Also used : Project(com.tinkerpop.frames.domain.classes.Project) Test(org.junit.Test)

Example 3 with Project

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

the class FramedVertexTest method testAddIncidenceIn.

@Test
public void testAddIncidenceIn() {
    Project rdfAgents = framedGraph.addVertex(null, Project.class);
    CreatedInfo createdInfo = rdfAgents.addCreatedByPersonInfo(marko);
    assertEquals(marko, createdInfo.getPerson());
    assertEquals(rdfAgents, createdInfo.getProject());
    assertEquals(marko, getOnlyElement(rdfAgents.getCreatedByPeople()));
}
Also used : Project(com.tinkerpop.frames.domain.classes.Project) CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) Test(org.junit.Test)

Example 4 with Project

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

the class JavaHandlerTest method testJavaHandlerClassAnnotation.

@Test
public void testJavaHandlerClassAnnotation() {
    Project project = g.getVertex(5, Project.class);
    Assert.assertEquals("java", project.getLanguageUsingMixin());
}
Also used : Project(com.tinkerpop.frames.domain.classes.Project) Test(org.junit.Test)

Example 5 with Project

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

the class FramedElementTest method testGettingProperties.

@Test
public void testGettingProperties() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
    Person marko = framedGraph.getVertex(1, Person.class);
    assertEquals(marko.getName(), "marko");
    assertEquals(marko.getAge(), new Integer(29));
    Project lop = framedGraph.getVertex(3, Project.class);
    assertEquals(lop.getName(), "lop");
    assertEquals(lop.getLanguage(), "java");
    CreatedInfo markoCreatedLopInfo = framedGraph.getEdge(9, CreatedInfo.class);
    assertEquals(markoCreatedLopInfo.getWeight(), 0.4f, 0.1f);
    // Same with using deprecated Domain/Range annotations:
    Created markoCreatedLop = framedGraph.getEdge(9, Direction.OUT, Created.class);
    assertEquals(markoCreatedLop.getWeight(), 0.4f, 0.1f);
    CreatedBy lopCreatedByMarko = framedGraph.getEdge(9, Direction.IN, CreatedBy.class);
    assertEquals(lopCreatedByMarko.getWeight(), 0.4f, 0.1f);
    Person temp = framedGraph.frame(graph.addVertex(null), Person.class);
    assertNull(temp.getName());
    assertNull(temp.getAge());
}
Also used : Project(com.tinkerpop.frames.domain.classes.Project) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) CreatedBy(com.tinkerpop.frames.domain.incidences.CreatedBy) 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)

Aggregations

Project (com.tinkerpop.frames.domain.classes.Project)8 Test (org.junit.Test)7 Graph (com.tinkerpop.blueprints.Graph)2 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)2 Person (com.tinkerpop.frames.domain.classes.Person)2 CreatedBy (com.tinkerpop.frames.domain.incidences.CreatedBy)2 CreatedInfo (com.tinkerpop.frames.domain.incidences.CreatedInfo)2 Created (com.tinkerpop.frames.domain.incidences.Created)1