Search in sources :

Example 21 with VirtualFileEntry

use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.

the class MavenProjectTypeTest method testMavenProject.

@Test
public void testMavenProject() throws Exception {
    WorkspaceDto usersWorkspaceMock = mock(WorkspaceDto.class);
    WorkspaceConfigDto workspaceConfigMock = mock(WorkspaceConfigDto.class);
    when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class).withMethod("GET").withHref("/workspace/")))).thenReturn(httpJsonRequest);
    when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class).withMethod("PUT").withHref("/workspace/" + "/project")))).thenReturn(httpJsonRequest);
    when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
    when(httpJsonResponse.asDto(WorkspaceDto.class)).thenReturn(usersWorkspaceMock);
    final ProjectConfigDto projectConfig = DtoFactory.getInstance().createDto(ProjectConfigDto.class).withName("project").withPath("/myProject").withType(MavenAttributes.MAVEN_ID);
    when(usersWorkspaceMock.getConfig()).thenReturn(workspaceConfigMock);
    when(workspaceConfigMock.getProjects()).thenReturn(Collections.singletonList(projectConfig));
    Map<String, List<String>> attributes = new HashMap<>();
    attributes.put(MavenAttributes.ARTIFACT_ID, Collections.singletonList("myartifact"));
    attributes.put(MavenAttributes.GROUP_ID, Collections.singletonList("mygroup"));
    attributes.put(MavenAttributes.VERSION, Collections.singletonList("1.0"));
    attributes.put(MavenAttributes.PACKAGING, Collections.singletonList("jar"));
    RegisteredProject project = pm.createProject(DtoFactory.getInstance().createDto(ProjectConfigDto.class).withType("maven").withAttributes(attributes).withPath("/myProject").withName("myProject"), new HashMap<>(0));
    for (VirtualFileEntry file : project.getBaseFolder().getChildren()) {
        if (file.getName().equals("pom.xml")) {
            Model pom = Model.readFrom(file.getVirtualFile().getContent());
            Assert.assertEquals(pom.getVersion(), "1.0");
        }
    }
}
Also used : HashMap(java.util.HashMap) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) Model(org.eclipse.che.ide.maven.tools.Model) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) List(java.util.List) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) Test(org.junit.Test)

Aggregations

VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)21 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)11 ServerException (org.eclipse.che.api.core.ServerException)9 Problem (org.eclipse.che.ide.ext.java.shared.dto.Problem)7 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)6 MavenServerService (org.eclipse.che.plugin.maven.server.rest.MavenServerService)6 MavenServerManagerTest (org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)6 Test (org.testng.annotations.Test)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)5 IProject (org.eclipse.core.resources.IProject)5 ConflictException (org.eclipse.che.api.core.ConflictException)4 FileEntry (org.eclipse.che.api.project.server.FileEntry)3 RegisteredProject (org.eclipse.che.api.project.server.RegisteredProject)3 IResourceStatus (org.eclipse.core.resources.IResourceStatus)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 MultiStatus (org.eclipse.core.runtime.MultiStatus)3 Status (org.eclipse.core.runtime.Status)3 HashMap (java.util.HashMap)2 List (java.util.List)2