use of org.neo4j.internal.kernel.api.TokenWrite 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();
}
};
}
use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.
the class SchemaComplianceCheckerTest method initialData.
@Override
void initialData(KernelTransaction tx) throws KernelException {
TokenWrite tokenWrite = tx.tokenWrite();
propertyKey1 = tokenWrite.propertyKeyGetOrCreateForName("1");
propertyKey2 = tokenWrite.propertyKeyGetOrCreateForName("2");
propertyKey3 = tokenWrite.propertyKeyGetOrCreateForName("3");
label1 = tokenWrite.labelGetOrCreateForName("A");
label2 = tokenWrite.labelGetOrCreateForName("B");
label3 = tokenWrite.labelGetOrCreateForName("C");
}
use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.
the class BuiltInProceduresIT method listPropertyKeys.
@Test
void listPropertyKeys() throws Throwable {
// Given
TokenWrite ops = tokenWriteInNewTransaction();
ops.propertyKeyGetOrCreateForName("MyProp");
commit();
// When
RawIterator<AnyValue[], ProcedureException> stream = procs().procedureCallRead(procs().procedureGet(procedureName("db", "propertyKeys")).id(), new AnyValue[0], ProcedureCallContext.EMPTY);
// Then
assertThat(asList(stream)).containsExactly(new AnyValue[] { stringValue("MyProp") });
}
use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.
the class KernelIT method createIndex.
private static IndexDescriptor createIndex(KernelTransaction transaction) throws KernelException {
TokenWrite tokenWrite = transaction.tokenWrite();
SchemaWrite schemaWrite = transaction.schemaWrite();
LabelSchemaDescriptor schema = forLabel(tokenWrite.labelGetOrCreateForName("hello"), tokenWrite.propertyKeyGetOrCreateForName("hepp"));
return schemaWrite.indexCreate(schema, null);
}
use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.
the class SystemBuiltInProceduresIT method listConstraints.
@Test
void listConstraints() throws Throwable {
// Given
KernelTransaction transaction = newTransaction(AUTH_DISABLED);
TokenWrite tokenWrite = transaction.tokenWrite();
int labelId = tokenWrite.labelGetOrCreateForName("Label");
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
SchemaWrite schemaWrite = transaction.schemaWrite();
schemaWrite.uniquePropertyConstraintCreate(uniqueForSchema(forLabel(labelId, propId)).withName("my_constraint"));
commit();
try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
// When & Then
assertFalse(tx.execute("CALL db.constraints").hasNext());
}
}
Aggregations