use of org.neo4j.consistency.checking.GraphStoreFixture in project neo4j by neo4j.
the class FullCheckIntegrationTest method createFixture.
private GraphStoreFixture createFixture() {
return new GraphStoreFixture(getRecordFormatName(), testDirectory) {
@Override
protected void generateInitialData(GraphDatabaseService db) {
// because many tests rely on sort order for those token ids.
try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
TokenWrite tokenWrite = ktx.tokenWrite();
label1 = tokenWrite.labelGetOrCreateForName("label1");
label2 = tokenWrite.labelGetOrCreateForName("label2");
label3 = tokenWrite.labelGetOrCreateForName("label3");
tokenWrite.labelGetOrCreateForName("label4");
draconian = tokenWrite.labelGetOrCreateForName("draconian");
key1 = tokenWrite.propertyKeyGetOrCreateForName(PROP1);
mandatory = tokenWrite.propertyKeyGetOrCreateForName("mandatory");
C = tokenWrite.relationshipTypeGetOrCreateForName("C");
T = tokenWrite.relationshipTypeGetOrCreateForName("T");
M = tokenWrite.relationshipTypeGetOrCreateForName("M");
tx.commit();
} catch (KernelException e) {
throw new RuntimeException(e);
}
// Create indexes
try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
tx.schema().indexFor(label("label3")).on(PROP1).create();
tx.schema().indexFor(label("label3")).on(PROP1).on(PROP2).create();
tx.schema().constraintFor(label("label4")).assertPropertyIsUnique(PROP1).create();
tx.commit();
}
try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
}
// Create initial data
try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
Node node1 = set(tx.createNode(label("label1")));
Node node2 = set(tx.createNode(label("label2")), property(PROP1, VALUE1));
node1.createRelationshipTo(node2, withName("C"));
// Just to create one more rel type
tx.createNode().createRelationshipTo(tx.createNode(), withName("T"));
indexedNodes.add(set(tx.createNode(label("label3")), property(PROP1, VALUE1)).getId());
indexedNodes.add(set(tx.createNode(label("label3")), property(PROP1, VALUE1), property(PROP2, VALUE2)).getId());
set(tx.createNode(label("label4")), property(PROP1, VALUE1));
tx.commit();
}
}
@Override
protected Map<Setting<?>, Object> getConfig() {
return getSettings();
}
};
}
Aggregations