Search in sources :

Example 46 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class LibraryToolbarPresenter method onUpdateSelectedBranch.

void onUpdateSelectedBranch() {
    if (placeManager.closeAllPlacesOrNothing()) {
        Repository repository = projectContext.getActiveWorkspaceProject().map(workspaceProject -> workspaceProject.getRepository()).orElseThrow(() -> new IllegalStateException("Cannot get repository without an active workspace project"));
        projectService.call(new RemoteCallback<WorkspaceProject>() {

            @Override
            public void callback(WorkspaceProject project) {
                libraryPlaces.goToProject(project);
                setBranchSelectorVisibility();
            }
        }).resolveProject(repository.getSpace(), repository.getBranch(view.getSelectedBranch()).get());
    } else {
        setUpBranches();
    }
}
Also used : Repository(org.guvnor.structure.repositories.Repository) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) PlaceManager(org.uberfire.client.mvp.PlaceManager) WorkspaceProjectService(org.guvnor.common.services.project.service.WorkspaceProjectService) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) LibraryPlaces(org.kie.workbench.common.screens.library.client.util.LibraryPlaces) Inject(javax.inject.Inject) Caller(org.jboss.errai.common.client.api.Caller) ApplicationScoped(javax.enterprise.context.ApplicationScoped) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) UberElement(org.uberfire.client.mvp.UberElement) Command(org.uberfire.mvp.Command) Branch(org.guvnor.structure.repositories.Branch) Repository(org.guvnor.structure.repositories.Repository) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 47 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class PopulatedLibraryScreenTest method mockProject.

private WorkspaceProject mockProject(final String projectName) {
    final WorkspaceProject result = mock(WorkspaceProject.class);
    doReturn(projectName).when(result).getName();
    doReturn(mock(Module.class)).when(result).getMainModule();
    return result;
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Module(org.guvnor.common.services.project.model.Module)

Example 48 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class PopulatedLibraryScreenTest method setup.

@Before
public void setup() {
    libraryServiceCaller = new CallerMock<>(libraryService);
    libraryScreen = spy(new PopulatedLibraryScreen(view, libraryPlaces, projectDetailEvent, libraryServiceCaller, projectController, projectContext, tileWidgets, addProjectButtonPresenter));
    doReturn(true).when(projectController).canCreateProjects();
    project1 = mockProject("project1Name");
    project2 = mockProject("project2Name");
    project3 = mockProject("project3Name");
    final List<WorkspaceProject> projects = new ArrayList<>();
    projects.add(project1);
    projects.add(project2);
    projects.add(project3);
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
    when(projectContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
    final LibraryInfo libraryInfo = new LibraryInfo(projects);
    doReturn(libraryInfo).when(libraryService).getLibraryInfo(organizationalUnit);
    doReturn(mock(TileWidget.View.class)).when(tileWidget).getView();
    doReturn(tileWidget).when(tileWidgets).get();
    doReturn(mock(AddProjectButtonPresenter.View.class)).when(addProjectButtonPresenter).getView();
    libraryScreen.setup();
}
Also used : LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 49 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class ProjectScreenTestBase method createProject.

protected WorkspaceProject createProject() {
    final Path rootPath = mock(Path.class);
    doReturn("git://modulePath").when(rootPath).toURI();
    final Module module = mock(Module.class);
    doReturn("mainModuleName").when(module).getModuleName();
    doReturn("modulePath").when(module).getIdentifier();
    doReturn(rootPath).when(module).getRootPath();
    final Path pomPath = mock(Path.class);
    doReturn(pomPath).when(module).getPomXMLPath();
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final Repository repository = mock(Repository.class);
    final Path repositoryRootPath = mock(Path.class);
    doReturn(Optional.of(new Branch("master", repositoryRootPath))).when(repository).getDefaultBranch();
    doReturn("rootpath").when(repositoryRootPath).toURI();
    return new WorkspaceProject(organizationalUnit, repository, new Branch("master", mock(Path.class)), module);
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Module(org.guvnor.common.services.project.model.Module)

Example 50 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class SettingsPresenterTest method testSave.

@Test
public void testSave() {
    WorkspaceProject project = mock(WorkspaceProject.class);
    doReturn(project).when(projectScreenService).save(any(), any(), any(), any());
    final Section section1 = newMockedSection();
    final Section section2 = newMockedSection();
    doReturn(promises.resolve()).when(settingsPresenter).resetDirtyIndicator(eq(section1));
    doReturn(promises.resolve()).when(settingsPresenter).resetDirtyIndicator(eq(section2));
    settingsPresenter.sections = new ArrayList<>(Arrays.asList(section1, section2));
    settingsPresenter.save("Test comment");
    verify(section1).save(eq("Test comment"), any());
    verify(section2).save(eq("Test comment"), any());
    verify(settingsPresenter).saveProjectScreenModel(eq("Test comment"), eq(DeploymentMode.VALIDATED), any());
    verify(settingsPresenter).resetDirtyIndicator(eq(section1));
    verify(settingsPresenter).resetDirtyIndicator(eq(section2));
    verify(settingsPresenter).displaySuccessMessage();
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Section(org.kie.workbench.common.screens.library.client.settings.SettingsPresenter.Section) Test(org.junit.Test)

Aggregations

WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)67 Test (org.junit.Test)42 Branch (org.guvnor.structure.repositories.Branch)29 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)28 Repository (org.guvnor.structure.repositories.Repository)26 Path (org.uberfire.backend.vfs.Path)26 Module (org.guvnor.common.services.project.model.Module)21 ArrayList (java.util.ArrayList)12 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)12 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)10 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)9 Before (org.junit.Before)8 KieModule (org.kie.workbench.common.services.shared.project.KieModule)7 POM (org.guvnor.common.services.project.model.POM)6 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)5 ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)5 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)5 Date (java.util.Date)4 HashSet (java.util.HashSet)4 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)4