use of org.neo4j.storageengine.api.CommandCreationContext 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.storageengine.api.CommandCreationContext in project neo4j by neo4j.
the class KernelTokenTest method setUp.
@BeforeEach
void setUp() {
ktx = mock(KernelTransactionImplementation.class);
transactionState = mock(TransactionState.class);
when(ktx.txState()).thenReturn(transactionState);
commandCreationContext = mock(CommandCreationContext.class);
storageReader = mock(StorageReader.class);
propertyKeyTokens = mock(TokenHolder.class);
labelTokens = mock(TokenHolder.class);
relationshipTypeTokens = mock(TokenHolder.class);
tokenHolders = new TokenHolders(propertyKeyTokens, labelTokens, relationshipTypeTokens);
kernelToken = new KernelToken(storageReader, commandCreationContext, ktx, tokenHolders);
}
use of org.neo4j.storageengine.api.CommandCreationContext in project neo4j by neo4j.
the class NeoStoresTest method commitTx.
private void commitTx() throws Exception {
try (CommandCreationContext commandCreationContext = storageEngine.newCommandCreationContext(INSTANCE)) {
CursorContext cursorContext = NULL;
commandCreationContext.initialize(cursorContext);
List<StorageCommand> commands = new ArrayList<>();
storageEngine.createCommands(commands, transactionState, storageReader, commandCreationContext, IGNORE, NONE, storageEngine.testAccessNeoStores().getMetaDataStore().getLastClosedTransactionId(), tx -> tx, cursorContext, INSTANCE);
PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(commands);
tx.setHeader(EMPTY_BYTE_ARRAY, -1, -1, -1, -1, AUTH_DISABLED);
storageEngine.apply(new TransactionToApply(tx, cursorContext), INTERNAL);
}
}
Aggregations