@Test
  public void vertexIndexLookupWithValue() {
    OrientGraph graph = newGraph();
    createVertexIndexLabel1(graph);
    String value = "value1";

    // verify index created
    Assert.assertEquals(
        graph.getIndexedKeys(Vertex.class, label1), new HashSet<>(Collections.singletonList(key)));
    Assert.assertEquals(
        graph.getIndexedKeys(Vertex.class, label2), new HashSet<>(Collections.emptyList()));
    Assert.assertEquals(
        graph.getIndexedKeys(Edge.class, label1), new HashSet<>(Collections.emptyList()));

    Vertex v1 = graph.addVertex(T.label, label1, key, value);
    Vertex v2 = graph.addVertex(T.label, label2, key, value);

    // looking deep into the internals here - I can't find a nicer way to
    // auto verify that an index is actually used
    GraphTraversal<Vertex, Vertex> traversal =
        graph.traversal().V().has(T.label, P.eq(label1)).has(key, P.eq(value));
    OrientGraphStepStrategy.instance().apply(traversal.asAdmin());

    OrientGraphStep orientGraphStep = (OrientGraphStep) traversal.asAdmin().getStartStep();
    OrientIndexQuery orientIndexQuery = (OrientIndexQuery) orientGraphStep.findIndex().get();

    OIndex index = orientIndexQuery.index;
    Assert.assertEquals(1, index.getSize());
    Assert.assertEquals(v1.id(), index.get(value));
  }
  @Test
  public void vertexUniqueConstraint() {
    OrientGraph graph = newGraph();
    createVertexIndexLabel1(graph);
    String value = "value1";

    graph.addVertex(T.label, label1, key, value);
    graph.addVertex(T.label, label2, key, value);

    // no duplicates allowed for vertex with label1
    try {
      graph.addVertex(T.label, label1, key, value);
      Assert.fail("must throw duplicate key here!");
    } catch (ORecordDuplicatedException e) {
      // ok
    }

    // allow duplicate for vertex with label2
    graph.addVertex(T.label, label2, key, value);
  }
  // TODO: fix
  @Test
  public void indexCollation() {
    OrientGraph graph = newGraph();

    String label = "VC1";
    String key = "name";
    String value = "bob";

    Configuration config = new BaseConfiguration();
    config.setProperty("type", "UNIQUE");
    config.setProperty("keytype", OType.STRING);
    config.setProperty("collate", "ci");
    graph.createVertexIndex(key, label, config);

    graph.addVertex(T.label, label, key, value);
    // TODO: test with a "has" traversal, if/when that supports a case insensitive match predicate
    //        OrientIndexQuery indexRef = new OrientIndexQuery(true, Optional.of(label), key,
    // value.toUpperCase());
    //        Iterator<OrientVertex> result = graph.getIndexedVertices(indexRef).iterator();
    //        Assert.assertEquals(result.hasNext(), true);
  }