Search in sources :

Example 1 with IDEFacade

use of jetbrains.communicator.ide.IDEFacade 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]);
}
Also used : Mock(org.jmock.Mock) MockIDEFacade(jetbrains.communicator.mock.MockIDEFacade) IDEFacade(jetbrains.communicator.ide.IDEFacade)

Example 2 with IDEFacade

use of jetbrains.communicator.ide.IDEFacade 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]);
}
Also used : Mock(org.jmock.Mock) MockIDEFacade(jetbrains.communicator.mock.MockIDEFacade) IDEFacade(jetbrains.communicator.ide.IDEFacade)

Example 3 with IDEFacade

use of jetbrains.communicator.ide.IDEFacade in project intellij-plugins by JetBrains.

the class ViewFilesCommandTest method testExecute_NoInformation.

public void testExecute_NoInformation() throws Exception {
    final ProjectsData projectsData = new ProjectsData();
    MockUser mockUser = new MockUser("user", null) {

        @Override
        public ProjectsData getProjectsData(IDEFacade ideFacade) {
            return projectsData;
        }
    };
    mockUser.setOnline(true);
    myMockUserListComponent.setSelectedNodes(new User[] { mockUser });
    myFacadeMock.expects(once()).method("showMessage");
    myCommand.execute();
}
Also used : ProjectsData(jetbrains.communicator.core.vfs.ProjectsData) IDEFacade(jetbrains.communicator.ide.IDEFacade) MockUser(jetbrains.communicator.mock.MockUser)

Example 4 with IDEFacade

use of jetbrains.communicator.ide.IDEFacade in project intellij-plugins by JetBrains.

the class ShowDiffCommandTest method testExecute.

public void testExecute() throws Exception {
    final VFile vFile = VFile.create("a file");
    MockUser user = new MockUser() {

        @Override
        public String getVFile(VFile file, IDEFacade ideFacade) {
            assertSame(vFile, file);
            return "something";
        }
    };
    myCommand.setUser(user);
    myCommand.setVFile(vFile);
    myFacadeMock.expects(once()).method("showDiffFor").with(eq(user), eq(vFile), eq("something"));
    myCommand.execute();
}
Also used : IDEFacade(jetbrains.communicator.ide.IDEFacade) VFile(jetbrains.communicator.core.vfs.VFile) MockUser(jetbrains.communicator.mock.MockUser)

Example 5 with IDEFacade

use of jetbrains.communicator.ide.IDEFacade in project intellij-plugins by JetBrains.

the class OutgoingCodePointerLocalMessage method createConsoleMessage.

public ConsoleMessage createConsoleMessage(User user) {
    return new OwnConsoleMessage(user, StringUtil.getMsg("code.pointer"), getWhen()) {

        public void printMessage(Project project, ConsoleView console) {
            final IDEAFacade ideFacade = (IDEAFacade) Pico.getInstance().getComponentInstanceOfType(IDEFacade.class);
            IncomingCodePointerMessage printer = new IncomingCodePointerMessage(myEvent, ideFacade);
            printer.outputMessage(console);
        }
    };
}
Also used : Project(com.intellij.openapi.project.Project) IncomingCodePointerMessage(jetbrains.communicator.idea.codePointer.IncomingCodePointerMessage) ConsoleView(com.intellij.execution.ui.ConsoleView) OwnConsoleMessage(jetbrains.communicator.idea.messagesWindow.OwnConsoleMessage) IDEFacade(jetbrains.communicator.ide.IDEFacade)

Aggregations

IDEFacade (jetbrains.communicator.ide.IDEFacade)13 MockUser (jetbrains.communicator.mock.MockUser)5 UserModelImpl (jetbrains.communicator.core.impl.users.UserModelImpl)3 ProjectsData (jetbrains.communicator.core.vfs.ProjectsData)3 MockIDEFacade (jetbrains.communicator.mock.MockIDEFacade)3 Mock (org.jmock.Mock)3 VFile (jetbrains.communicator.core.vfs.VFile)2 MockUserListComponent (jetbrains.communicator.mock.MockUserListComponent)2 ConsoleView (com.intellij.execution.ui.ConsoleView)1 Project (com.intellij.openapi.project.Project)1 UserListComponent (jetbrains.communicator.ide.UserListComponent)1 IdeaLocalMessage (jetbrains.communicator.idea.IdeaLocalMessage)1 IncomingCodePointerMessage (jetbrains.communicator.idea.codePointer.IncomingCodePointerMessage)1 OwnConsoleMessage (jetbrains.communicator.idea.messagesWindow.OwnConsoleMessage)1