Search in sources :

Example 1 with Invocation

use of org.jmock.core.Invocation in project intellij-plugins by JetBrains.

the class JabberTransport_ConnectionTest method createJabberUIMock.

private Mock createJabberUIMock() {
    Mock mockUI = mock(JabberUI.class);
    mockUI.stubs().method("connectAndLogin").will(new ReturnStub(Boolean.TRUE) {

        @Override
        public Object invoke(Invocation invocation) throws Throwable {
            myFacade.connect();
            return super.invoke(invocation);
        }
    });
    return mockUI;
}
Also used : Invocation(org.jmock.core.Invocation) ReturnStub(org.jmock.core.stub.ReturnStub) Mock(org.jmock.Mock)

Example 2 with Invocation

use of org.jmock.core.Invocation in project intellij-plugins by JetBrains.

the class ClearHistoryCommandTest method testClearHistory.

public void testClearHistory() throws Exception {
    myIdeMock.expects(once()).method("askQuestion").with(eq(StringUtil.getMsg("ClearHistoryCommand.title")), eq(StringUtil.getMsg("ClearHistoryCommand.text"))).will(returnValue(true));
    myIdeMock.expects(once()).method("runLongProcess").will(new CustomStub("runner") {

        @Override
        public Object invoke(Invocation invocation) throws Throwable {
            ((IDEFacade.Process) invocation.parameterValues.get(1)).run(new NullProgressIndicator());
            return null;
        }
    });
    myIdeMock.expects(once()).method("runOnPooledThread").will(new CustomStub("foo") {

        @Override
        public Object invoke(Invocation invocation) throws Throwable {
            final FutureTask task = new FutureTask((Runnable) invocation.parameterValues.get(0), null);
            task.run();
            return task;
        }
    });
    myDispatcherMock.expects(once()).method("clearHistory");
    myCommand.execute();
}
Also used : Invocation(org.jmock.core.Invocation) FutureTask(java.util.concurrent.FutureTask) CustomStub(org.jmock.core.stub.CustomStub) NullProgressIndicator(jetbrains.communicator.ide.NullProgressIndicator) IDEFacade(jetbrains.communicator.ide.IDEFacade)

Aggregations

Invocation (org.jmock.core.Invocation)2 FutureTask (java.util.concurrent.FutureTask)1 IDEFacade (jetbrains.communicator.ide.IDEFacade)1 NullProgressIndicator (jetbrains.communicator.ide.NullProgressIndicator)1 Mock (org.jmock.Mock)1 CustomStub (org.jmock.core.stub.CustomStub)1 ReturnStub (org.jmock.core.stub.ReturnStub)1