Search in sources :

Example 6 with TokenNameLookup

use of org.neo4j.common.TokenNameLookup in project neo4j by neo4j.

the class PropertyDeleterTest method startStore.

private void startStore(boolean log) {
    Config config = Config.defaults(GraphDatabaseInternalSettings.log_inconsistent_data_deletion, log);
    idGeneratorFactory = new DefaultIdGeneratorFactory(directory.getFileSystem(), immediate(), "db");
    neoStores = new StoreFactory(DatabaseLayout.ofFlat(directory.homePath()), config, idGeneratorFactory, pageCache, directory.getFileSystem(), NullLogProvider.getInstance(), PageCacheTracer.NULL, writable()).openAllNeoStores(true);
    propertyStore = neoStores.getPropertyStore();
    propertyCreator = new PropertyCreator(propertyStore, traverser, NULL, INSTANCE);
    deleter = new PropertyDeleter(traverser, this.neoStores, new TokenNameLookup() {

        @Override
        public String labelGetName(int labelId) {
            return "" + labelId;
        }

        @Override
        public String relationshipTypeGetName(int relationshipTypeId) {
            return "" + relationshipTypeId;
        }

        @Override
        public String propertyKeyGetName(int propertyKeyId) {
            return "" + propertyKeyId;
        }
    }, logProvider, config, NULL, INSTANCE);
}
Also used : TokenNameLookup(org.neo4j.common.TokenNameLookup) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory)

Example 7 with TokenNameLookup

use of org.neo4j.common.TokenNameLookup in project neo4j by neo4j.

the class SchemaStorageTest method shouldThrowExceptionOnNodeDuplicateRuleFound.

@Test
void shouldThrowExceptionOnNodeDuplicateRuleFound() {
    TokenNameLookup tokenNameLookup = getDefaultTokenNameLookup();
    SchemaStorage schemaStorageSpy = Mockito.spy(storage);
    when(schemaStorageSpy.streamAllSchemaRules(false, NULL)).thenReturn(Stream.of(getUniquePropertyConstraintRule(1L, LABEL1_ID, PROP1_ID), getUniquePropertyConstraintRule(2L, LABEL1_ID, PROP1_ID)));
    var e = assertThrows(DuplicateSchemaRuleException.class, () -> schemaStorageSpy.constraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(LABEL1_ID, PROP1_ID), NULL));
    assertThat(e, tokenNameLookup).hasUserMessage("Multiple label uniqueness constraints found for (:Label1 {prop1}).");
}
Also used : TokenNameLookup(org.neo4j.common.TokenNameLookup) Test(org.junit.jupiter.api.Test)

Example 8 with TokenNameLookup

use of org.neo4j.common.TokenNameLookup in project neo4j by neo4j.

the class SchemaStorageTest method getDefaultTokenNameLookup.

private static TokenNameLookup getDefaultTokenNameLookup() {
    TokenNameLookup tokenNameLookup = mock(TokenNameLookup.class);
    when(tokenNameLookup.labelGetName(LABEL1_ID)).thenReturn(LABEL1);
    when(tokenNameLookup.propertyKeyGetName(PROP1_ID)).thenReturn(PROP1);
    when(tokenNameLookup.relationshipTypeGetName(TYPE1_ID)).thenReturn(TYPE1);
    when(tokenNameLookup.entityTokensGetNames(EntityType.NODE, new int[] { LABEL1_ID })).thenReturn(new String[] { LABEL1 });
    when(tokenNameLookup.entityTokensGetNames(EntityType.RELATIONSHIP, new int[] { TYPE1_ID })).thenReturn(new String[] { TYPE1 });
    return tokenNameLookup;
}
Also used : TokenNameLookup(org.neo4j.common.TokenNameLookup)

Example 9 with TokenNameLookup

use of org.neo4j.common.TokenNameLookup in project neo4j by neo4j.

the class SchemaStorageTest method shouldThrowExceptionOnNodeRuleNotFound.

@Test
void shouldThrowExceptionOnNodeRuleNotFound() {
    TokenNameLookup tokenNameLookup = getDefaultTokenNameLookup();
    var e = assertThrows(SchemaRuleNotFoundException.class, () -> storage.constraintsGetSingle(ConstraintDescriptorFactory.existsForLabel(LABEL1_ID, PROP1_ID), NULL));
    assertThat(e, tokenNameLookup).hasUserMessage("No label property existence constraint was found for (:Label1 {prop1}).");
}
Also used : TokenNameLookup(org.neo4j.common.TokenNameLookup) Test(org.junit.jupiter.api.Test)

Aggregations

TokenNameLookup (org.neo4j.common.TokenNameLookup)9 Test (org.junit.jupiter.api.Test)5 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)2 Config (org.neo4j.configuration.Config)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 String.format (java.lang.String.format)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 BitSet (java.util.BitSet)1 Collection (java.util.Collection)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 StringJoiner (java.util.StringJoiner)1 TimeUnit (java.util.concurrent.TimeUnit)1 UnaryOperator (java.util.function.UnaryOperator)1