Search in sources :

Example 26 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class SpaceContributorsListServiceImplTest method contributorCanNotEditContributors.

@Test
public void contributorCanNotEditContributors() {
    doReturn(false).when(organizationalUnitController).canUpdateOrgUnit(any());
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor("owner", ContributorType.CONTRIBUTOR));
    service.canEditContributors(contributors, ContributorType.OWNER).then(canEditContributors -> {
        assertFalse(canEditContributors);
        return promises.resolve();
    });
    service.canEditContributors(contributors, ContributorType.ADMIN).then(canEditContributors -> {
        assertFalse(canEditContributors);
        return promises.resolve();
    });
    service.canEditContributors(contributors, ContributorType.CONTRIBUTOR).then(canEditContributors -> {
        assertFalse(canEditContributors);
        return promises.resolve();
    });
}
Also used : ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Example 27 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class ContributorsListItemPresenterTest method removeTest.

@Test
public void removeTest() {
    final Contributor contributor1 = new Contributor("admin", ContributorType.OWNER);
    final Contributor contributor2 = new Contributor("other", ContributorType.CONTRIBUTOR);
    final ContributorsListService contributorsListService = mock(ContributorsListService.class);
    doAnswer(invocationOnMock -> {
        final List<Contributor> contributors = new ArrayList<>();
        contributors.add(contributor1);
        contributors.add(contributor2);
        invocationOnMock.getArgument(0, Consumer.class).accept(contributors);
        return null;
    }).when(contributorsListService).getContributors(any());
    final ContributorsListPresenter parentPresenter = mock(ContributorsListPresenter.class);
    doReturn(promises.resolve(true)).when(parentPresenter).canEditContributors(any());
    presenter.setup(contributor2, parentPresenter, contributorsListService);
    presenter.remove();
    verify(view).showBusyIndicator(Mockito.<String>any());
    verify(contributorsListService).saveContributors(any(), any(), any());
}
Also used : Consumer(java.util.function.Consumer) ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Example 28 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class ContributorsListItemPresenterTest method setupTest.

@Test
public void setupTest() {
    final Contributor contributor = mock(Contributor.class);
    presenter.setup(contributor, mock(ContributorsListPresenter.class), mock(ContributorsListService.class));
    verify(view).init(presenter);
    verify(view).setupViewMode(contributor);
}
Also used : Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Example 29 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class ContributorsListItemPresenterTest method setup.

@Before
public void setup() {
    promises = new SyncPromises();
    presenter = new ContributorsListItemPresenter(view, libraryPlaces, notificationEvent, promises);
    persistedContributor = new Contributor("admin", ContributorType.OWNER);
    doAnswer(invocationOnMock -> {
        final List<Contributor> contributors = new ArrayList<>();
        contributors.add(persistedContributor);
        invocationOnMock.getArgument(0, Consumer.class).accept(contributors);
        return null;
    }).when(contributorsListService).getContributors(any());
}
Also used : Consumer(java.util.function.Consumer) SyncPromises(org.uberfire.promise.SyncPromises) ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor) Before(org.junit.Before)

Example 30 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class ProjectContributorsListServiceImplTest method adminCanEditSomeContributors.

@Test
public void adminCanEditSomeContributors() {
    doReturn(promises.resolve(false)).when(projectController).canUpdateProject(any());
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor("owner", ContributorType.ADMIN));
    service.canEditContributors(contributors, ContributorType.OWNER).then(canEditContributors -> {
        assertFalse(canEditContributors);
        return promises.resolve();
    });
    service.canEditContributors(contributors, ContributorType.ADMIN).then(canEditContributors -> {
        assertTrue(canEditContributors);
        return promises.resolve();
    });
    service.canEditContributors(contributors, ContributorType.CONTRIBUTOR).then(canEditContributors -> {
        assertTrue(canEditContributors);
        return promises.resolve();
    });
}
Also used : ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor) 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