Search in sources :

Example 1 with InMemoryTokens

use of org.neo4j.test.InMemoryTokens in project neo4j by neo4j.

the class PlainOperationsTest method indexedBackedConstraintCreateMustThrowOnIndexTypeFullText.

@Test
void indexedBackedConstraintCreateMustThrowOnIndexTypeFullText() throws Exception {
    // given
    IndexPrototype prototype = IndexPrototype.uniqueForSchema(schema).withName("constraint name").withIndexProvider(GenericNativeIndexProvider.DESCRIPTOR).withIndexType(IndexType.FULLTEXT);
    IndexDescriptor constraintIndex = prototype.materialise(42);
    when(constraintIndexCreator.createUniquenessConstraintIndex(any(), any(), eq(prototype))).thenReturn(constraintIndex);
    IndexProxy indexProxy = mock(IndexProxy.class);
    when(indexProxy.getDescriptor()).thenReturn(constraintIndex);
    when(indexingService.getIndexProxy(constraintIndex)).thenReturn(indexProxy);
    when(storageReader.constraintsGetForSchema(schema)).thenReturn(Collections.emptyIterator());
    when(storageReader.indexGetForSchema(schema)).thenReturn(Collections.emptyIterator());
    // when
    var e = assertThrows(KernelException.class, () -> operations.uniquePropertyConstraintCreate(prototype));
    assertThat(e.getUserMessage(new InMemoryTokens())).contains("FULLTEXT");
}
Also used : InMemoryTokens(org.neo4j.test.InMemoryTokens) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 2 with InMemoryTokens

use of org.neo4j.test.InMemoryTokens in project neo4j by neo4j.

the class MultipleIndexPopulatorTest method before.

@BeforeEach
void before() {
    indexStatisticsStore = mock(IndexStatisticsStore.class);
    indexStoreView = mock(IndexStoreView.class);
    when(indexStoreView.newPropertyAccessor(any(CursorContext.class), any())).thenReturn(mock(NodePropertyAccessor.class));
    when(indexStoreView.visitNodes(any(), any(), any(), any(), anyBoolean(), anyBoolean(), any(), any())).thenReturn(mock(StoreScan.class));
    schemaState = mock(SchemaState.class);
    tokens = new InMemoryTokens();
    multipleIndexPopulator = new MultipleIndexPopulator(indexStoreView, NullLogProvider.getInstance(), EntityType.NODE, schemaState, jobScheduler, tokens, PageCacheTracer.NULL, INSTANCE, "", AUTH_DISABLED, Config.defaults());
}
Also used : InMemoryTokens(org.neo4j.test.InMemoryTokens) SchemaState(org.neo4j.internal.schema.SchemaState) IndexStatisticsStore(org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore) CursorContext(org.neo4j.io.pagecache.context.CursorContext) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with InMemoryTokens

use of org.neo4j.test.InMemoryTokens in project neo4j by neo4j.

the class CompositeIndexAccessorCompatibility method testExactMatchOnRandomCompositeValues.

@Test
public void testExactMatchOnRandomCompositeValues() throws Exception {
    // given
    ValueType[] types = randomSetOfSupportedTypes();
    List<ValueIndexEntryUpdate<?>> updates = new ArrayList<>();
    Set<ValueTuple> duplicateChecker = new HashSet<>();
    for (long id = 0; id < 10_000; id++) {
        ValueIndexEntryUpdate<SchemaDescriptor> update;
        do {
            update = add(id, descriptor.schema(), random.randomValues().nextValueOfTypes(types), random.randomValues().nextValueOfTypes(types));
        } while (!duplicateChecker.add(ValueTuple.of(update.values())));
        updates.add(update);
    }
    updateAndCommit(updates);
    // when
    InMemoryTokens tokenNameLookup = new InMemoryTokens();
    for (ValueIndexEntryUpdate<?> update : updates) {
        // then
        List<Long> hits = query(exact(0, update.values()[0]), exact(1, update.values()[1]));
        assertEquals(update.describe(tokenNameLookup) + " " + hits, 1, hits.size());
        assertThat(single(hits)).isEqualTo(update.getEntityId());
    }
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) InMemoryTokens(org.neo4j.test.InMemoryTokens) ValueType(org.neo4j.values.storable.ValueType) ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) ArrayList(java.util.ArrayList) ValueTuple(org.neo4j.values.storable.ValueTuple) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with InMemoryTokens

use of org.neo4j.test.InMemoryTokens in project neo4j by neo4j.

the class IndexDescriptorTest method userDescriptionMustIncludeSchemaDescription.

@Test
void userDescriptionMustIncludeSchemaDescription() {
    IndexPrototype prototype = IndexPrototype.forSchema(SCHEMAS[0]);
    IndexDescriptor index = prototype.withName("index").materialise(1);
    InMemoryTokens tokens = new InMemoryTokens();
    String schemaDescription = SCHEMAS[0].userDescription(tokens);
    assertThat(prototype.userDescription(tokens)).contains(schemaDescription);
    assertThat(index.userDescription(tokens)).contains(schemaDescription);
}
Also used : InMemoryTokens(org.neo4j.test.InMemoryTokens) Test(org.junit.jupiter.api.Test)

Aggregations

InMemoryTokens (org.neo4j.test.InMemoryTokens)4 Test (org.junit.jupiter.api.Test)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)1 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)1 SchemaState (org.neo4j.internal.schema.SchemaState)1 CursorContext (org.neo4j.io.pagecache.context.CursorContext)1 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)1 IndexStatisticsStore (org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore)1 NodePropertyAccessor (org.neo4j.storageengine.api.NodePropertyAccessor)1 ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)1 ValueTuple (org.neo4j.values.storable.ValueTuple)1 ValueType (org.neo4j.values.storable.ValueType)1