Search in sources :

Example 11 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class PropertyKeyTokenRecordCheckTest method shouldNotReportAnythingForRecordNotInUse.

@Test
public void shouldNotReportAnythingForRecordNotInUse() throws Exception {
    // given
    PropertyKeyTokenRecord key = notInUse(new PropertyKeyTokenRecord(42));
    // when
    ConsistencyReport.PropertyKeyTokenConsistencyReport report = check(key);
    // then
    verifyNoMoreInteractions(report);
}
Also used : PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 12 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class SchemaRecordCheckTest method shouldNotReportConstraintIndexRuleWithoutBackReference.

@Test
public void shouldNotReportConstraintIndexRuleWithoutBackReference() throws Exception {
    // given
    int ruleId = 1;
    DynamicRecord record = inUse(dynamicRecord(ruleId));
    SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
    IndexRule rule = constraintIndexRule(ruleId, labelId, propertyKeyId, providerDescriptor);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId)).thenReturn(rule);
    add(inUse(new LabelTokenRecord(labelId)));
    add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
    // when
    check(record);
    SchemaRecordCheck obligationChecker = checker().forObligationChecking();
    ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record);
    // then
    verifyZeroInteractions(report);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaRuleUtil.constraintIndexRule(org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 13 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class SchemaRecordCheckTest method shouldReportTwoUniquenessConstraintsReferencingSameIndex.

@Test
public void shouldReportTwoUniquenessConstraintsReferencingSameIndex() throws Exception {
    // given
    int ruleId1 = 0;
    int ruleId2 = 1;
    DynamicRecord record1 = inUse(dynamicRecord(ruleId1));
    DynamicRecord record2 = inUse(dynamicRecord(ruleId2));
    ConstraintRule rule1 = uniquenessConstraintRule(ruleId1, labelId, propertyKeyId, ruleId2);
    ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, labelId, propertyKeyId, ruleId2);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2);
    add(inUse(new LabelTokenRecord(labelId)));
    add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
    // when
    check(record1);
    ConsistencyReport.SchemaConsistencyReport report = check(record2);
    // then
    verify(report).duplicateObligation(record1);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ConstraintRule(org.neo4j.kernel.impl.store.record.ConstraintRule) SchemaRuleUtil.uniquenessConstraintRule(org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 14 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class PropertyKeyTokenRecordCheckTest method shouldReportDynamicBlockNotInUse.

@Test
public void shouldReportDynamicBlockNotInUse() throws Exception {
    // given
    PropertyKeyTokenRecord key = inUse(new PropertyKeyTokenRecord(42));
    DynamicRecord name = addKeyName(notInUse(new DynamicRecord(6)));
    key.setNameId((int) name.getId());
    // when
    ConsistencyReport.PropertyKeyTokenConsistencyReport report = check(key);
    // then
    verify(report).nameBlockNotInUse(name);
    verifyNoMoreInteractions(report);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 15 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class PropertyRecordCheckTest method shouldReportPropertyKeyNotInUse.

@Test
public void shouldReportPropertyKeyNotInUse() throws Exception {
    // given
    PropertyRecord property = inUse(new PropertyRecord(42));
    PropertyKeyTokenRecord key = add(notInUse(new PropertyKeyTokenRecord(0)));
    PropertyBlock block = propertyBlock(key, PropertyType.INT, 0);
    property.addPropertyBlock(block);
    // when
    ConsistencyReport.PropertyConsistencyReport report = check(property);
    // then
    verify(report).keyNotInUse(block, key);
    verifyNoMoreInteractions(report);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Aggregations

PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)65 Test (org.junit.Test)31 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)30 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)28 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)16 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)14 IOException (java.io.IOException)10 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)8 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)8 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)8 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)8 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)8 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)6 StorageCommand (org.neo4j.storageengine.api.StorageCommand)6 SchemaRuleUtil.uniquenessConstraintRule (org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule)5 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)5 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)5 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)5 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)4