use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class ProjectPageTest method initExampleProjects.
private void initExampleProjects() {
when(examplesService.getProjects(any(ExampleRepository.class))).thenReturn(new HashSet<ExampleProject>() {
{
add(project1);
add(project2);
}
});
final ExampleRepository repository = new ExampleRepository(EXAMPLE_REPOSITORY);
model.setSelectedRepository(repository);
page.prepareView();
Mockito.reset(projectsView, pageSelectedEvent);
}
use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class ProjectPageTest method testRemoveProject.
@Test
public void testRemoveProject() {
final ExampleProject project = mock(ExampleProject.class);
model.addProject(project);
page.removeProject(project);
assertEquals(0, model.getProjects().size());
verify(pageStatusChangedEvent, times(1)).fire(any(WizardPageStatusChangeEvent.class));
}
use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class ProjectPageTest method testPrepareView_NewRepositorySelected.
@Test
public void testPrepareView_NewRepositorySelected() {
when(examplesService.getProjects(any(ExampleRepository.class))).thenReturn(new HashSet<ExampleProject>() {
{
add(project1);
add(project2);
}
});
final ExampleRepository repository = new ExampleRepository(EXAMPLE_REPOSITORY);
model.setSelectedRepository(repository);
page.prepareView();
assertEquals(projectsViewWidget, page.asWidget());
assertEquals(repository, model.getSourceRepository());
assertTrue(model.getProjects().isEmpty());
verify(projectsView, times(1)).setProjectsInRepository(projectsArgumentCaptor.capture());
final List<ExampleProject> sortedProjects = projectsArgumentCaptor.getValue();
assertNotNull(sortedProjects);
assertEquals(2, sortedProjects.size());
assertEquals("project1", sortedProjects.get(0).getName());
assertEquals("project2", sortedProjects.get(1).getName());
verify(pageSelectedEvent, times(1)).fire(any(WizardPageSelectedEvent.class));
}
use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method importProjectFromExampleTest.
@Test
public void importProjectFromExampleTest() {
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
final ExampleProject exampleProject = mock(ExampleProject.class);
final WorkspaceProject project = mock(WorkspaceProject.class);
final Module module = mock(Module.class);
doReturn(module).when(project).getMainModule();
final WorkspaceProjectContextChangeEvent projectContextChangeEvent = mock(WorkspaceProjectContextChangeEvent.class);
doReturn(project).when(projectContextChangeEvent).getWorkspaceProject();
doReturn(projectContextChangeEvent).when(examplesService).setupExamples(any(ExampleOrganizationalUnit.class), anyList());
final WorkspaceProject importedProject = libraryService.importProject(organizationalUnit, exampleProject);
assertEquals(module, importedProject.getMainModule());
}
use of org.kie.workbench.common.screens.examples.model.ExampleProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method getDefaultExampleProjectsTest.
@Test
public void getDefaultExampleProjectsTest() {
System.setProperty("org.kie.project.examples.repository.url", "");
final ExampleRepository playgroundRepository = new ExampleRepository("playgroundRepositoryUrl");
doReturn(playgroundRepository).when(examplesService).getPlaygroundRepository();
final Set<ExampleProject> exampleProjects = new HashSet<>();
exampleProjects.add(mock(ExampleProject.class));
doReturn(exampleProjects).when(examplesService).getProjects(playgroundRepository);
final Set<ExampleProject> loadedExampleProjects = libraryService.getExampleProjects();
assertEquals(exampleProjects, loadedExampleProjects);
}
Aggregations