Search in sources :

Example 6 with CreatedInfo

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

Example 7 with CreatedInfo

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

the class FramedVertexTest method testRemoveIncidences.

@Test
public void testRemoveIncidences() {
    assertEquals(newHashSet(markoKnowsVadas, markowKnowsJosh), newHashSet(marko.getKnows()));
    marko.removeKnows(markowKnowsJosh);
    assertEquals(markoKnowsVadas, getOnlyElement(marko.getKnows()));
    HashSet<CreatedInfo> toRemove = newHashSet(joshCreatedLop, markoCreatedLop, peterCreatedLop);
    assertEquals(toRemove, newHashSet(lop.getCreatedInfo()));
    for (CreatedInfo createdBy : toRemove) {
        lop.removeCreatedInfo(createdBy);
    }
    assertTrue(Iterables.isEmpty(lop.getCreatedInfo()));
}
Also used : CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) Test(org.junit.Test)

Example 8 with CreatedInfo

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

the class FramedVertexTest method testGettingIncidences.

@Test
public void testGettingIncidences() {
    final CreatedInfo created = getOnlyElement(marko.getCreatedInfo());
    assertEquals("lop", created.getProject().getName());
    assertEquals(0.4f, created.getWeight(), 0.01f);
    assertEquals(newHashSet(markowKnowsJosh, markoKnowsVadas), newHashSet(marko.getKnows()));
    assertEquals(joshCreatedRipple, getOnlyElement(ripple.getCreatedInfo()));
}
Also used : CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) Test(org.junit.Test)

Example 9 with CreatedInfo

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

the class FramedEdgeTest method testEquality.

@Test
public void testEquality() {
    // Deprecated Domain/Range:
    Created created = marko.getCreated().iterator().next();
    WeightedEdge weightedEdge = framedGraph.frame(created.asEdge(), Direction.OUT, WeightedEdge.class);
    assertEquals(created, weightedEdge);
    // Initial/Terminal:
    CreatedInfo createdInfo = marko.getCreatedInfo().iterator().next();
    assertEquals(createdInfo, weightedEdge);
}
Also used : CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) WeightedEdge(com.tinkerpop.frames.domain.incidences.WeightedEdge) Created(com.tinkerpop.frames.domain.incidences.Created) Test(org.junit.Test)

Aggregations

CreatedInfo (com.tinkerpop.frames.domain.incidences.CreatedInfo)9 Test (org.junit.Test)9 Created (com.tinkerpop.frames.domain.incidences.Created)4 Graph (com.tinkerpop.blueprints.Graph)3 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)3 Person (com.tinkerpop.frames.domain.classes.Person)3 Project (com.tinkerpop.frames.domain.classes.Project)2 CreatedBy (com.tinkerpop.frames.domain.incidences.CreatedBy)1 Knows (com.tinkerpop.frames.domain.incidences.Knows)1 WeightedEdge (com.tinkerpop.frames.domain.incidences.WeightedEdge)1