Search in sources :

Example 1 with Created

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

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

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

the class FramedVertexTest method testAddingIncidencesDeprecated.

/**
 * Uses deprecated Domain/Range annotations
 */
@Test
public void testAddingIncidencesDeprecated() {
    Created markoCreatedRipple = marko.addCreated(ripple);
    assertEquals(newHashSet(markoCreatedRipple, markoCreatedLop), newHashSet(marko.getCreated()));
    assertNull(markoCreatedRipple.getWeight());
    markoCreatedRipple.setWeight(0.0f);
    assertEquals(0.0f, markoCreatedRipple.getWeight(), 0.01f);
}
Also used : Created(com.tinkerpop.frames.domain.incidences.Created) Test(org.junit.Test)

Example 4 with Created

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

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

the class FramedEdgeTest method testGettingDomainAndRange.

@Test
public void testGettingDomainAndRange() {
    assertEquals(marko, knows.getDomain());
    assertEquals(vadas, knows.getRange());
    CreatedBy createdBy = lop.getCreatedBy().iterator().next();
    assertEquals(lop, createdBy.getDomain());
    assertTrue(createdBy.getRange().equals(marko) || createdBy.getRange().equals(peter) || createdBy.getRange().equals(josh));
    Created created = marko.getCreated().iterator().next();
    // Please note: the below results are actually incorrect: the domain and range are incorrectly tagged
    // in Created for usage with @Incidence. I'm not going to fix that in the test-cases as Domain and
    // Range are deprecated now. The incorrect annotations probable show better than anything that
    // the now deprecated annotations are quite confusing:
    // range actually returns a Person, not a Project...
    assertEquals(lop, created.getRange());
    // domain actually returns a Project, not a Person...
    assertEquals(marko, created.getDomain());
}
Also used : CreatedBy(com.tinkerpop.frames.domain.incidences.CreatedBy) Created(com.tinkerpop.frames.domain.incidences.Created) Test(org.junit.Test)

Aggregations

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