Search in sources :

Example 1 with Contributor

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

the class ContributorsListItemPresenterTest method cancelPersistedContributorTest.

@Test
public void cancelPersistedContributorTest() {
    final Contributor contributor = mock(Contributor.class);
    final ContributorsListPresenter parentPresenter = mock(ContributorsListPresenter.class);
    presenter.setup(contributor, parentPresenter, mock(ContributorsListService.class));
    presenter.cancel();
    verify(view, times(2)).setupViewMode(contributor);
    verify(view, never()).removeContributor();
    verify(parentPresenter).itemIsNotBeingEdited();
}
Also used : Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Example 2 with Contributor

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

the class ContributorsListItemPresenterTest method removeLastOwnerTest.

@Test
public void removeLastOwnerTest() {
    final Contributor contributor = new Contributor("admin", ContributorType.OWNER);
    final ContributorsListService contributorsListService = mock(ContributorsListService.class);
    doAnswer(invocationOnMock -> {
        invocationOnMock.getArgument(0, Consumer.class).accept(Collections.singletonList(contributor));
        return null;
    }).when(contributorsListService).getContributors(any());
    final ContributorsListPresenter parentPresenter = mock(ContributorsListPresenter.class);
    doReturn(promises.resolve(true)).when(parentPresenter).canEditContributors(any());
    presenter.setup(contributor, parentPresenter, contributorsListService);
    presenter.remove();
    verify(notificationEvent).fire(any());
    verify(view, never()).showBusyIndicator(anyString());
}
Also used : Consumer(java.util.function.Consumer) Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Example 3 with Contributor

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

the class ProjectContributorsListServiceImplTest method saveContributorsTest.

@Test
public void saveContributorsTest() {
    final Repository repository = mock(Repository.class);
    doReturn(repository).when(repositoryService).getRepositoryFromSpace(any(), any());
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor("owner", ContributorType.OWNER));
    contributors.add(new Contributor("contributor", ContributorType.CONTRIBUTOR));
    contributors.add(new Contributor("admin", ContributorType.ADMIN));
    service.saveContributors(contributors, () -> {
    }, null);
    verify(repositoryService).updateContributors(repository, contributors);
}
Also used : Repository(org.guvnor.structure.repositories.Repository) ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Example 4 with Contributor

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

the class ProjectContributorsListServiceImplTest method ownerCanEditContributors.

@Test
public void ownerCanEditContributors() {
    doReturn(promises.resolve(false)).when(projectController).canUpdateProject(any());
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor("owner", ContributorType.OWNER));
    service.canEditContributors(contributors, ContributorType.OWNER).then(canEditContributors -> {
        assertTrue(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)

Example 5 with Contributor

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

the class ProjectContributorsListServiceImplTest method contributorCanNotEditContributors.

@Test
public void contributorCanNotEditContributors() {
    doReturn(promises.resolve(false)).when(projectController).canUpdateProject(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)

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