Search in sources :

Example 1 with RolePermissions

use of org.guvnor.structure.organizationalunit.config.RolePermissions in project kie-wb-common by kiegroup.

the class BranchManagementPresenterTest method setupWithUpdatableBranchesTest.

@Test
public void setupWithUpdatableBranchesTest() {
    final Map<String, RolePermissions> permissionsByRole = new HashMap<>();
    permissionsByRole.put("CONTRIBUTOR", new RolePermissions("CONTRIBUTOR", true, false, true, true));
    doReturn(new BranchPermissions("myBranch", permissionsByRole)).when(libraryService).loadBranchPermissions("mySpace", "myProject", "myBranch");
    doReturn(promises.resolve(Arrays.asList(new Branch("main", mock(Path.class)), new Branch("myBranch", mock(Path.class))))).when(projectController).getUpdatableBranches(any());
    presenter.setup(mock(ProjectScreenModel.class)).then(v -> {
        assertEquals("myBranch", presenter.selectedBranch);
        verify(view).init(presenter);
        verify(view, never()).showEmptyState();
        verify(view).setupBranchSelect(any(), any(), any());
        verify(libraryService).loadBranchPermissions("mySpace", "myProject", "myBranch");
        return promises.resolve();
    }).catch_(error -> {
        fail();
        return promises.resolve();
    });
}
Also used : RolePermissions(org.guvnor.structure.organizationalunit.config.RolePermissions) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) CallerMock(org.uberfire.mocks.CallerMock) Space(org.uberfire.spaces.Space) Mock(org.mockito.Mock) Promises(org.uberfire.client.promise.Promises) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) Mockito.spy(org.mockito.Mockito.spy) SettingsSectionChange(org.kie.workbench.common.screens.library.client.settings.SettingsSectionChange) ArrayList(java.util.ArrayList) LibraryPlaces(org.kie.workbench.common.screens.library.client.util.LibraryPlaces) BranchPermissions(org.guvnor.structure.organizationalunit.config.BranchPermissions) Map(java.util.Map) Module(org.guvnor.common.services.project.model.Module) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Assert.fail(org.junit.Assert.fail) SyncPromises(org.uberfire.promise.SyncPromises) Mockito.anyString(org.mockito.Mockito.anyString) Mockito.doReturn(org.mockito.Mockito.doReturn) Path(org.uberfire.backend.vfs.Path) Before(org.junit.Before) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Repository(org.guvnor.structure.repositories.Repository) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test) LibraryService(org.kie.workbench.common.screens.library.api.LibraryService) MenuItem(org.kie.workbench.common.screens.library.client.settings.util.sections.MenuItem) Contributor(org.uberfire.security.Contributor) Mockito.verify(org.mockito.Mockito.verify) List(java.util.List) Mockito.never(org.mockito.Mockito.never) Caller(org.jboss.errai.common.client.api.Caller) ProjectController(org.guvnor.common.services.project.client.security.ProjectController) EventSourceMock(org.uberfire.mocks.EventSourceMock) Collections(java.util.Collections) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) Branch(org.guvnor.structure.repositories.Branch) Mockito.mock(org.mockito.Mockito.mock) BranchPermissions(org.guvnor.structure.organizationalunit.config.BranchPermissions) RolePermissions(org.guvnor.structure.organizationalunit.config.RolePermissions) HashMap(java.util.HashMap) Branch(org.guvnor.structure.repositories.Branch) Mockito.anyString(org.mockito.Mockito.anyString) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 2 with RolePermissions

use of org.guvnor.structure.organizationalunit.config.RolePermissions in project kie-wb-common by kiegroup.

the class RoleItemPresenterTest method setup.

@Before
public void setup() {
    presenter = new RoleItemPresenter(view);
    rolePermissions = new RolePermissions("myRole", true, true, true, true);
    branchManagementPresenter = mock(BranchManagementPresenter.class);
    presenter.setup(rolePermissions, branchManagementPresenter);
}
Also used : RolePermissions(org.guvnor.structure.organizationalunit.config.RolePermissions) Before(org.junit.Before)

Aggregations

RolePermissions (org.guvnor.structure.organizationalunit.config.RolePermissions)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ProjectController (org.guvnor.common.services.project.client.security.ProjectController)1 Module (org.guvnor.common.services.project.model.Module)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)1 BranchPermissions (org.guvnor.structure.organizationalunit.config.BranchPermissions)1 Branch (org.guvnor.structure.repositories.Branch)1 Repository (org.guvnor.structure.repositories.Repository)1 Caller (org.jboss.errai.common.client.api.Caller)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.fail (org.junit.Assert.fail)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1