Search in sources :

Example 1 with AbstractEdge

use of org.janusgraph.graphdb.relations.AbstractEdge in project janusgraph by JanusGraph.

the class JanusGraphTest method testUpdateEdgePropertyThenRemoveEdge.

@Test
public void testUpdateEdgePropertyThenRemoveEdge() {
    initializeGraphWithVerticesAndEdges();
    // normal edge
    AbstractEdge edge = (AbstractEdge) graph.traversal().E().has("_e", 1).next();
    assertTrue(ElementLifeCycle.isLoaded(edge.getLifeCycle()));
    Object id = edge.id();
    for (int val : Arrays.asList(-1, -11)) {
        edge.property("_e", val);
        // the edge object represents the old edge to be deleted
        assertEquals(id, edge.id());
        assertTrue(ElementLifeCycle.isRemoved(edge.getLifeCycle()));
        // the edge object has a corresponding new edge with same id
        assertEquals(id, edge.it().id());
        assertTrue(ElementLifeCycle.isNew(edge.it().getLifeCycle()));
        assertTrue(edge.isNew());
    }
    edge.remove();
    graph.tx().commit();
    assertFalse(graph.traversal().E().has("_e", 1).hasNext());
    assertFalse(graph.traversal().E().has("_e", -1).hasNext());
    assertFalse(graph.traversal().E().has("_e", -11).hasNext());
    assertTrue(graph.traversal().E().has("_e", 2).hasNext());
}
Also used : AbstractEdge(org.janusgraph.graphdb.relations.AbstractEdge) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with AbstractEdge

use of org.janusgraph.graphdb.relations.AbstractEdge in project janusgraph by JanusGraph.

the class JanusGraphTest method testUpdateForkEdgePropertyThenRemoveEdge.

@Test
public void testUpdateForkEdgePropertyThenRemoveEdge() {
    initializeGraphWithVerticesAndEdges();
    // fork edge
    AbstractEdge edge = (AbstractEdge) graph.traversal().E().has("_e", 2).next();
    assertTrue(ElementLifeCycle.isLoaded(edge.getLifeCycle()));
    Object id = edge.id();
    edge.property("_e", -2);
    // the edge object represents the old edge to be deleted
    assertEquals(id, edge.id());
    assertTrue(ElementLifeCycle.isRemoved(edge.getLifeCycle()));
    // the edge object has a corresponding new (forked) edge with different id
    Object forkedId = edge.it().id();
    assertNotEquals(id, forkedId);
    assertTrue(ElementLifeCycle.isNew(edge.it().getLifeCycle()));
    assertTrue(edge.isNew());
    edge.property("_e", -3);
    assertEquals(id, edge.id());
    assertTrue(ElementLifeCycle.isRemoved(edge.getLifeCycle()));
    assertEquals(forkedId, edge.it().id());
    assertTrue(ElementLifeCycle.isNew(edge.it().getLifeCycle()));
    assertTrue(edge.isNew());
    edge.remove();
    graph.tx().commit();
    assertFalse(graph.traversal().E().has("_e", 2).hasNext());
    assertFalse(graph.traversal().E().has("_e", -2).hasNext());
    assertFalse(graph.traversal().E().has("_e", -3).hasNext());
}
Also used : AbstractEdge(org.janusgraph.graphdb.relations.AbstractEdge) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with AbstractEdge

use of org.janusgraph.graphdb.relations.AbstractEdge in project janusgraph by JanusGraph.

the class JanusGraphTest method testUpdateForkEdgePropertyThenFindEdgeById.

@Test
public void testUpdateForkEdgePropertyThenFindEdgeById() {
    initializeGraphWithVerticesAndEdges();
    AbstractEdge edge = (AbstractEdge) graph.traversal().E().has("_e", 2).next();
    Object id = edge.id();
    edge.property("_e", -2);
    assertTrue(graph.traversal().E(id).hasNext());
}
Also used : AbstractEdge(org.janusgraph.graphdb.relations.AbstractEdge) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractEdge (org.janusgraph.graphdb.relations.AbstractEdge)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3