Search in sources :

Example 1 with ReadableTransactionState

use of org.neo4j.storageengine.api.txstate.ReadableTransactionState in project neo4j by neo4j.

the class ReplicatedTokenHolderTest method mockedStorageEngine.

@SuppressWarnings("unchecked")
private StorageEngine mockedStorageEngine() throws Exception {
    StorageEngine storageEngine = mock(StorageEngine.class);
    doAnswer(invocation -> {
        Collection<StorageCommand> target = invocation.getArgumentAt(0, Collection.class);
        ReadableTransactionState txState = invocation.getArgumentAt(1, ReadableTransactionState.class);
        txState.accept(new TxStateVisitor.Adapter() {

            @Override
            public void visitCreatedLabelToken(String name, int id) {
                LabelTokenRecord before = new LabelTokenRecord(id);
                LabelTokenRecord after = before.clone();
                after.setInUse(true);
                target.add(new Command.LabelTokenCommand(before, after));
            }
        });
        return null;
    }).when(storageEngine).createCommands(anyCollection(), any(ReadableTransactionState.class), any(StorageStatement.class), any(ResourceLocker.class), anyLong());
    StoreReadLayer readLayer = mock(StoreReadLayer.class);
    when(readLayer.newStatement()).thenReturn(mock(StorageStatement.class));
    when(storageEngine.storeReadLayer()).thenReturn(readLayer);
    return storageEngine;
}
Also used : TxStateVisitor(org.neo4j.storageengine.api.txstate.TxStateVisitor) StorageStatement(org.neo4j.storageengine.api.StorageStatement) StoreReadLayer(org.neo4j.storageengine.api.StoreReadLayer) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ResourceLocker(org.neo4j.storageengine.api.lock.ResourceLocker) ReadableTransactionState(org.neo4j.storageengine.api.txstate.ReadableTransactionState) StorageEngine(org.neo4j.storageengine.api.StorageEngine) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Aggregations

LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)1 StorageCommand (org.neo4j.storageengine.api.StorageCommand)1 StorageEngine (org.neo4j.storageengine.api.StorageEngine)1 StorageStatement (org.neo4j.storageengine.api.StorageStatement)1 StoreReadLayer (org.neo4j.storageengine.api.StoreReadLayer)1 ResourceLocker (org.neo4j.storageengine.api.lock.ResourceLocker)1 ReadableTransactionState (org.neo4j.storageengine.api.txstate.ReadableTransactionState)1 TxStateVisitor (org.neo4j.storageengine.api.txstate.TxStateVisitor)1