use of org.jmock.Mock in project intellij-plugins by JetBrains.
the class JabberTransportTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myFacade = new MockJabberFacade();
myUIMock = mock(JabberUI.class);
myUserModel = new UserModelImpl(getBroadcaster());
disposeOnTearDown(myUserModel);
Mock dispatcherMock = mock(AsyncMessageDispatcher.class);
myIDEFacade = new MockIDEFacade();
dispatcherMock.stubs().method("getIdeFacade").will(returnValue(myIDEFacade));
myTransport = new JabberTransport((JabberUI) myUIMock.proxy(), myFacade, myUserModel, (AsyncMessageDispatcher) dispatcherMock.proxy(), null);
disposeOnTearDown(myTransport);
myProjectContainer = Pico.getInstance().makeChildContainer();
}
use of org.jmock.Mock in project intellij-plugins by JetBrains.
the class JabberUserFinderTest method testAskForRegister_AnswerYes.
public void testAskForRegister_AnswerYes() throws Exception {
Mock facadeMock = mock(IDEFacade.class);
final String[] params = new String[2];
myUserFinder = new JabberUserFinderImpl((IDEFacade) facadeMock.proxy(), myUserModel) {
@Override
protected void doRegister(final String jabberUserId, final String currentProjectId) {
params[0] = jabberUserId;
params[1] = currentProjectId;
}
};
set_project(facadeMock, "id1", true);
myUserFinder.registerForProject("kir@fff");
assertEquals("kir@fff", params[0]);
assertEquals("id1", params[1]);
params[0] = params[1] = null;
set_project(facadeMock, "id1", false);
myUserFinder.registerForProject("kir@fff");
assertNull("No questions expected now - same user and project", params[0]);
set_project(facadeMock, "id1", true);
myUserFinder.registerForProject("kir@fff1");
assertEquals("Another user, expect question", "kir@fff1", params[0]);
params[0] = params[1] = null;
set_project(facadeMock, "id2", true);
myUserFinder.registerForProject("kir@fff1");
assertEquals("Another project, expect question", "kir@fff1", params[0]);
}
use of org.jmock.Mock in project intellij-plugins by JetBrains.
the class JabberUserFinderTest method testAskForRegister_AnswerNo.
public void testAskForRegister_AnswerNo() throws Exception {
Mock facadeMock = mock(IDEFacade.class);
final String[] params = new String[2];
myUserFinder = new JabberUserFinderImpl((IDEFacade) facadeMock.proxy(), myUserModel) {
@Override
protected void doRegister(final String jabberUserId, final String currentProjectId) {
params[0] = jabberUserId;
params[1] = currentProjectId;
}
};
facadeMock.expects(atLeastOnce()).method("getCacheDir").will(returnValue(myFacade.getCacheDir()));
facadeMock.expects(once()).method("getCurrentProjectId").will(returnValue("id1"));
facadeMock.expects(once()).method("askQuestion").will(returnValue(false));
myUserFinder.registerForProject("kir@fff");
assertNull(params[0]);
}
use of org.jmock.Mock in project intellij-plugins by JetBrains.
the class UserMonitorThreadTest method testProgressIndicatorInvocations.
public void testProgressIndicatorInvocations() throws Exception {
expectSetOneOnlineUser();
Mock mockProgressIndicator = mock(ProgressIndicator.class);
mockProgressIndicator.expects(atLeastOnce()).method("setText").with(eq("Found in local network: 1 user"));
mockProgressIndicator.expects(atLeastOnce()).method("checkCanceled");
final double[] lastFraction = new double[] { -1 };
mockProgressIndicator.expects(atLeastOnce()).method("setFraction").with(new IsGreaterThan(new Comparable() {
@Override
public int compareTo(Object o) {
double v = ((Number) o).doubleValue();
int result = (int) ((lastFraction[0] - v) * 100);
lastFraction[0] = v;
if (result >= 0) {
System.out.println("result = " + result);
}
return result;
}
public String toString() {
return "" + lastFraction[0];
}
}));
myUserMonitorThread.findNow((ProgressIndicator) mockProgressIndicator.proxy());
assertEquals("Should end at 100%", 1, lastFraction[0], 0.01);
}
use of org.jmock.Mock 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;
}
Aggregations