use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.
the class ExamplesServiceImplRepositoryNamesTest method setup.
@Before
public void setup() {
when(ou.getSpace()).thenReturn(space);
when(space.getName()).thenReturn("ou");
when(spaceConfigStorageRegistry.get(anyString())).thenReturn(spaceConfigStorage);
when(spaceConfigStorageRegistry.getBatch(anyString())).thenReturn(new SpaceConfigStorageRegistryImpl.SpaceStorageBatchImpl(spaceConfigStorage));
when(spaceConfigStorageRegistry.exist(anyString())).thenReturn(true);
service = spy(new ExamplesServiceImpl(ioService, repositoryFactory, moduleService, ouService, projectService, metadataService, newProjectEvent, projectScreenService, validators, spaceConfigStorageRegistry, systemFS, pathUtil, repositoryService));
when(validators.getValidators()).thenReturn(new ArrayList<>());
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1GroupId"));
}
});
when(moduleService.resolveModule(any(Path.class))).thenAnswer(new Answer<KieModule>() {
@Override
public KieModule answer(final InvocationOnMock invocationOnMock) throws Throwable {
final Path path = (Path) invocationOnMock.getArguments()[0];
final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
return module;
}
});
when(sessionInfo.getId()).thenReturn("sessionId");
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn("user");
when(configurationFactory.newConfigGroup(any(ConfigType.class), anyString(), anyString())).thenReturn(mock(ConfigGroup.class));
final ImportProject exProject1 = mock(ImportProject.class);
importProjects = Collections.singletonList(exProject1);
final GitRepository repository1 = mock(GitRepository.class);
final Path repositoryRoot = mock(Path.class);
final Path module1Root = mock(Path.class);
when(exampleOrganizationalUnit.getName()).thenReturn("ou");
when(exProject1.getName()).thenReturn("module1");
when(exProject1.getRoot()).thenReturn(module1Root);
when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot)));
final Optional<Branch> main = Optional.of(new Branch("main", PathFactory.newPath("testFile", "file:///")));
when(repository1.getDefaultBranch()).thenReturn(main);
when(repositoryRoot.toURI()).thenReturn("default:///");
when(module1Root.toURI()).thenReturn("default:///module1");
when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(ou);
final WorkspaceProject project = spy(new WorkspaceProject());
doReturn("module1").when(repository1).getAlias();
doReturn(project).when(service).importProject(eq(ou), eq(exProject1));
doReturn(repository1.getAlias()).when(project).getName();
doReturn(mock(Module.class)).when(project).getMainModule();
doReturn(ou).when(project).getOrganizationalUnit();
doReturn(project).when(projectService).resolveProject(repository1);
doReturn(project).when(projectService).resolveProject(any(Path.class));
final ProjectScreenModel model = new ProjectScreenModel();
model.setPOM(new POM());
doReturn(model).when(projectScreenService).load(any());
}
use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.
the class ExampleImportPresenterTest method filterProjectsTest.
@Test
public void filterProjectsTest() {
doReturn(false).when(libraryService).isClustered();
doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(0, ParameterizedCommand.class).execute(importProjectsPreferences);
return null;
}).when(importProjectsPreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
Set<ImportProject> projects = getImportProjects();
doReturn(projects).when(examplesService).getExampleProjects(any());
Map<String, String> params = new HashMap<>();
params.put("repositoryUrl", "repoUrl");
importPresenter.onStartup(new DefaultPlaceRequest(LibraryPlaces.PROJECT_SCREEN, params));
final List<ExampleProjectWidget> filteredProjects = importPresenter.filterProjects("a");
assertEquals(2, filteredProjects.size());
}
use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.
the class ExampleImportPresenterTest method selectProjectWithMultipleProjectSelectionDisabledTest.
@Test
public void selectProjectWithMultipleProjectSelectionDisabledTest() {
final Set<ImportProject> importProjects = getImportProjects();
importPresenter.setupProjects(importProjects);
importPresenter.setMultipleProjectSelectionEnabled(false);
final List<ImportProject> importProjectsList = new ArrayList<>(importProjects);
final ImportProject project1 = importProjectsList.get(0);
final ExampleProjectWidget project1Widget = importPresenter.getProjectWidgetsByProject().get(project1);
final ImportProject project2 = importProjectsList.get(1);
final ExampleProjectWidget project2Widget = importPresenter.getProjectWidgetsByProject().get(project2);
final ImportProject project3 = importProjectsList.get(2);
final ExampleProjectWidget project3Widget = importPresenter.getProjectWidgetsByProject().get(project3);
importPresenter.selectProject(project1Widget);
verify(project1Widget).select();
verify(project1Widget, never()).unselect();
verify(project2Widget, never()).select();
verify(project2Widget).unselect();
verify(project3Widget, never()).select();
verify(project3Widget).unselect();
}
use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.
the class ExampleImportPresenterTest method getImportProjects.
private Set<ImportProject> getImportProjects() {
Set<ImportProject> projects = new HashSet<>();
projects.add(new ImportProject(mock(Path.class), "p1a", "p1a description", "git@git.com", null));
projects.add(new ImportProject(mock(Path.class), "p3b", "p3b description", "git@git.com", null));
projects.add(new ImportProject(mock(Path.class), "p2a", "p2a description", "git@git.com", null));
return projects;
}
use of org.kie.workbench.common.screens.examples.model.ImportProject in project kie-wb-common by kiegroup.
the class BranchSelectorPopUpPresenterTest method setupWithoutMasterSelectedTest.
@Test
public void setupWithoutMasterSelectedTest() {
final ImportProject importProject = mock(ImportProject.class);
final List<String> branches = new ArrayList<>();
branches.add("branch1");
doReturn(branches).when(importProject).getSelectedBranches();
final HTMLElement branchSelectorContainer = mock(HTMLElement.class);
doReturn(branchSelectorContainer).when(view).getBranchSelectorContainer();
presenter.setup(importProject, mock(Consumer.class));
verify(view).init(presenter);
verify(branchSelector).setup(same(branchSelectorContainer), any(), eq(Arrays.asList("branch1", "master")), any());
verify(view).show();
verify(presenter.branchesSelectedCallback, never()).accept(anyList());
}
Aggregations