Search in sources :

Example 6 with ProjectHandlerRegistry

use of org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry in project che by eclipse.

the class JavaDebuggerTest method initProjectApi.

@BeforeClass
protected void initProjectApi() throws Exception {
    TestWorkspaceHolder workspaceHolder = new TestWorkspaceHolder(new ArrayList<>());
    File root = new File("target/test-classes/workspace");
    assertTrue(root.exists());
    File indexDir = new File("target/fs_index");
    assertTrue(indexDir.mkdirs());
    Set<PathMatcher> filters = new HashSet<>();
    filters.add(path -> true);
    FSLuceneSearcherProvider sProvider = new FSLuceneSearcherProvider(indexDir, filters);
    EventService eventService = new EventService();
    LocalVirtualFileSystemProvider vfsProvider = new LocalVirtualFileSystemProvider(root, sProvider);
    ProjectTypeRegistry projectTypeRegistry = new ProjectTypeRegistry(new HashSet<>());
    projectTypeRegistry.registerProjectType(new JavaProjectType(new JavaValueProviderFactory()));
    ProjectHandlerRegistry projectHandlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
    ProjectRegistry projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, projectTypeRegistry, projectHandlerRegistry, eventService);
    projectRegistry.initProjects();
    ProjectImporterRegistry importerRegistry = new ProjectImporterRegistry(new HashSet<>());
    FileWatcherNotificationHandler fileWatcherNotificationHandler = new DefaultFileWatcherNotificationHandler(vfsProvider);
    FileTreeWatcher fileTreeWatcher = new FileTreeWatcher(root, new HashSet<>(), fileWatcherNotificationHandler);
    ProjectManager projectManager = new ProjectManager(vfsProvider, projectTypeRegistry, projectRegistry, projectHandlerRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, workspaceHolder, mock(FileWatcherManager.class));
    ResourcesPlugin resourcesPlugin = new ResourcesPlugin("target/index", root.getAbsolutePath(), () -> projectRegistry, () -> projectManager);
    resourcesPlugin.start();
    JavaPlugin javaPlugin = new JavaPlugin(root.getAbsolutePath() + "/.settings", resourcesPlugin, projectRegistry);
    javaPlugin.start();
    projectRegistry.setProjectType("test", "java", false);
    JavaModelManager.getDeltaState().initializeRoots(true);
    events = new ArrayBlockingQueue<>(10);
    Map<String, String> connectionProperties = ImmutableMap.of("host", "localhost", "port", System.getProperty("debug.port"));
    JavaDebuggerFactory factory = new JavaDebuggerFactory();
    debugger = factory.create(connectionProperties, events::add);
}
Also used : ProjectTypeRegistry(org.eclipse.che.api.project.server.type.ProjectTypeRegistry) FileWatcherNotificationHandler(org.eclipse.che.api.vfs.impl.file.FileWatcherNotificationHandler) DefaultFileWatcherNotificationHandler(org.eclipse.che.api.vfs.impl.file.DefaultFileWatcherNotificationHandler) ProjectImporterRegistry(org.eclipse.che.api.project.server.importer.ProjectImporterRegistry) JavaPlugin(org.eclipse.jdt.internal.ui.JavaPlugin) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) JavaProjectType(org.eclipse.che.plugin.java.server.projecttype.JavaProjectType) HashSet(java.util.HashSet) ProjectHandlerRegistry(org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry) JavaValueProviderFactory(org.eclipse.che.plugin.java.server.projecttype.JavaValueProviderFactory) LocalVirtualFileSystemProvider(org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider) EventService(org.eclipse.che.api.core.notification.EventService) ProjectManager(org.eclipse.che.api.project.server.ProjectManager) FileWatcherManager(org.eclipse.che.api.vfs.watcher.FileWatcherManager) PathMatcher(java.nio.file.PathMatcher) DefaultFileWatcherNotificationHandler(org.eclipse.che.api.vfs.impl.file.DefaultFileWatcherNotificationHandler) FileTreeWatcher(org.eclipse.che.api.vfs.impl.file.FileTreeWatcher) File(java.io.File) FSLuceneSearcherProvider(org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider) BeforeClass(org.testng.annotations.BeforeClass)

Example 7 with ProjectHandlerRegistry

use of org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry 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)

Aggregations

ProjectHandlerRegistry (org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry)7 ProjectTypeRegistry (org.eclipse.che.api.project.server.type.ProjectTypeRegistry)7 File (java.io.File)6 HashSet (java.util.HashSet)6 PathMatcher (java.nio.file.PathMatcher)5 EventService (org.eclipse.che.api.core.notification.EventService)5 ProjectImporterRegistry (org.eclipse.che.api.project.server.importer.ProjectImporterRegistry)5 DefaultFileWatcherNotificationHandler (org.eclipse.che.api.vfs.impl.file.DefaultFileWatcherNotificationHandler)5 FileTreeWatcher (org.eclipse.che.api.vfs.impl.file.FileTreeWatcher)5 LocalVirtualFileSystemProvider (org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider)5 FSLuceneSearcherProvider (org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider)5 ProjectManager (org.eclipse.che.api.project.server.ProjectManager)3 ProjectRegistry (org.eclipse.che.api.project.server.ProjectRegistry)3 FileWatcherNotificationHandler (org.eclipse.che.api.vfs.impl.file.FileWatcherNotificationHandler)3 JavaProjectType (org.eclipse.che.plugin.java.server.projecttype.JavaProjectType)3 JavaValueProviderFactory (org.eclipse.che.plugin.java.server.projecttype.JavaValueProviderFactory)3 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)3 ProjectTypeDef (org.eclipse.che.api.project.server.type.ProjectTypeDef)2 FileWatcherManager (org.eclipse.che.api.vfs.watcher.FileWatcherManager)2 JavaPlugin (org.eclipse.jdt.internal.ui.JavaPlugin)2