Search in sources :

Example 1 with ProjectAlreadyExistException

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);
    }
}
Also used : ProjectAlreadyExistException(org.kie.workbench.common.screens.examples.exception.ProjectAlreadyExistException) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 2 with ProjectAlreadyExistException

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());
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) ProjectAlreadyExistException(org.kie.workbench.common.screens.examples.exception.ProjectAlreadyExistException) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)2 Test (org.junit.Test)2 ProjectAlreadyExistException (org.kie.workbench.common.screens.examples.exception.ProjectAlreadyExistException)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ImportProject (org.kie.workbench.common.screens.examples.model.ImportProject)1 Path (org.uberfire.backend.vfs.Path)1