use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method createProjectFromBaseKieTemplateWithRemoteUrlTest.
@Test
public void createProjectFromBaseKieTemplateWithRemoteUrlTest() {
final String remoteRepositoryUrl = "myRemoteUrl";
final List<Contributor> spaceContributors = new ArrayList<>();
spaceContributors.add(new Contributor("user1", ContributorType.OWNER));
spaceContributors.add(new Contributor("user2", ContributorType.ADMIN));
spaceContributors.add(new Contributor("admin", ContributorType.CONTRIBUTOR));
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
doReturn("ou").when(organizationalUnit).getName();
doReturn("org.ou").when(organizationalUnit).getDefaultGroupId();
doReturn(spaceContributors).when(organizationalUnit).getContributors();
doReturn(organizationalUnit).when(ouService).getOrganizationalUnit("ou");
final Repository kieBaseTemplate = mock(Repository.class);
doReturn(Optional.of(kieBaseTemplate)).when(archetypeService).getBaseKieTemplateRepository();
final Archetype baseKieArchetype = mock(Archetype.class);
doReturn(Optional.of(baseKieArchetype)).when(archetypeService).getBaseKieArchetype();
libraryService.createProject(organizationalUnit, remoteRepositoryUrl, "myRemoteRepository");
final List<Contributor> projectContributors = new ArrayList<>();
projectContributors.add(new Contributor("user1", ContributorType.OWNER));
projectContributors.add(new Contributor("user2", ContributorType.ADMIN));
projectContributors.add(new Contributor("admin", ContributorType.OWNER));
verify(archetypeService).getBaseKieArchetype();
verify(projectService).newProject(eq(organizationalUnit), any(POM.class), eq(DeploymentMode.VALIDATED), eq(projectContributors), eq(kieBaseTemplate), eq(remoteRepositoryUrl));
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class SpacesScreenServiceImpl method getContributors.
private List<Contributor> getContributors() {
final List<Contributor> contributors = new ArrayList<>();
contributors.add(new Contributor(sessionInfo.getIdentity().getIdentifier(), ContributorType.OWNER));
return contributors;
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class SpacesScreenServiceImplTest method testSaveSpace.
@Test
public void testSaveSpace() {
final SpacesScreenService.NewSpace space = new SpacesScreenService.NewSpace() {
{
name = "test";
groupId = "com.test";
description = "Test space";
}
};
final List<Contributor> contributors = new ArrayList<>();
contributors.add(new Contributor(sessionInfo.getIdentity().getIdentifier(), ContributorType.OWNER));
assertEquals(201, spacesScreenService.postSpace(space).getStatus());
verify(organizationalUnitService).createOrganizationalUnit("test", "com.test", new ArrayList<>(), contributors, "Test space");
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class SpaceContributorsListServiceImplTest 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 OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
doReturn(contributors).when(organizationalUnit).getContributors();
doReturn(organizationalUnit).when(organizationalUnitService).getOrganizationalUnit(Mockito.<String>any());
service.getContributors(repositoryContributors -> {
assertEquals(3, repositoryContributors.size());
});
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class SpaceContributorsListServiceImplTest method ownerCanEditContributors.
@Test
public void ownerCanEditContributors() {
doReturn(false).when(organizationalUnitController).canUpdateOrgUnit(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();
});
}
Aggregations