Search in sources :

Example 6 with StorageSchemaReader

use of org.neo4j.storageengine.api.StorageSchemaReader in project neo4j by neo4j.

the class RecordStorageReaderSchemaTest method shouldListAllConstraintsAtTimeOfSnapshot.

@Test
void shouldListAllConstraintsAtTimeOfSnapshot() throws Exception {
    // Given
    createUniquenessConstraint(label1, propertyKey);
    // When
    StorageSchemaReader snapshot = storageReader.schemaSnapshot();
    createUniquenessConstraint(label2, propertyKey);
    Set<ConstraintDescriptor> constraints = asSet(snapshot.constraintsGetAll());
    // Then
    Set<ConstraintDescriptor> expectedConstraints = asSet(uniqueConstraintDescriptor(label1, propertyKey));
    assertEquals(expectedConstraints, constraints);
}
Also used : StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) Test(org.junit.jupiter.api.Test)

Example 7 with StorageSchemaReader

use of org.neo4j.storageengine.api.StorageSchemaReader in project neo4j by neo4j.

the class RecordStorageReaderSchemaTest method shouldListAllIndexesAtTimeOfSnapshot.

@Test
void shouldListAllIndexesAtTimeOfSnapshot() throws Exception {
    // Given
    IndexDescriptor expectedIndex = createIndex(label1, propertyKey);
    // When
    StorageSchemaReader snapshot = storageReader.schemaSnapshot();
    createIndex(label2, propertyKey);
    Set<IndexDescriptor> indexes = asSet(snapshot.indexesGetAll());
    // Then
    assertEquals(asSet(expectedIndex), indexes);
}
Also used : StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 8 with StorageSchemaReader

use of org.neo4j.storageengine.api.StorageSchemaReader in project neo4j by neo4j.

the class RecordStorageReaderSchemaTest method shouldListAllIndexesForLabelAtTimeOfSnapshot.

@Test
void shouldListAllIndexesForLabelAtTimeOfSnapshot() throws Exception {
    // Given
    IndexDescriptor expectedUniquenessIndex = createUniquenessConstraint(label1, propertyKey);
    IndexDescriptor expectedIndex = createIndex(label1, otherPropertyKey);
    createUniquenessConstraint(label2, propertyKey);
    createIndex(label2, otherPropertyKey);
    // When
    StorageSchemaReader snapshot = storageReader.schemaSnapshot();
    Set<IndexDescriptor> indexes = asSet(snapshot.indexesGetForLabel(labelId(label1)));
    // Then
    Set<IndexDescriptor> expectedIndexes = asSet(expectedIndex, expectedUniquenessIndex);
    assertEquals(expectedIndexes, indexes);
}
Also used : StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

StorageSchemaReader (org.neo4j.storageengine.api.StorageSchemaReader)8 Test (org.junit.jupiter.api.Test)5 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)5 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)4 String.format (java.lang.String.format)2 Collections (java.util.Collections)2 Iterator (java.util.Iterator)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Function (java.util.function.Function)2 Predicate (java.util.function.Predicate)2 Stream (java.util.stream.Stream)2 Dependencies (org.neo4j.collection.Dependencies)2 RawIterator (org.neo4j.collection.RawIterator)2 EntityType (org.neo4j.common.EntityType)2 Config (org.neo4j.configuration.Config)2 KernelException (org.neo4j.exceptions.KernelException)2 Predicates.alwaysTrue (org.neo4j.function.Predicates.alwaysTrue)2 Iterators (org.neo4j.internal.helpers.collection.Iterators)2 Iterators.singleOrNull (org.neo4j.internal.helpers.collection.Iterators.singleOrNull)2