org.umlg.sqlg.test.index.TestIndexTopologyTraversal Maven / Gradle / Ivy
package org.umlg.sqlg.test.index;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Test;
import org.umlg.sqlg.structure.*;
import org.umlg.sqlg.structure.topology.*;
import org.umlg.sqlg.test.BaseTest;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
/**
* Date: 2016/11/26
* Time: 11:01 PM
*/
public class TestIndexTopologyTraversal extends BaseTest {
@Test
public void testIndexTopologyTraversal() {
Schema schemaA = this.sqlgGraph.getTopology().ensureSchemaExist("A");
VertexLabel aVertexLabel = schemaA.ensureVertexLabelExist("A");
VertexLabel bVertexLabel = schemaA.ensureVertexLabelExist("B");
Map properties = new HashMap<>();
properties.put("name", PropertyType.STRING);
EdgeLabel edgeLabel = this.sqlgGraph.getTopology().ensureEdgeLabelExist("ab", aVertexLabel, bVertexLabel, properties);
edgeLabel.ensureIndexExists(IndexType.UNIQUE, Collections.singletonList(edgeLabel.getProperty("name").get()));
this.sqlgGraph.tx().commit();
List indexes = this.sqlgGraph.topology().V().hasLabel("sqlg_schema.index").toList();
assertEquals(1, indexes.size());
List indexProperties = this.sqlgGraph.topology().V()
.hasLabel("sqlg_schema.schema").has("name", "A")
.out(Topology.SQLG_SCHEMA_SCHEMA_VERTEX_EDGE)
.out(Topology.SQLG_SCHEMA_OUT_EDGES_EDGE)
.out(Topology.SQLG_SCHEMA_EDGE_INDEX_EDGE)
.out(Topology.SQLG_SCHEMA_INDEX_PROPERTY_EDGE)
.toList();
assertEquals(1, indexProperties.size());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy