Search in sources :

Example 1 with GraphStoreFixture

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();
        }
    };
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Node(org.neo4j.graphdb.Node) Setting(org.neo4j.graphdb.config.Setting) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) KernelException(org.neo4j.exceptions.KernelException) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture)

Aggregations

GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)1 KernelException (org.neo4j.exceptions.KernelException)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Node (org.neo4j.graphdb.Node)1 Setting (org.neo4j.graphdb.config.Setting)1 TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)1