use of org.kie.workbench.common.screens.examples.exception.ProjectAlreadyExistException in project kie-wb-common by kiegroup.
the class ExamplesServiceImplRepositoryNamesTest method nameIsTaken.
@Test
public void nameIsTaken() {
String module1 = "module1";
String module1_1 = "module1 [1]";
doCallRealMethod().when(service).importProject(any(), any());
WorkspaceProject project1 = mock(WorkspaceProject.class);
doReturn(module1).when(project1).getName();
List<WorkspaceProject> projects = new ArrayList<>();
projects.add(project1);
projects.add(project1);
doReturn(projects).when(projectService).getAllWorkspaceProjectsByName(any(), eq(module1));
doReturn(module1_1).when(projectService).createFreshProjectName(any(), eq(module1));
try {
service.setupExamples(exampleOrganizationalUnit, importProjects);
fail("Should raise exception");
} catch (ProjectAlreadyExistException ex) {
assertNotNull(ex);
}
}
use of org.kie.workbench.common.screens.examples.exception.ProjectAlreadyExistException in project kie-wb-common by kiegroup.
the class ProjectImportServiceImplRepositoryNamesTest method nameIsTaken.
@Test
public void nameIsTaken() {
String module1 = "module1";
String module1_1 = "module1 [1]";
doCallRealMethod().when(service).importProject(any(), any());
doReturn(mock(org.uberfire.java.nio.file.Path.class)).when(service).getProjectRoot(any(ImportProject.class));
doReturn(mock(org.uberfire.java.nio.file.Path.class)).when(pathUtil).convert(any(Path.class));
WorkspaceProject project1 = mock(WorkspaceProject.class, Answers.RETURNS_DEEP_STUBS.get());
doReturn(module1).when(project1).getName();
when(project1.getMainModule().getPomXMLPath()).thenReturn(mock(Path.class));
List<WorkspaceProject> projects = new ArrayList<>();
projects.add(project1);
projects.add(project1);
doReturn(projects).when(projectService).getAllWorkspaceProjectsByName(any(), eq(module1));
doReturn(module1_1).when(projectService).createFreshProjectName(any(), eq(module1));
try {
service.importProjects(organizationalUnit, importProjects);
fail("An exception should be rise");
} catch (ProjectAlreadyExistException ex) {
assertNotNull(ex);
System.out.println(ex.getMessage());
}
}
Aggregations