use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.
the class MavenProjectManager method fillMavenKeyMap.
private void fillMavenKeyMap(MavenProject mavenProject) {
MavenKey mavenKey = mavenProject.getMavenKey();
mavenWorkspaceCache.put(mavenKey, mavenProject.getPomFile());
keyToProjectMap.put(mavenKey, mavenProject);
}
use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.
the class MavenModelReader method fillModelByDefaults.
private void fillModelByDefaults(MavenModel model) {
model.setMavenKey(new MavenKey("unknown", "unknown", "unknown"));
final MavenKey parentKey = new MavenKey("unknown", "unknown", "unknown");
model.setParent(new MavenParent(parentKey, "../pom.xml"));
model.setPackaging("jar");
model.setModules(emptyList());
final MavenBuild build = model.getBuild();
build.setSources(singletonList(DEFAULT_SOURCE_FOLDER));
build.setTestSources(singletonList(DEFAULT_TEST_SOURCE_FOLDER));
build.setResources(singletonList(new MavenResource(DEFAULT_RESOURCES_FOLDER, false, null, Collections.emptyList(), Collections.emptyList())));
build.setTestResources(singletonList(new MavenResource(DEFAULT_TEST_RESOURCES_FOLDER, false, null, Collections.emptyList(), Collections.emptyList())));
}
use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.
the class MavenProjectManagerTest method testUpdateProject.
@Test
public void testUpdateProject() throws Exception {
when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/FirstProject/pom.xml").getFile()));
when(pom.getFullPath()).thenReturn(new Path("/FirstProject/pom.xml"));
when(project.getFullPath()).thenReturn(new Path("/FirstProject/"));
projectManager.addListener(listener);
MavenProject mavenProject = new MavenProject(project, workspace);
mavenProject.read(project, manager);
MavenKey mavenKey = mavenProject.getMavenKey();
assertThat(mavenKey).isNotNull();
projectManager.update(Collections.singletonList(project), true);
verify(listener).projectUpdated(mapArgument.capture(), any());
}
use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.
the class MavenProjectManagerTest method testUpdateMultimoduleProject.
@Test
public void testUpdateMultimoduleProject() throws Exception {
IProject testProject = mock(IProject.class);
IFile testPom = mock(IFile.class);
IProject subModuleProject = mock(IProject.class);
IFile subPom = mock(IFile.class);
IFile testFile = mock(IFile.class);
when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/pom.xml").getFile()));
when(pom.getFullPath()).thenReturn(new Path("/multimoduleProject/pom.xml"));
when(project.getFullPath()).thenReturn(new Path("/multimoduleProject/"));
when(testProject.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(testPom);
when(subModuleProject.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(subPom);
when(testProject.getFullPath()).thenReturn(new Path("/multimoduleProject/test"));
when(subModuleProject.getFullPath()).thenReturn(new Path("/multimoduleProject/subModule"));
when(testPom.getFullPath()).thenReturn(new Path("/multimoduleProject/test/pom.xml"));
when(subPom.getFullPath()).thenReturn(new Path("/multimoduleProject/subModule/pom.xml"));
when(testPom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/test/pom.xml").getFile()));
when(subPom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/subModule/pom.xml").getFile()));
when(workspaceRoot.getProject("/multimoduleProject/test")).thenReturn(testProject);
when(workspaceRoot.getProject("/multimoduleProject/subModule")).thenReturn(subModuleProject);
when(workspaceRoot.getFile(any())).thenReturn(testFile);
when(testFile.exists()).thenReturn(false);
projectManager.addListener(listener);
MavenProject mavenProject = new MavenProject(project, workspace);
mavenProject.read(project, manager);
MavenKey mavenKey = mavenProject.getMavenKey();
assertThat(mavenKey).isNotNull();
projectManager.update(Collections.singletonList(project), true);
verify(listener).projectUpdated(mapArgument.capture(), any());
}
use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.
the class MavenProjectManagerTest method testResolveProject.
@Test
public void testResolveProject() throws Exception {
when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/FirstProject/pom.xml").getFile()));
when(pom.getFullPath()).thenReturn(new Path("/FirstProject/pom.xml"));
when(project.getFullPath()).thenReturn(new Path("/FirstProject/"));
projectManager.addListener(listener);
MavenProject mavenProject = new MavenProject(project, workspace);
mavenProject.read(project, manager);
MavenKey mavenKey = mavenProject.getMavenKey();
assertThat(mavenKey).isNotNull();
projectManager.resolveMavenProject(project, mavenProject);
verify(listener).projectResolved(any(), any());
}
Aggregations