Search in sources :

Example 11 with ProjectTypeRegistry

use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry in project che by eclipse.

the class ProjectTypesTest method testGetMixinsShouldReturnProjectTypeConstraintException.

//@Test(expectedExceptions = ProjectTypeConstraintException.class)
public void testGetMixinsShouldReturnProjectTypeConstraintException() throws Exception {
    String otherPrimaryId = generate("projectType-", 3);
    Set<ProjectTypeDef> pts = new HashSet<>();
    pts.add(new PrimaryType());
    pts.add(new PrimaryType(otherPrimaryId, generate("projectType-", 5)));
    pts.add(new PersistedMixin());
    ProjectTypeRegistry reg = new ProjectTypeRegistry(pts);
    List<RegisteredProject.Problem> problems = new ArrayList<>();
    new ProjectTypes(generate("projectPath-", 5), PrimaryType.PRIMARY_ID, Arrays.asList(PersistedMixin.PERSISTED_MIXIN_ID, otherPrimaryId), reg, problems);
    assertEquals(problems.size(), 1);
    assertEquals(problems.get(0).code, 12);
}
Also used : ProjectTypeRegistry(org.eclipse.che.api.project.server.type.ProjectTypeRegistry) ArrayList(java.util.ArrayList) ProjectTypeDef(org.eclipse.che.api.project.server.type.ProjectTypeDef) HashSet(java.util.HashSet)

Example 12 with ProjectTypeRegistry

use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry in project che by eclipse.

the class ProjectTypesTest method testGetMixins.

@Test
public void testGetMixins() throws Exception {
    Set<ProjectTypeDef> pts = new HashSet<>();
    pts.add(new PrimaryType());
    pts.add(new PersistedMixin());
    ProjectTypeRegistry reg = new ProjectTypeRegistry(pts);
    List<RegisteredProject.Problem> problems = new ArrayList<>();
    ProjectTypes projectTypes = new ProjectTypes(generate("projectPath-", 5), PrimaryType.PRIMARY_ID, Collections.singletonList(PersistedMixin.PERSISTED_MIXIN_ID), reg, problems);
    assertNotNull(projectTypes.getMixins());
    assertEquals(projectTypes.getMixins().size(), 1);
    assertTrue(projectTypes.getMixins().containsKey(PersistedMixin.PERSISTED_MIXIN_ID));
}
Also used : ProjectTypeRegistry(org.eclipse.che.api.project.server.type.ProjectTypeRegistry) ArrayList(java.util.ArrayList) ProjectTypeDef(org.eclipse.che.api.project.server.type.ProjectTypeDef) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 13 with ProjectTypeRegistry

use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry in project che by eclipse.

the class MavenProjectTypeTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    Set<ProjectTypeDef> projTypes = new HashSet<>();
    projTypes.add(new JavaProjectType(new JavaValueProviderFactory()));
    projTypes.add(new MavenProjectType(new MavenValueProviderFactory()));
    ptRegistry = new ProjectTypeRegistry(projTypes);
    Set<ProjectHandler> handlers = new HashSet<>();
    handlers.add(new MavenProjectGenerator(Collections.<GeneratorStrategy>emptySet()));
    httpJsonRequest = mock(HttpJsonRequest.class, new SelfReturningAnswer());
}
Also used : ProjectTypeRegistry(org.eclipse.che.api.project.server.type.ProjectTypeRegistry) HttpJsonRequest(org.eclipse.che.api.core.rest.HttpJsonRequest) JavaValueProviderFactory(org.eclipse.che.plugin.java.server.projecttype.JavaValueProviderFactory) ProjectTypeDef(org.eclipse.che.api.project.server.type.ProjectTypeDef) ProjectHandler(org.eclipse.che.api.project.server.handlers.ProjectHandler) GeneratorStrategy(org.eclipse.che.plugin.maven.server.projecttype.handler.GeneratorStrategy) SelfReturningAnswer(org.eclipse.che.commons.test.mockito.answer.SelfReturningAnswer) MavenProjectGenerator(org.eclipse.che.plugin.maven.server.projecttype.handler.MavenProjectGenerator) JavaProjectType(org.eclipse.che.plugin.java.server.projecttype.JavaProjectType) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 14 with ProjectTypeRegistry

use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry 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

ProjectTypeRegistry (org.eclipse.che.api.project.server.type.ProjectTypeRegistry)14 HashSet (java.util.HashSet)11 File (java.io.File)8 ProjectHandlerRegistry (org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry)7 ProjectTypeDef (org.eclipse.che.api.project.server.type.ProjectTypeDef)7 ArrayList (java.util.ArrayList)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 JavaProjectType (org.eclipse.che.plugin.java.server.projecttype.JavaProjectType)4 JavaValueProviderFactory (org.eclipse.che.plugin.java.server.projecttype.JavaValueProviderFactory)4 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 Before (org.junit.Before)3 ProjectConfig (org.eclipse.che.api.core.model.project.ProjectConfig)2