g.drop();
}
@Test
public void indexes() {
OrientGraph g = new OrientGraph(URL, "admin", "admin");
try {
if (g.getVertexType("VC1") == null) {
g.createVertexType("VC1");
}
} finally {
g.shutdown();
}
g = new OrientGraph(URL, "admin", "admin");
try {
// System.out.println(g.getIndexedKeys(Vertex.class,true)); this will print VC1.p1
if (g.getIndex("VC1.p1", Vertex.class) == null) {// this will return null. I do not know why
g.createKeyIndex("p1", Vertex.class, new Parameter<String, String>("class", "VC1"), new Parameter<String, String>("type",
"UNIQUE"), new Parameter<String, OType>("keytype", OType.STRING));
}
} catch (OIndexException e) {
// ignore because the index may exist
} finally {
g.shutdown();
}
g = new OrientGraph(URL, "admin", "admin");
String val1 = System.currentTimeMillis() + "";
try {
Vertex v = g.addVertex("class:VC1");
v.setProperty("p1", val1);
} finally {
g.shutdown();
}
g = new OrientGraph(URL, "admin", "admin");
try {
Vertex v = g.addVertex("class:VC1");
v.setProperty("p1", val1);
} finally {
try {
g.shutdown();
fail("must throw duplicate key here!");
} catch (ORecordDuplicatedException e) {
// ok
}