use of org.neo4j.kernel.impl.api.index.IndexingProvidersService in project neo4j by neo4j.
the class PlainOperationsTest method shouldAcquireTxStateBeforeAllocatingSchemaId.
@Test
void shouldAcquireTxStateBeforeAllocatingSchemaId() throws KernelException {
// given
KernelTransactionImplementation ktx = mock(KernelTransactionImplementation.class);
when(ktx.txState()).thenReturn(mock(TransactionState.class));
Locks.Client lockClient = mock(Locks.Client.class);
when(ktx.lockClient()).thenReturn(lockClient);
CommandCreationContext commandCreationContext = mock(CommandCreationContext.class);
IndexingProvidersService indexingProvidersService = mock(IndexingProvidersService.class);
when(indexingProvidersService.getDefaultProvider()).thenReturn(mock(IndexProviderDescriptor.class));
AllStoreHolder allStoreHolder = mock(AllStoreHolder.class);
when(allStoreHolder.index(any())).thenReturn(Iterators.emptyResourceIterator());
when(allStoreHolder.indexGetForName(any())).thenReturn(IndexDescriptor.NO_INDEX);
when(allStoreHolder.constraintsGetForSchema(any())).thenReturn(Iterators.emptyResourceIterator());
Operations operations = new Operations(allStoreHolder, mock(StorageReader.class), mock(IndexTxStateUpdater.class), commandCreationContext, ktx, mock(KernelToken.class), mock(DefaultPooledCursors.class), mock(ConstraintIndexCreator.class), mock(ConstraintSemantics.class), indexingProvidersService, Config.defaults(), INSTANCE, () -> KernelVersion.LATEST, mock(DbmsRuntimeRepository.class));
// when
operations.indexCreate(IndexPrototype.forSchema(schema).withName("name"));
// then
InOrder inOrder = inOrder(ktx, commandCreationContext);
inOrder.verify(ktx).txState();
inOrder.verify(commandCreationContext).reserveSchema();
inOrder.verifyNoMoreInteractions();
}
use of org.neo4j.kernel.impl.api.index.IndexingProvidersService in project neo4j by neo4j.
the class OperationsTest method setUp.
@BeforeEach
void setUp() throws Exception {
TxState realTxState = new TxState();
txState = Mockito.spy(realTxState);
when(transaction.getReasonIfTerminated()).thenReturn(Optional.empty());
when(transaction.lockClient()).thenReturn(locks);
when(transaction.dataWrite()).thenReturn(write);
when(transaction.isOpen()).thenReturn(true);
when(transaction.lockTracer()).thenReturn(LockTracer.NONE);
when(transaction.txState()).thenReturn(txState);
when(transaction.securityContext()).thenReturn(SecurityContext.authDisabled(AccessMode.Static.FULL, EMBEDDED_CONNECTION, DB_NAME));
logHelper = new SecurityLogHelper(getFormat());
securityLog = new CommunitySecurityLog((LogExtended) logHelper.getLogProvider().getLog(this.getClass()));
when(transaction.securityAuthorizationHandler()).thenReturn(new SecurityAuthorizationHandler(securityLog));
DefaultPooledCursors cursors = mock(DefaultPooledCursors.class);
nodeCursor = mock(FullAccessNodeCursor.class);
propertyCursor = mock(FullAccessPropertyCursor.class);
relationshipCursor = mock(DefaultRelationshipScanCursor.class);
when(cursors.allocateFullAccessNodeCursor(NULL)).thenReturn(nodeCursor);
when(cursors.allocateFullAccessPropertyCursor(NULL, INSTANCE)).thenReturn(propertyCursor);
when(cursors.allocateRelationshipScanCursor(NULL)).thenReturn(relationshipCursor);
StorageEngine engine = mock(StorageEngine.class);
storageReader = mock(StorageReader.class);
storageReaderSnapshot = mock(StorageSchemaReader.class);
when(storageReader.nodeExists(anyLong(), any())).thenReturn(true);
when(storageReader.constraintsGetForLabel(anyInt())).thenReturn(Collections.emptyIterator());
when(storageReader.constraintsGetAll()).thenReturn(Collections.emptyIterator());
when(storageReader.schemaSnapshot()).thenReturn(storageReaderSnapshot);
when(engine.newReader()).thenReturn(storageReader);
indexingService = mock(IndexingService.class);
Dependencies dependencies = new Dependencies();
var facade = mock(GraphDatabaseFacade.class);
dependencies.satisfyDependency(facade);
allStoreHolder = new AllStoreHolder(storageReader, transaction, cursors, mock(GlobalProcedures.class), mock(SchemaState.class), indexingService, mock(IndexStatisticsStore.class), dependencies, Config.defaults(), INSTANCE);
constraintIndexCreator = mock(ConstraintIndexCreator.class);
tokenHolders = mockedTokenHolders();
creationContext = mock(CommandCreationContext.class);
IndexingProvidersService indexingProvidersService = mock(IndexingProvidersService.class);
when(indexingProvidersService.indexProviderByName("native-btree-1.0")).thenReturn(GenericNativeIndexProvider.DESCRIPTOR);
when(indexingProvidersService.getDefaultProvider()).thenReturn(GenericNativeIndexProvider.DESCRIPTOR);
when(indexingProvidersService.indexProviderByName("fulltext-1.0")).thenReturn(FulltextIndexProviderFactory.DESCRIPTOR);
when(indexingProvidersService.getFulltextProvider()).thenReturn(FulltextIndexProviderFactory.DESCRIPTOR);
when(indexingProvidersService.indexProviderByName("provider-1.0")).thenReturn(new IndexProviderDescriptor("provider", "1.0"));
when(indexingProvidersService.completeConfiguration(any())).thenAnswer(inv -> inv.getArgument(0));
operations = new Operations(allStoreHolder, storageReader, mock(IndexTxStateUpdater.class), creationContext, transaction, new KernelToken(storageReader, creationContext, transaction, tokenHolders), cursors, constraintIndexCreator, mock(ConstraintSemantics.class), indexingProvidersService, Config.defaults(), INSTANCE, () -> KernelVersion.LATEST, mock(DbmsRuntimeRepository.class));
operations.initialize(NULL);
this.order = inOrder(locks, txState, storageReader, storageReaderSnapshot, creationContext);
}
Aggregations