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");
}
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());
}
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());
}
}
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);
}
Aggregations