Search in sources :

Example 31 with Contributor

use of org.uberfire.security.Contributor 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)

Aggregations

Contributor (org.uberfire.security.Contributor)31 ArrayList (java.util.ArrayList)25 Test (org.junit.Test)22 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)11 Repository (org.guvnor.structure.repositories.Repository)8 POM (org.guvnor.common.services.project.model.POM)6 Consumer (java.util.function.Consumer)4 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)4 List (java.util.List)3 Branch (org.guvnor.structure.repositories.Branch)3 Before (org.junit.Before)3 Collections (java.util.Collections)2 Map (java.util.Map)2 Module (org.guvnor.common.services.project.model.Module)2 BranchPermissions (org.guvnor.structure.organizationalunit.config.BranchPermissions)2 UnauthorizedException (org.jboss.errai.security.shared.exception.UnauthorizedException)2 Archetype (org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype)2 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)2 LibraryPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2