use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.
the class GraphValidationTest method testValidationOnVertices.
@Test
public void testValidationOnVertices() {
OrientGraphNoTx g1 = new OrientGraphNoTx(URL, "admin", "admin");
try {
final OrientVertexType validationTestType = g1.createVertexType("ValidationTest");
validationTestType.createEdgeProperty(Direction.OUT, "Connection").setMandatory(true);
validationTestType.createEdgeProperty(Direction.IN, "Connection").setMandatory(true);
final OrientEdgeType connectionType = g1.createEdgeType("Connection");
connectionType.createProperty("in", OType.LINK, validationTestType).setMandatory(true);
connectionType.createProperty("out", OType.LINK, validationTestType).setMandatory(true);
} finally {
g1.shutdown();
}
OrientGraph g2 = new OrientGraph(URL, "admin", "admin");
try {
OrientVertex vertex1 = g2.addTemporaryVertex("ValidationTest");
OrientVertex vertex2 = g2.addTemporaryVertex("ValidationTest");
OrientVertex vertex3 = g2.addTemporaryVertex("ValidationTest");
OrientVertex vertex4 = g2.addTemporaryVertex("ValidationTest");
vertex1.addEdge("Connection", vertex2);
vertex2.addEdge("Connection", vertex3);
vertex3.addEdge("Connection", vertex4);
vertex4.addEdge("Connection", vertex1);
g2.commit();
} finally {
g2.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.
the class GraphValidationTest method testPropertyReadOnly.
@Test(expected = OValidationException.class)
public void testPropertyReadOnly() {
OrientGraphNoTx graphNoTx = new OrientGraphNoTx(URL);
OrientVertexType testType = graphNoTx.createVertexType("Test");
OProperty prop;
prop = testType.createProperty("name", OType.STRING).setReadonly(true);
graphNoTx.shutdown();
// this one passes
Assert.assertTrue(prop.isReadonly());
OrientGraph graph = new OrientGraph(URL);
try {
OrientVertex vert1 = graph.addVertex("class:Test", "name", "Sam");
graph.commit();
// should throw an exception
vert1.setProperty("name", "Ben");
graph.commit();
// fails
Assert.assertEquals(vert1.getProperty("name"), "Sam");
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.
the class GraphValidationTest method testNoTxGraphConstraints.
@Test
public void testNoTxGraphConstraints() {
OrientGraphNoTx graphNoTx = new OrientGraphNoTx(URL);
OrientVertexType testType = graphNoTx.createVertexType("Test");
testType.createProperty("age", OType.INTEGER).setMax("3");
OrientVertex vert1 = graphNoTx.addVertex("class:Test", "age", 2);
try {
vert1.setProperty("age", 4);
} catch (OValidationException e) {
// this fails
Assert.assertEquals(vert1.getProperty("age"), 2);
} finally {
graphNoTx.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.
the class GraphValidationTest method setupSchema.
private void setupSchema() {
OrientGraphNoTx graphNoTx = new OrientGraphNoTx(URL, "admin", "admin");
try {
ODatabaseDocumentTx database = graphNoTx.getRawGraph();
OSchema oScchema = database.getMetadata().getSchema();
oScchema.getClass("V").setStrictMode(true);
oScchema.getClass("E").setStrictMode(true);
OrientVertexType CmVertexBaseType = graphNoTx.createVertexType("CmVertexBase", "V");
CmVertexBaseType.setStrictMode(true);
OrientVertexType CmEdgeBaseType = graphNoTx.createVertexType("CmEdgeBase", "V");
CmEdgeBaseType.setStrictMode(true);
OClass mOClass = database.getMetadata().getSchema().createClass("M", database.getMetadata().getSchema().getClass("V"));
mOClass.createProperty("name", OType.STRING).setMandatory(true).setNotNull(true);
mOClass.setStrictMode(true);
graphNoTx.commit();
} finally {
graphNoTx.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.
the class TestGraphRecovering method testRecoverPerfectGraphLW.
@Test
public void testRecoverPerfectGraphLW() {
final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverPerfectGraphLW");
try {
init(g, true);
final TestListener eventListener = new TestListener();
new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
Assert.assertEquals(eventListener.scannedEdges, 0);
Assert.assertEquals(eventListener.removedEdges, 0);
Assert.assertEquals(eventListener.scannedVertices, 3);
Assert.assertEquals(eventListener.scannedLinks, 6);
Assert.assertEquals(eventListener.removedLinks, 0);
Assert.assertEquals(eventListener.repairedVertices, 0);
} finally {
g.shutdown();
}
}
Aggregations