use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class TxStateTest method shouldAddUniquenessConstraint.
@Test
void shouldAddUniquenessConstraint() {
// when
LabelSchemaDescriptor schema = forLabel(1, 17);
UniquenessConstraintDescriptor constraint = ConstraintDescriptorFactory.uniqueForSchema(schema);
state.constraintDoAdd(constraint, IndexPrototype.uniqueForSchema(schema).withName("constraint_7").materialise(7));
// then
DiffSets<ConstraintDescriptor> diff = state.constraintsChangesForLabel(1);
assertEquals(singleton(constraint), diff.getAdded());
assertTrue(diff.getRemoved().isEmpty());
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class TxStateTest method addingUniquenessConstraintShouldBeIdempotent.
@Test
void addingUniquenessConstraintShouldBeIdempotent() {
// given
LabelSchemaDescriptor schema = forLabel(1, 17);
UniquenessConstraintDescriptor constraint1 = ConstraintDescriptorFactory.uniqueForSchema(schema);
state.constraintDoAdd(constraint1, IndexPrototype.uniqueForSchema(schema).withName("constraint_7").materialise(7));
// when
UniquenessConstraintDescriptor constraint2 = ConstraintDescriptorFactory.uniqueForSchema(schema);
state.constraintDoAdd(constraint2, IndexPrototype.uniqueForSchema(schema).withName("constraint_19").materialise(19));
// then
assertEquals(constraint1, constraint2);
assertEquals(singleton(constraint1), state.constraintsChangesForLabel(1).getAdded());
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class BuiltInProceduresTest method givenIndex.
private void givenIndex(String label, String propKey) {
int labelId = token(label, labels);
int propId = token(propKey, propKeys);
int id = indexes.size() + 1000;
Map<String, Value> configMap = new HashMap<>();
configMap.put("config1", Values.stringValue("value1"));
configMap.put("config2", Values.intValue(2));
configMap.put("config3", Values.booleanValue(true));
LabelSchemaDescriptor schema = forLabel(labelId, propId);
IndexDescriptor index = IndexPrototype.forSchema(schema, EMPTY.getProviderDescriptor()).withName("index_" + id).materialise(id).withIndexConfig(IndexConfig.with(configMap));
indexes.add(index);
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class BuiltInProceduresTest method givenUniqueConstraint.
private void givenUniqueConstraint(String label, String propKey) {
int labelId = token(label, labels);
int propId = token(propKey, propKeys);
LabelSchemaDescriptor schema = forLabel(labelId, propId);
int id = uniqueIndexes.size() + 1000;
final String name = "constraint_" + id;
IndexDescriptor index = IndexPrototype.uniqueForSchema(schema, EMPTY.getProviderDescriptor()).withName(name).materialise(id);
uniqueIndexes.add(index);
final UniquenessConstraintDescriptor constraint = ConstraintDescriptorFactory.uniqueForLabel(labelId, propId).withName(name);
constraints.add(constraint);
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class FusionIndexPopulatorTest method verifySampleToCorrectPopulator.
private void verifySampleToCorrectPopulator(Value[] values, IndexPopulator populator) {
for (Value value : values) {
// when
IndexEntryUpdate<LabelSchemaDescriptor> update = add(value);
fusionIndexPopulator.includeSample(update);
// then
verify(populator).includeSample(update);
reset(populator);
}
}
Aggregations