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");
}
}
}
Aggregations