Search in sources :

Example 6 with EventService

use of org.eclipse.che.api.core.notification.EventService in project che by eclipse.

the class MachineProcessManagerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    final EventService eventService = mock(EventService.class);
    final String machineLogsDir = targetDir().resolve("logs-dir").toString();
    IoUtil.deleteRecursive(new File(machineLogsDir));
    manager = spy(new MachineProcessManager(machineLogsDir, eventService, environmentEngine));
    EnvironmentContext envCont = new EnvironmentContext();
    envCont.setSubject(CREATOR);
    EnvironmentContext.setCurrent(envCont);
    doReturn(logConsumer).when(manager).getProcessLogger(MACHINE_ID, 111, "outputChannel");
    when(command.getCommandLine()).thenReturn("CommandLine");
    when(command.getName()).thenReturn("CommandName");
    when(command.getType()).thenReturn("CommandType");
    when(instance.createProcess(command, "outputChannel")).thenReturn(instanceProcess);
    when(instanceProcess.getPid()).thenReturn(111);
    when(environmentEngine.getMachine(WORKSPACE_ID, MACHINE_ID)).thenReturn(instance);
}
Also used : EnvironmentContext(org.eclipse.che.commons.env.EnvironmentContext) EventService(org.eclipse.che.api.core.notification.EventService) File(java.io.File) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with EventService

use of org.eclipse.che.api.core.notification.EventService in project che by eclipse.

the class SimpleGeneratorStrategyTest method prepareProject.

private void prepareProject() throws Exception {
    final String vfsUser = "dev";
    Set<ProjectTypeDef> pts = new HashSet<>();
    final ProjectTypeDef pt = new ProjectTypeDef("mytype", "mytype type", true, false) {
    };
    pts.add(pt);
    final ProjectTypeRegistry projectTypeRegistry = new ProjectTypeRegistry(pts);
    final EventService eventService = new EventService();
    //        final VirtualFileSystemRegistry vfsRegistry = new VirtualFileSystemRegistry();
    //        final MemoryFileSystemProvider memoryFileSystemProvider =
    //                new MemoryFileSystemProvider(workspace,
    //                                             eventService,
    //                                             new VirtualFileSystemUserContext() {
    //                    @Override
    //                    public VirtualFileSystemUser getVirtualFileSystemUser() {
    //                        return new VirtualFileSystemUser(vfsUser, vfsUserGroups);
    //                    }
    //                },
    //                                             vfsRegistry,
    //                                             SystemPathsFilter.ANY);
    //        vfsRegistry.registerProvider(workspace, memoryFileSystemProvider);
    WorkspaceDto usersWorkspaceMock = mock(WorkspaceDto.class);
    final ProjectConfigDto projectConfigDto = DtoFactory.getInstance().createDto(ProjectConfigDto.class).withPath("/my_project");
    WorkspaceConfigDto workspaceConfigMock = mock(WorkspaceConfigDto.class);
    when(usersWorkspaceMock.getConfig()).thenReturn(workspaceConfigMock);
    when(workspaceConfigMock.getProjects()).thenReturn(Collections.singletonList(projectConfigDto));
    ProjectHandlerRegistry handlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
    //        pm = new ProjectManager(vfsRegistry,
    //                                       eventService,
    //                                       projectTypeRegistry,
    //                                       handlerRegistry,
    //                                       filterProvider,
    //                                       API_ENDPOINT,
    //                                       httpJsonRequestFactory);
    //        HttpJsonRequest httpJsonRequest = mock(HttpJsonRequest.class, new SelfReturningAnswer());
    //        when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class)
    //                                                          .withMethod("PUT")
    //                                                          .withHref(API_ENDPOINT + "/workspace/" + workspace + "/project"))))
    //                .thenReturn(httpJsonRequest);
    //        when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class)
    //                                                          .withMethod("GET")
    //                                                          .withHref(API_ENDPOINT + "/workspace/" + workspace))))
    //                .thenReturn(httpJsonRequest);
    //        when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
    when(httpJsonResponse.asDto(WorkspaceDto.class)).thenReturn(usersWorkspaceMock);
    pm.createProject(DtoFactory.getInstance().createDto(ProjectConfigDto.class).withType(pt.getId()).withName("my_project").withPath("/my_project"), null);
}
Also used : ProjectTypeRegistry(org.eclipse.che.api.project.server.type.ProjectTypeRegistry) ProjectHandlerRegistry(org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) ProjectTypeDef(org.eclipse.che.api.project.server.type.ProjectTypeDef) EventService(org.eclipse.che.api.core.notification.EventService) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) HashSet(java.util.HashSet)

