use of org.neo4j.internal.schema.constraints.RelExistenceConstraintDescriptor in project neo4j by neo4j.
the class SchemaCheckerTest method shouldPopulateMandatoryPropertiesMap.
@Test
void shouldPopulateMandatoryPropertiesMap() throws Exception {
// given
try (AutoCloseable ignored = tx()) {
var cursorContext = CursorContext.NULL;
NodeExistenceConstraintDescriptor constraint1 = ConstraintDescriptorFactory.existsForLabel(label1, propertyKey1).withId(schemaStore.nextId(cursorContext)).withName(NAME);
NodeExistenceConstraintDescriptor constraint2 = ConstraintDescriptorFactory.existsForLabel(label2, propertyKey1, propertyKey2).withId(schemaStore.nextId(cursorContext)).withName(NAME2);
RelExistenceConstraintDescriptor constraint3 = ConstraintDescriptorFactory.existsForRelType(relationshipType1, propertyKey2).withId(schemaStore.nextId(cursorContext)).withName(NAME);
RelExistenceConstraintDescriptor constraint4 = ConstraintDescriptorFactory.existsForRelType(relationshipType2, propertyKey1, propertyKey2).withId(schemaStore.nextId(cursorContext)).withName(NAME2);
schemaStorage.writeSchemaRule(constraint1, cursorContext, INSTANCE);
schemaStorage.writeSchemaRule(constraint2, cursorContext, INSTANCE);
schemaStorage.writeSchemaRule(constraint3, cursorContext, INSTANCE);
schemaStorage.writeSchemaRule(constraint4, cursorContext, INSTANCE);
}
// when
check();
// then
assertEquals(IntSets.mutable.of(propertyKey1), mandatoryNodeProperties.remove(label1));
assertEquals(IntSets.mutable.of(propertyKey1, propertyKey2), mandatoryNodeProperties.remove(label2));
assertTrue(mandatoryNodeProperties.isEmpty());
assertEquals(IntSets.mutable.of(propertyKey2), mandatoryRelationshipProperties.remove(relationshipType1));
assertEquals(IntSets.mutable.of(propertyKey1, propertyKey2), mandatoryRelationshipProperties.remove(relationshipType2));
assertTrue(mandatoryRelationshipProperties.isEmpty());
}
Aggregations