Search in sources :

Example 26 with ConstraintDescriptor

use of org.neo4j.internal.schema.ConstraintDescriptor in project neo4j by neo4j.

the class FullCheckIntegrationTest method createRelationshipPropertyExistenceConstraint.

private void createRelationshipPropertyExistenceConstraint(int relTypeId, int propertyKeyId) throws KernelException {
    SchemaStore schemaStore = fixture.directStoreAccess().nativeStores().getSchemaStore();
    ConstraintDescriptor rule = relPropertyExistenceConstraintRule(schemaStore.nextId(NULL), relTypeId, propertyKeyId);
    writeToSchemaStore(schemaStore, rule);
}
Also used : SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor)

Example 27 with ConstraintDescriptor

use of org.neo4j.internal.schema.ConstraintDescriptor in project neo4j by neo4j.

the class FullCheckIntegrationTest method createUniquenessConstraintRule.

private void createUniquenessConstraintRule(final int labelId, final int... propertyKeyIds) throws KernelException {
    SchemaStore schemaStore = fixture.directStoreAccess().nativeStores().getSchemaStore();
    long ruleId1 = schemaStore.nextId(NULL);
    long ruleId2 = schemaStore.nextId(NULL);
    String name = "constraint_" + ruleId2;
    IndexDescriptor indexRule = uniqueForSchema(forLabel(labelId, propertyKeyIds), DESCRIPTOR).withName(name).materialise(ruleId1).withOwningConstraintId(ruleId2);
    ConstraintDescriptor uniqueRule = ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKeyIds).withId(ruleId2).withName(name).withOwnedIndexId(ruleId1);
    writeToSchemaStore(schemaStore, indexRule);
    writeToSchemaStore(schemaStore, uniqueRule);
}
Also used : SchemaStore(org.neo4j.kernel.impl.store.SchemaStore) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 28 with ConstraintDescriptor

use of org.neo4j.internal.schema.ConstraintDescriptor in project neo4j by neo4j.

the class ConstraintDescriptorFactoryTest method shouldCreateUniqueConstraintDescriptors.

@Test
void shouldCreateUniqueConstraintDescriptors() {
    ConstraintDescriptor desc;
    desc = ConstraintDescriptorFactory.uniqueForLabel(LABEL_ID, 1);
    assertThat(desc.type()).isEqualTo(ConstraintType.UNIQUE);
    assertThat(desc.schema()).isEqualTo(SchemaDescriptor.forLabel(LABEL_ID, 1));
}
Also used : ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) Test(org.junit.jupiter.api.Test)

Example 29 with ConstraintDescriptor

use of org.neo4j.internal.schema.ConstraintDescriptor in project neo4j by neo4j.

the class ConstraintDescriptorFactoryTest method shouldCreateEqualDescriptors.

@Test
void shouldCreateEqualDescriptors() {
    ConstraintDescriptor desc1;
    ConstraintDescriptor desc2;
    desc1 = ConstraintDescriptorFactory.uniqueForLabel(LABEL_ID, 1);
    desc2 = ConstraintDescriptorFactory.uniqueForLabel(LABEL_ID, 1);
    assertEquality(desc1, desc2);
    desc1 = ConstraintDescriptorFactory.existsForLabel(LABEL_ID, 1);
    desc2 = ConstraintDescriptorFactory.existsForLabel(LABEL_ID, 1);
    assertEquality(desc1, desc2);
    desc1 = ConstraintDescriptorFactory.existsForRelType(LABEL_ID, 1);
    desc2 = ConstraintDescriptorFactory.existsForRelType(LABEL_ID, 1);
    assertEquality(desc1, desc2);
}
Also used : ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) Test(org.junit.jupiter.api.Test)

Example 30 with ConstraintDescriptor

use of org.neo4j.internal.schema.ConstraintDescriptor in project neo4j by neo4j.

the class ConstraintDescriptorFactoryTest method shouldCreateExistsConstraintDescriptors.

@Test
void shouldCreateExistsConstraintDescriptors() {
    ConstraintDescriptor desc;
    desc = ConstraintDescriptorFactory.existsForLabel(LABEL_ID, 1);
    assertThat(desc.type()).isEqualTo(ConstraintType.EXISTS);
    assertThat(desc.schema()).isEqualTo(SchemaDescriptor.forLabel(LABEL_ID, 1));
    desc = ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, 1);
    assertThat(desc.type()).isEqualTo(ConstraintType.EXISTS);
    assertThat(desc.schema()).isEqualTo(SchemaDescriptor.forRelType(REL_TYPE_ID, 1));
}
Also used : ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)107 Test (org.junit.jupiter.api.Test)62 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)34 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)32 UniquenessConstraintDescriptor (org.neo4j.internal.schema.constraints.UniquenessConstraintDescriptor)26 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)21 NodeKeyConstraintDescriptor (org.neo4j.internal.schema.constraints.NodeKeyConstraintDescriptor)20 IndexBackedConstraintDescriptor (org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor)19 SchemaReadCore (org.neo4j.internal.kernel.api.SchemaReadCore)16 TokenRead (org.neo4j.internal.kernel.api.TokenRead)9 ArrayList (java.util.ArrayList)8 RepeatedTest (org.junit.jupiter.api.RepeatedTest)6 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)6 SchemaStore (org.neo4j.kernel.impl.store.SchemaStore)6 InternalIndexState (org.neo4j.internal.kernel.api.InternalIndexState)5 SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)5 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)5 SchemaRule (org.neo4j.internal.schema.SchemaRule)5 SchemaRecord (org.neo4j.kernel.impl.store.record.SchemaRecord)5 OptionalLong (java.util.OptionalLong)4