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();
});
}
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());
}
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);
}
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());
}
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();
});
}
Aggregations