use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaRecordCheckTest method shouldReportConstraintIndexNotReferencingBack.
@Test
public void shouldReportConstraintIndexNotReferencingBack() 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);
ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, labelId, propertyKeyId, ruleId1);
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();
ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record1);
check(obligationChecker, record2);
// then
verify(report).constraintIndexRuleNotReferencingBack(record2);
}
use of org.neo4j.kernel.impl.store.record.IndexRule 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);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaStorageTest method shouldReturnIndexRuleForLabelAndVeryManyPropertiesComposite.
@Test
public void shouldReturnIndexRuleForLabelAndVeryManyPropertiesComposite() throws Exception {
String[] props = "abcdefghijklmnopqrstuvwxyzABCDEFGHJILKMNOPQRSTUVWXYZ".split("\\B");
createSchema(db -> {
IndexCreator indexCreator = db.schema().indexFor(Label.label(LABEL1));
for (String prop : props) {
indexCreator = indexCreator.on(prop);
}
indexCreator.create();
});
IndexRule rule = storage.indexGetForSchema(NewIndexDescriptorFactory.forLabel(labelId(LABEL1), Arrays.stream(props).mapToInt(this::propId).toArray()));
assertNotNull(rule);
assertTrue(SchemaDescriptorPredicates.hasLabel(rule, labelId(LABEL1)));
for (String prop : props) {
assertTrue(SchemaDescriptorPredicates.hasProperty(rule, propId(prop)));
}
assertEquals(NewIndexDescriptor.Type.GENERAL, rule.getIndexDescriptor().type());
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaStorageTest method shouldReturnIndexRuleForLabelAndProperty.
@Test
public void shouldReturnIndexRuleForLabelAndProperty() {
// Given
createSchema(index(LABEL1, PROP1), index(LABEL1, PROP2), index(LABEL2, PROP1));
// When
IndexRule rule = storage.indexGetForSchema(indexDescriptor(LABEL1, PROP2));
// Then
assertNotNull(rule);
assertRule(rule, LABEL1, PROP2, NewIndexDescriptor.Type.GENERAL);
}
use of org.neo4j.kernel.impl.store.record.IndexRule in project neo4j by neo4j.
the class SchemaStorageTest method shouldReturnIndexRuleForLabelAndPropertyComposite.
@Test
public void shouldReturnIndexRuleForLabelAndPropertyComposite() throws Exception {
String a = "a", b = "b", c = "c", d = "d", e = "e", f = "f";
createSchema(db -> {
db.schema().indexFor(Label.label(LABEL1)).on(a).on(b).on(c).on(d).on(e).on(f).create();
});
IndexRule rule = storage.indexGetForSchema(NewIndexDescriptorFactory.forLabel(labelId(LABEL1), propId(a), propId(b), propId(c), propId(d), propId(e), propId(f)));
assertNotNull(rule);
assertTrue(SchemaDescriptorPredicates.hasLabel(rule, labelId(LABEL1)));
assertTrue(SchemaDescriptorPredicates.hasProperty(rule, propId(a)));
assertTrue(SchemaDescriptorPredicates.hasProperty(rule, propId(b)));
assertTrue(SchemaDescriptorPredicates.hasProperty(rule, propId(c)));
assertTrue(SchemaDescriptorPredicates.hasProperty(rule, propId(d)));
assertTrue(SchemaDescriptorPredicates.hasProperty(rule, propId(e)));
assertTrue(SchemaDescriptorPredicates.hasProperty(rule, propId(f)));
assertEquals(NewIndexDescriptor.Type.GENERAL, rule.getIndexDescriptor().type());
}
Aggregations