use of com.tinkerpop.frames.domain.incidences.CreatedBy in project frames by tinkerpop.
the class FramedVertexTest method testRemoveIncidencesDeprecated.
/**
* Uses deprecated Domain/Range annotations
*/
@Test
public void testRemoveIncidencesDeprecated() {
List<CreatedBy> toRemove2 = new ArrayList<CreatedBy>();
for (CreatedBy createdBy : lop.getCreatedBy()) {
toRemove2.add(createdBy);
}
assertEquals(3, toRemove2.size());
for (CreatedBy createdBy : toRemove2) {
lop.removeCreatedBy(createdBy);
}
assertTrue(Iterables.isEmpty(lop.getCreatedBy()));
}
use of com.tinkerpop.frames.domain.incidences.CreatedBy in project frames by tinkerpop.
the class FramedVertexTest method testAddIncidenceInDeprecated.
/**
* Use deprecated Domain/Range annotations on edge
*/
@Test
public void testAddIncidenceInDeprecated() {
Project rdfAgents = framedGraph.addVertex(null, Project.class);
CreatedBy createdBy = rdfAgents.addCreatedByPersonIncidence(marko);
assertEquals(marko, createdBy.getRange());
assertEquals(rdfAgents, createdBy.getDomain());
assertEquals(marko, getOnlyElement(rdfAgents.getCreatedByPeople()));
}
use of com.tinkerpop.frames.domain.incidences.CreatedBy 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());
}
use of com.tinkerpop.frames.domain.incidences.CreatedBy 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());
}
Aggregations