Search in sources :

Example 1 with MessageType

use of org.eclipse.che.plugin.maven.shared.MessageType in project che by eclipse.

the class PomReconcilerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = new MavenTerminal() {

        @Override
        public void print(int level, String message, Throwable throwable) throws RemoteException {
            System.out.println(message);
            if (throwable != null) {
                throwable.printStackTrace();
            }
        }
    };
    File localRepository = new File(new File("target/localRepo").getAbsolutePath());
    localRepository.mkdirs();
    mavenServerManager.setLocalRepository(localRepository);
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    projectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    ClasspathManager classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, projectManager, terminal, mavenNotifier);
    mavenWorkspace = new MavenWorkspace(projectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, classpathManager, eventService, new EclipseWorkspaceProvider());
}
Also used : ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) File(java.io.File) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with MessageType

use of org.eclipse.che.plugin.maven.shared.MessageType in project che by eclipse.

the class WorkspaceTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = new MavenTerminal() {

        @Override
        public void print(int level, String message, Throwable throwable) throws RemoteException {
            System.out.println(message);
            if (throwable != null) {
                throwable.printStackTrace();
            }
        }
    };
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier), eventService, new EclipseWorkspaceProvider());
}
Also used : ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ArrayList(java.util.ArrayList) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with MessageType

use of org.eclipse.che.plugin.maven.shared.MessageType in project che by eclipse.

the class ClasspathManagerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = (level, message, throwable) -> {
        System.out.println(message);
        if (throwable != null) {
            throwable.printStackTrace();
        }
    };
    localRepository = new File(new File("target/localRepo").getAbsolutePath());
    localRepository.mkdirs();
    mavenServerManager.setLocalRepository(localRepository);
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier);
    mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, classpathManager, eventService, new EclipseWorkspaceProvider());
}
Also used : MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) JsonObject(com.google.gson.JsonObject) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Assert.assertNull(org.testng.Assert.assertNull) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) Mock(org.mockito.Mock) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) Test(org.testng.annotations.Test) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) AfterMethod(org.testng.annotations.AfterMethod) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) IProject(org.eclipse.core.resources.IProject) BaseTest(org.eclipse.che.plugin.maven.server.BaseTest) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) IJavaProject(org.eclipse.jdt.core.IJavaProject) JavaCore(org.eclipse.jdt.core.JavaCore) BeforeMethod(org.testng.annotations.BeforeMethod) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) Assert.assertNotNull(org.testng.Assert.assertNotNull) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) File(java.io.File) IoUtil(org.eclipse.che.commons.lang.IoUtil) IType(org.eclipse.jdt.core.IType) Provider(com.google.inject.Provider) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) List(java.util.List) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Assert.assertTrue(org.testng.Assert.assertTrue) Collections(java.util.Collections) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) Mockito.mock(org.mockito.Mockito.mock) MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) File(java.io.File) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with MessageType

use of org.eclipse.che.plugin.maven.shared.MessageType in project che by eclipse.

the class ResolvingMavenProjectStateHolder method onWsAgentStarted.

@Override
public void onWsAgentStarted(WsAgentStateEvent event) {
    wsAgentStateController.getMessageBus().then(new Operation<MessageBus>() {

        @Override
        public void apply(MessageBus messageBus) throws OperationException {
            try {
                messageBus.subscribe(MAVEN_CHANEL_NAME, new MessageHandler() {

                    @Override
                    public void onMessage(String message) {
                        Jso jso = Jso.deserialize(message);
                        int type = jso.getFieldCastedToInteger("$type");
                        MessageType messageType = MessageType.valueOf(type);
                        if (messageType == START_STOP) {
                            handleStartStop(factory.createDtoFromJson(message, StartStopNotification.class));
                        }
                    }
                });
            } catch (WebSocketException e) {
                Log.error(getClass(), e);
            }
        }
    });
}
Also used : MessageBus(org.eclipse.che.ide.websocket.MessageBus) MessageHandler(org.eclipse.che.ide.websocket.events.MessageHandler) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException) Jso(org.eclipse.che.ide.collections.Jso) StartStopNotification(org.eclipse.che.plugin.maven.shared.dto.StartStopNotification) OperationException(org.eclipse.che.api.promises.client.OperationException) MessageType(org.eclipse.che.plugin.maven.shared.MessageType)

Aggregations

MessageType (org.eclipse.che.plugin.maven.shared.MessageType)4 JsonObject (com.google.gson.JsonObject)3 Provider (com.google.inject.Provider)3 List (java.util.List)3 Set (java.util.Set)3 ProjectRegistry (org.eclipse.che.api.project.server.ProjectRegistry)3 MavenTerminal (org.eclipse.che.maven.server.MavenTerminal)3 EclipseWorkspaceProvider (org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider)3 MavenCommunication (org.eclipse.che.plugin.maven.server.core.MavenCommunication)3 MavenExecutorService (org.eclipse.che.plugin.maven.server.core.MavenExecutorService)3 MavenProjectManager (org.eclipse.che.plugin.maven.server.core.MavenProjectManager)3 MavenWorkspace (org.eclipse.che.plugin.maven.server.core.MavenWorkspace)3 ClasspathManager (org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager)3 MavenServerManagerTest (org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)3 NotificationMessage (org.eclipse.che.plugin.maven.shared.dto.NotificationMessage)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 File (java.io.File)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1