use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportTwoIndexRulesWithDuplicateContent.
@Test
public void shouldReportTwoIndexRulesWithDuplicateContent() throws Exception {
// given
int ruleId1 = 0;
int ruleId2 = 1;
DynamicRecord record1 = inUse(dynamicRecord(ruleId1));
DynamicRecord record2 = inUse(dynamicRecord(ruleId2));
SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, providerDescriptor, (long) ruleId1);
IndexRule rule2 = constraintIndexRule(ruleId2, labelId, propertyKeyId, providerDescriptor, (long) 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).duplicateRuleContent(record1);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportInvalidLabelReferences.
@Test
public void shouldReportInvalidLabelReferences() throws Exception {
// given
int schemaRuleId = 0;
DynamicRecord record = inUse(dynamicRecord(schemaRuleId));
SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
IndexRule rule = indexRule(schemaRuleId, labelId, propertyKeyId, providerDescriptor);
when(checker().ruleAccess.loadSingleSchemaRule(schemaRuleId)).thenReturn(rule);
LabelTokenRecord labelTokenRecord = add(notInUse(new LabelTokenRecord(labelId)));
add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
// when
ConsistencyReport.SchemaConsistencyReport report = check(record);
// then
verify(report).labelNotInUse(labelTokenRecord);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportUniquenessConstraintNotReferencingBack.
@Test
public void shouldReportUniquenessConstraintNotReferencingBack() throws Exception {
// given
int ruleId1 = 0;
int ruleId2 = 1;
DynamicRecord record1 = inUse(dynamicRecord(ruleId1));
DynamicRecord record2 = inUse(dynamicRecord(ruleId2));
SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, providerDescriptor, (long) 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);
check(record2);
SchemaRecordCheck obligationChecker = checker().forObligationChecking();
check(obligationChecker, record1);
ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record2);
// then
verify(report).uniquenessConstraintNotReferencingBack(record1);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportUnreferencedConstraintIndex.
@Test
public void shouldReportUnreferencedConstraintIndex() throws Exception {
// given
int ruleId = 0;
DynamicRecord record = inUse(dynamicRecord(ruleId));
SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
IndexRule rule = constraintIndexRule(ruleId, labelId, propertyKeyId, providerDescriptor, (long) ruleId);
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
verify(report).missingObligation(SchemaRule.Kind.UNIQUENESS_CONSTRAINT);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportInvalidConstraintBackReferences.
@Test
public void shouldReportInvalidConstraintBackReferences() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
int ruleId1 = (int) next.schema();
int ruleId2 = (int) next.schema();
int labelId = next.label();
int propertyKeyId = next.propertyKey();
DynamicRecord record1 = new DynamicRecord(ruleId1);
DynamicRecord record2 = new DynamicRecord(ruleId2);
DynamicRecord record1Before = record1.clone();
DynamicRecord record2Before = record2.clone();
IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, DESCRIPTOR, (long) ruleId2);
ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, labelId, propertyKeyId, ruleId2);
Collection<DynamicRecord> records1 = serializeRule(rule1, record1);
Collection<DynamicRecord> records2 = serializeRule(rule2, record2);
assertEquals(asList(record1), records1);
assertEquals(asList(record2), records2);
tx.nodeLabel(labelId, "label");
tx.propertyKey(propertyKeyId, "property");
tx.createSchema(asList(record1Before), records1, rule1);
tx.createSchema(asList(record2Before), records2, rule2);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.SCHEMA, 2).andThatsAllFolks();
}
Aggregations