Search in sources :

Example 1 with WorkspaceProject

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

the class KieMultipleDocumentEditorTest method testOnRepositoryRemoved.

@Test
public void testOnRepositoryRemoved() {
    final Repository repository = mock(Repository.class);
    when(workbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mock(Module.class))));
    editor.setupMenuBar();
    editor.onRepositoryRemoved(new RepositoryRemovedEvent(repository));
    verify(editor, times(1)).enableMenus(eq(false));
    verify(editor, times(4)).enableMenuItem(eq(false), any(MenuItems.class));
    verify(saveMenuItem, times(1)).setEnabled(eq(false));
    verify(versionManagerMenuItem, times(1)).setEnabled(eq(false));
}
Also used : Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Branch(org.guvnor.structure.repositories.Branch) MenuItems(org.uberfire.ext.editor.commons.client.menu.MenuItems) Module(org.guvnor.common.services.project.model.Module) RepositoryRemovedEvent(org.guvnor.structure.repositories.RepositoryRemovedEvent) Test(org.junit.Test)

Example 2 with WorkspaceProject

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

the class ProjectScreenTest method setUp.

@Before
public void setUp() {
    projectScreenServiceCaller = new CallerMock<>(projectScreenService);
    promises = spy(new SyncPromises());
    when(assetsScreen.getView()).thenReturn(assetsView);
    when(viewHideAlertsButtonPresenter.getView()).thenReturn(viewHideAlertsButtonView);
    when(editContributorsPopUpPresenterInstance.get()).thenReturn(editContributorsPopUpPresenter);
    when(deleteProjectPopUpScreenInstance.get()).thenReturn(deleteProjectPopUpScreen);
    when(renameProjectPopUpScreenInstance.get()).thenReturn(renameProjectPopUpScreen);
    final WorkspaceProject workspaceProject = mock(WorkspaceProject.class);
    final Module module = mock(Module.class);
    when(module.getModuleName()).thenReturn("module-name");
    when(workspaceProject.getMainModule()).thenReturn(module);
    when(libraryPlaces.getActiveWorkspaceContext()).thenReturn(workspaceProject);
    this.presenter = spy(new ProjectScreen(this.view, this.libraryPlaces, this.emptyAssetsScree, this.assetsScreen, this.contributorsListScreen, this.projectMetrictsScreen, this.projectController, this.settingsPresenter, this.organizationalUnitController, this.newFileUploader, this.newResourcePresenter, this.buildExecutor, this.editContributorsPopUpPresenterInstance, this.deleteProjectPopUpScreenInstance, this.renameProjectPopUpScreenInstance, new CallerMock<>(this.libraryService), projectScreenServiceCaller, copyPopUpPresenter, projectNameValidator, promises, notificationEvent, viewHideAlertsButtonPresenter));
    this.presenter.workspaceProject = createProject();
}
Also used : SyncPromises(org.uberfire.promise.SyncPromises) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Module(org.guvnor.common.services.project.model.Module) Before(org.junit.Before)

Example 3 with WorkspaceProject

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

the class SettingsPresenterTest method testForceSave.

@Test
public void testForceSave() {
    WorkspaceProject project = mock(WorkspaceProject.class);
    doReturn(project).when(projectScreenService).save(any(), any(), any(), any());
    settingsPresenter.concurrentPomUpdateInfo = mock(ObservablePath.OnConcurrentUpdateEvent.class);
    settingsPresenter.forceSave("Test comment", null);
    assertEquals(null, settingsPresenter.concurrentPomUpdateInfo);
    verify(conflictingRepositoriesPopup).hide();
    verify(settingsPresenter).saveProjectScreenModel(eq("Test comment"), eq(DeploymentMode.FORCED), any());
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Test(org.junit.Test)

Example 4 with WorkspaceProject

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

the class SettingsPresenterTest method testSaveProjectScreenModel.

@Test
public void testSaveProjectScreenModel() {
    WorkspaceProject project = mock(WorkspaceProject.class);
    Module module = mock(Module.class);
    doReturn(module).when(project).getMainModule();
    doReturn(project).when(projectScreenService).save(any(), any(), any(), any());
    settingsPresenter.saveProjectScreenModel("Test comment", DeploymentMode.VALIDATED, null).catch_(i -> {
        fail("Promise should've been resolved!");
        return promises.resolve();
    });
    verify(projectScreenService).save(any(), any(), eq("Test comment"), eq(DeploymentMode.VALIDATED));
    verify(projectContext).updateProjectModule(module);
    verify(settingsPresenter, never()).handlePomConcurrentUpdate(any(), any());
    verify(settingsPresenter, never()).defaultErrorResolution(any());
    verify(settingsPresenter, never()).handleSaveProjectScreenModelError(any(), any(), any());
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 5 with WorkspaceProject

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

the class LibraryPlacesTest method goToNewProject.

@Test
public void goToNewProject() {
    final WorkspaceProject project = new WorkspaceProject(activeOrganizationalUnit, activeRepository, activeBranch, mock(Module.class));
    libraryPlaces.goToProject(project);
    verify(projectContextChangeEvent).fire(any(WorkspaceProjectContextChangeEvent.class));
    verify(placeManager).closeAllPlacesOrNothing();
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Module(org.guvnor.common.services.project.model.Module) 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