Search in sources :

Example 1 with CreatedInfo

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

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

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

the class FramedVertexTest method testAddingIncidences.

@Test
public void testAddingIncidences() {
    CreatedInfo markoCreatedRipple = marko.addCreatedInfo(ripple);
    assertEquals(newHashSet(markoCreatedRipple, markoCreatedLop), newHashSet(marko.getCreated()));
    assertNull(markoCreatedRipple.getWeight());
    markoCreatedRipple.setWeight(0.0f);
    assertEquals(0.0f, markoCreatedRipple.getWeight(), 0.01f);
    Knows markoKnowsPeter = marko.addKnows(peter);
    assertEquals(newHashSet(markoKnowsPeter, markoKnowsVadas, markowKnowsJosh), newHashSet(marko.getKnows()));
    assertNull(markoKnowsPeter.getWeight());
    markoKnowsPeter.setWeight(1.0f);
    assertEquals(1.0f, markoKnowsPeter.getWeight(), 0.01f);
}
Also used : CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) Knows(com.tinkerpop.frames.domain.incidences.Knows) Test(org.junit.Test)

Example 4 with CreatedInfo

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

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

the class FramedEdgeTest method testGettingOutAndIn.

@Test
public void testGettingOutAndIn() {
    assertEquals(marko, knows.getOut());
    assertEquals(vadas, knows.getIn());
    CreatedInfo created = lop.getCreatedInfo().iterator().next();
    assertEquals(lop, created.getProject());
    assertTrue(created.getPerson().equals(marko) || created.getPerson().equals(peter) || created.getPerson().equals(josh));
    created = marko.getCreatedInfo().iterator().next();
    assertEquals(lop, created.getProject());
    assertEquals(marko, created.getPerson());
}
Also used : CreatedInfo(com.tinkerpop.frames.domain.incidences.CreatedInfo) 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