use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class ImportPresenter method ok.
public void ok() {
final List<ExampleProject> projects = projectWidgetsByName.entrySet().stream().filter(p -> p.getValue().isSelected()).map(Map.Entry::getKey).collect(Collectors.toList());
if (projects.isEmpty()) {
notificationEvent.fire(new NotificationEvent(view.getNoProjectsSelectedMessage(), NotificationEvent.NotificationType.ERROR));
return;
}
view.showBusyIndicator(view.getImportingMessage());
importProjects(projects, event -> {
view.hideBusyIndicator();
notificationEvent.fire(new NotificationEvent(view.getImportProjectsSuccessMessage(), NotificationEvent.NotificationType.SUCCESS));
projectContextChangeEvent.fire(event);
}, new HasBusyIndicatorDefaultErrorCallback(view));
}
use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class ExamplesServiceImplRepositoryNamesTest method setup.
@Before
public void setup() {
service = spy(new ExamplesServiceImpl(ioService, configurationFactory, repositoryFactory, moduleService, repositoryService, repositoryCopier, ouService, projectService, metadataService, spaces, newProjectEvent, projectScreenService));
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1Owner", "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 ExampleProject exProject1 = mock(ExampleProject.class);
exampleProjects = new ArrayList<ExampleProject>() {
{
add(exProject1);
}
};
final OrganizationalUnit ou = mock(OrganizationalUnit.class);
doReturn("ou").when(ou).getName();
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> master = Optional.of(new Branch("master", PathFactory.newPath("testFile", "file:///")));
when(repository1.getDefaultBranch()).thenReturn(master);
when(repositoryRoot.toURI()).thenReturn("default:///");
when(module1Root.toURI()).thenReturn("default:///module1");
when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(ou);
doReturn("module1").when(repository1).getAlias();
doReturn(repository1).when(repositoryCopier).copy(eq(ou), anyString(), eq(module1Root));
final WorkspaceProject project = spy(new WorkspaceProject());
doReturn(repository1.getAlias()).when(project).getName();
doReturn(mock(Module.class)).when(project).getMainModule();
doReturn(mock(OrganizationalUnit.class)).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.ExampleProject in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testGetProjects_EmptyRepositoryUrl.
@Test
public void testGetProjects_EmptyRepositoryUrl() {
final Set<ExampleProject> modules = service.getProjects(new ExampleRepository(""));
assertNotNull(modules);
assertEquals(0, modules.size());
}
use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testGetProjects_CustomDescription.
@Test
public void testGetProjects_CustomDescription() {
final Path moduleRoot = mock(Path.class);
final KieModule module = mock(KieModule.class);
when(module.getRootPath()).thenReturn(moduleRoot);
when(module.getModuleName()).thenReturn("module1");
when(moduleRoot.toURI()).thenReturn("default:///module1");
when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);
when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("This is custom description.\n\n This is a new line.");
when(metadataService.getTags(any(Path.class))).thenReturn(Arrays.asList("tag1", "tag2"));
final GitRepository repository = makeGitRepository();
when(repositoryFactory.newRepository(any(ConfigGroup.class))).thenReturn(repository);
when(moduleService.getAllModules(any(Branch.class))).thenReturn(new HashSet<Module>() {
{
add(module);
}
});
final Set<ExampleProject> modules = service.getProjects(new ExampleRepository("https://github.com/guvnorngtestuser1/guvnorng-playground.git"));
assertNotNull(modules);
assertEquals(1, modules.size());
assertTrue(modules.contains(new ExampleProject(moduleRoot, "module1", "This is custom description. This is a new line.", Arrays.asList("tag1", "tag2"))));
}
use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testGetProjects_WhiteSpaceRepositoryUrl.
@Test
public void testGetProjects_WhiteSpaceRepositoryUrl() {
final Set<ExampleProject> modules = service.getProjects(new ExampleRepository(" "));
assertNotNull(modules);
assertEquals(0, modules.size());
}
Aggregations