ListeningExecutorService userExecutor = MoreExecutors.sameThreadExecutor();
Predicate<String> notRunningAnymore = Predicates.alwaysTrue();
SudoAwareInitManager commandRunner = createMockBuilder(SudoAwareInitManager.class).addMockedMethod(
"refreshAndRunAction").addMockedMethod("runAction").addMockedMethod("getStatement").addMockedMethod(
"getNode").addMockedMethod("toString").createStrictMock();
InitScript initScript = createMockBuilder(InitScript.class).addMockedMethod("getInstanceName").createStrictMock();
// log what we are stopping
expect(commandRunner.getStatement()).andReturn(initScript);
expect(initScript.getInstanceName()).andReturn("init-script");
// stop
expect(commandRunner.refreshAndRunAction("stop")).andReturn(new ExecResponse("stdout", "", 0));
// create cancellation exception
expect(commandRunner.getStatement()).andReturn(initScript);
expect(initScript.getInstanceName()).andReturn("init-script");
expect(commandRunner.getNode()).andReturn(
new NodeMetadataBuilder().ids("id").status(NodeMetadata.Status.RUNNING).build()).atLeastOnce();
// StatementOnNodeFailure event
expect(commandRunner.getStatement()).andReturn(initScript);