Example 8 with EventService

use of org.eclipse.che.api.core.notification.EventService in project che by eclipse.

the class CascadeRemovalTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    server = H2DBTestServer.startDefault();
    injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {

        @Override
        protected void configure() {
            install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, ProfileImpl.class, PreferenceEntity.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, EnvironmentRecipeImpl.class, ExtendedMachineImpl.class, SourceStorageImpl.class, ServerConf2Impl.class, StackImpl.class, CommandImpl.class, SnapshotImpl.class, RecipeImpl.class, SshPairImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").setExceptionHandler(H2ExceptionHandler.class).build());
            bind(EventService.class).in(Singleton.class);
            install(new InitModule(PostConstruct.class));
            bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
            bind(DBInitializer.class).asEagerSingleton();
            install(new UserJpaModule());
            install(new AccountModule());
            install(new SshJpaModule());
            install(new WorkspaceJpaModule());
            install(new MachineJpaModule());
            bind(WorkspaceManager.class);
            final WorkspaceRuntimes wR = mock(WorkspaceRuntimes.class);
            when(wR.hasRuntime(anyString())).thenReturn(false);
            bind(WorkspaceRuntimes.class).toInstance(wR);
            bind(AccountManager.class);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_snapshot")).toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_restore")).toInstance(false);
            bind(WorkspaceSharedPool.class).toInstance(new WorkspaceSharedPool("cached", null, null));
        }
    });
    eventService = injector.getInstance(EventService.class);
    accountDao = injector.getInstance(AccountDao.class);
    userDao = injector.getInstance(UserDao.class);
    preferenceDao = injector.getInstance(PreferenceDao.class);
    profileDao = injector.getInstance(ProfileDao.class);
    sshDao = injector.getInstance(SshDao.class);
    snapshotDao = injector.getInstance(SnapshotDao.class);
    workspaceDao = injector.getInstance(WorkspaceDao.class);
}
Also used : EventService(org.eclipse.che.api.core.notification.EventService) UserJpaModule(org.eclipse.che.api.user.server.jpa.UserJpaModule) AccountDao(org.eclipse.che.account.spi.AccountDao) PreferenceDao(org.eclipse.che.api.user.server.spi.PreferenceDao) InitModule(org.eclipse.che.inject.lifecycle.InitModule) SshDao(org.eclipse.che.api.ssh.server.spi.SshDao) AbstractModule(com.google.inject.AbstractModule) WorkspaceSharedPool(org.eclipse.che.api.workspace.server.WorkspaceSharedPool) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) ProfileDao(org.eclipse.che.api.user.server.spi.ProfileDao) SnapshotDao(org.eclipse.che.api.machine.server.spi.SnapshotDao) UserDao(org.eclipse.che.api.user.server.spi.UserDao) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountModule(org.eclipse.che.account.api.AccountModule) MachineJpaModule(org.eclipse.che.api.machine.server.jpa.MachineJpaModule) WorkspaceRuntimes(org.eclipse.che.api.workspace.server.WorkspaceRuntimes) SshJpaModule(org.eclipse.che.api.ssh.server.jpa.SshJpaModule) PostConstruct(javax.annotation.PostConstruct) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao) WorkspaceJpaModule(org.eclipse.che.api.workspace.server.jpa.WorkspaceJpaModule) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

EventService (org.eclipse.che.api.core.notification.EventService)8 File (java.io.File)5 HashSet (java.util.HashSet)5 ProjectHandlerRegistry (org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry)5 ProjectTypeRegistry (org.eclipse.che.api.project.server.type.ProjectTypeRegistry)5 PathMatcher (java.nio.file.PathMatcher)4 ProjectImporterRegistry (org.eclipse.che.api.project.server.importer.ProjectImporterRegistry)4 DefaultFileWatcherNotificationHandler (org.eclipse.che.api.vfs.impl.file.DefaultFileWatcherNotificationHandler)4 FileTreeWatcher (org.eclipse.che.api.vfs.impl.file.FileTreeWatcher)4 LocalVirtualFileSystemProvider (org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider)4 FSLuceneSearcherProvider (org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider)4 BeforeMethod (org.testng.annotations.BeforeMethod)3 ProjectTypeDef (org.eclipse.che.api.project.server.type.ProjectTypeDef)2 FileWatcherNotificationHandler (org.eclipse.che.api.vfs.impl.file.FileWatcherNotificationHandler)2 AbstractModule (com.google.inject.AbstractModule)1 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Collections.emptyList (java.util.Collections.emptyList)1