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;
}
Aggregations