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