use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class ProjectContributorsListServiceImplTest method getContributorsTest.
@Test
public void getContributorsTest() {
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));
final Repository repository = mock(Repository.class);
doReturn(contributors).when(repository).getContributors();
doReturn(repository).when(repositoryService).getRepositoryFromSpace(any(), any());
service.getContributors(repositoryContributors -> {
assertEquals(3, repositoryContributors.size());
});
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class ContributorsListPresenterTest method filterContributorsTest.
@Test
public void filterContributorsTest() {
final InOrder order = inOrder(contributorsListItemPresenter);
presenter.contributors = new ArrayList<>();
presenter.contributors.add(new Contributor("John", ContributorType.OWNER));
presenter.contributors.add(new Contributor("Mary", ContributorType.ADMIN));
presenter.contributors.add(new Contributor("Jonathan", ContributorType.CONTRIBUTOR));
presenter.filterContributors("h");
verify(view).clearContributors();
order.verify(contributorsListItemPresenter).setup(presenter.contributors.get(0), presenter, null);
order.verify(contributorsListItemPresenter).setup(presenter.contributors.get(2), presenter, null);
verify(view, times(2)).addContributor(any());
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class ContributorsListPresenterTest method setup.
@Before
public void setup() {
promises = new SyncPromises();
doReturn(contributorsListItemPresenter).when(contributorsListItemPresenters).get();
doReturn(mock(ContributorsListItemPresenter.View.class)).when(contributorsListItemPresenter).getView();
presenter = spy(new ContributorsListPresenter(view, contributorsListItemPresenters, elemental2DomUtil, promises));
contributors = new ArrayList<>();
contributors.add(new Contributor("admin", ContributorType.OWNER));
contributors.add(new Contributor("user", ContributorType.CONTRIBUTOR));
contributors.add(new Contributor("Director", ContributorType.ADMIN));
doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(0, Consumer.class).accept(contributors);
return null;
}).when(contributorsListService).getContributors(any());
final List<String> userNames = Arrays.asList("admin", "user", "Director");
doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(0, Consumer.class).accept(userNames);
return null;
}).when(contributorsListService).getValidUsernames(any());
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class SpaceContributorsListServiceImplTest method saveContributorsTest.
@Test
public void saveContributorsTest() {
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
doReturn("ou").when(organizationalUnit).getName();
doReturn(organizationalUnit).when(organizationalUnitService).getOrganizationalUnit(Mockito.<String>any());
doReturn(organizationalUnit).when(organizationalUnitService).updateOrganizationalUnit(any(), 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(organizationalUnitService).updateOrganizationalUnit("ou", null, contributors);
verify(afterEditOrganizationalUnitEvent).fire(any());
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class SpaceContributorsListServiceImplTest method adminCanEditSomeContributors.
@Test
public void adminCanEditSomeContributors() {
doReturn(false).when(organizationalUnitController).canUpdateOrgUnit(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