use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.
the class OrganizationalUnitPopUpPresenterTest method setup.
@Before
public void setup() {
doReturn(true).when(organizationalUnitController).canReadOrgUnits();
doReturn(true).when(organizationalUnitController).canReadOrgUnit(any());
doReturn(true).when(organizationalUnitController).canUpdateOrgUnit(any());
doReturn(true).when(organizationalUnitController).canCreateOrgUnits();
doReturn(true).when(organizationalUnitController).canDeleteOrgUnit(any());
organizationalUnitServiceCaller = new CallerMock<>(organizationalUnitService);
doReturn(true).when(organizationalUnitService).isValidGroupId(anyString());
doReturn(null).when(organizationalUnitService).getOrganizationalUnit(anyString());
doAnswer(invocationOnMock -> new OrganizationalUnitImpl((String) invocationOnMock.getArguments()[0], (String) invocationOnMock.getArguments()[1], (String) invocationOnMock.getArguments()[2])).when(organizationalUnitService).createOrganizationalUnit(anyString(), anyString(), anyString(), any(), any());
doReturn(mock(ContributorsManagementPresenter.View.class)).when(contributorsManagementPresenter).getView();
presenter = spy(new OrganizationalUnitPopUpPresenter(view, organizationalUnitServiceCaller, afterCreateOrganizationalUnitEvent, afterEditOrganizationalUnitEvent, notificationEvent, organizationalUnitController, contributorsManagementPresenter, sessionInfo));
}
use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.
the class ExamplesServiceImplRepositoryNamesTest method setup.
@Before
public void setup() {
service = spy(new ExamplesServiceImpl(ioService, configurationFactory, repositoryFactory, moduleService, repositoryService, repositoryCopier, ouService, projectService, metadataService, spaces, newProjectEvent, projectScreenService));
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1Owner", "ou1GroupId"));
}
});
when(moduleService.resolveModule(any(Path.class))).thenAnswer(new Answer<KieModule>() {
@Override
public KieModule answer(final InvocationOnMock invocationOnMock) throws Throwable {
final Path path = (Path) invocationOnMock.getArguments()[0];
final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
return module;
}
});
when(sessionInfo.getId()).thenReturn("sessionId");
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn("user");
when(configurationFactory.newConfigGroup(any(ConfigType.class), anyString(), anyString())).thenReturn(mock(ConfigGroup.class));
final ExampleProject exProject1 = mock(ExampleProject.class);
exampleProjects = new ArrayList<ExampleProject>() {
{
add(exProject1);
}
};
final OrganizationalUnit ou = mock(OrganizationalUnit.class);
doReturn("ou").when(ou).getName();
final GitRepository repository1 = mock(GitRepository.class);
final Path repositoryRoot = mock(Path.class);
final Path module1Root = mock(Path.class);
when(exampleOrganizationalUnit.getName()).thenReturn("ou");
when(exProject1.getName()).thenReturn("module1");
when(exProject1.getRoot()).thenReturn(module1Root);
when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot)));
final Optional<Branch> master = Optional.of(new Branch("master", PathFactory.newPath("testFile", "file:///")));
when(repository1.getDefaultBranch()).thenReturn(master);
when(repositoryRoot.toURI()).thenReturn("default:///");
when(module1Root.toURI()).thenReturn("default:///module1");
when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(ou);
doReturn("module1").when(repository1).getAlias();
doReturn(repository1).when(repositoryCopier).copy(eq(ou), anyString(), eq(module1Root));
final WorkspaceProject project = spy(new WorkspaceProject());
doReturn(repository1.getAlias()).when(project).getName();
doReturn(mock(Module.class)).when(project).getMainModule();
doReturn(mock(OrganizationalUnit.class)).when(project).getOrganizationalUnit();
doReturn(project).when(projectService).resolveProject(repository1);
doReturn(project).when(projectService).resolveProject(any(Path.class));
final ProjectScreenModel model = new ProjectScreenModel();
model.setPOM(new POM());
doReturn(model).when(projectScreenService).load(any());
}
use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method setup.
@Before
public void setup() {
service = spy(new ExamplesServiceImpl(ioService, configurationFactory, repositoryFactory, moduleService, repositoryService, repositoryCopier, ouService, projectService, metadataService, spaces, newProjectEvent, projectScreenService));
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1Owner", "ou1GroupId"));
add(new OrganizationalUnitImpl("ou2Name", "ou2Owner", "ou2GroupId"));
}
});
when(moduleService.resolveModule(any(Path.class))).thenAnswer(new Answer<KieModule>() {
@Override
public KieModule answer(final InvocationOnMock invocationOnMock) throws Throwable {
final Path path = (Path) invocationOnMock.getArguments()[0];
final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
return module;
}
});
when(sessionInfo.getId()).thenReturn("sessionId");
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn("user");
when(configurationFactory.newConfigGroup(any(ConfigType.class), anyString(), anyString(), anyString())).thenReturn(mock(ConfigGroup.class));
}
use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.
the class DefExplorerQueryServiceTest method createOrganizationalUnits.
private void createOrganizationalUnits() {
organizationalUnits = new ArrayList<>();
o1 = new OrganizationalUnitImpl("o1", "owner1", "group1");
repo_o1_1 = new RepositoryMock("repo_o1_1", "repo_o1_1");
repo_o1_2 = new RepositoryMock("repo_o1_2", "repo_o1_2");
repo_o1_3 = new RepositoryMock("repo_o1_3", "repo_o1_3");
o1.getRepositories().add(repo_o1_1);
o1.getRepositories().add(repo_o1_2);
o1.getRepositories().add(repo_o1_3);
organizationalUnits.add(o1);
o2 = new OrganizationalUnitImpl("o2", "owner2", "group2");
repo_o2_1 = new RepositoryMock("repo_o2_1", "repo_o2_1");
repo_o2_2 = new RepositoryMock("repo_o2_2", "repo_o2_2");
o2.getRepositories().add(repo_o2_1);
o2.getRepositories().add(repo_o2_2);
organizationalUnits.add(o2);
o3 = new OrganizationalUnitImpl("o3", "owner3", "group3");
repo_o3_1 = new RepositoryMock("repo_o3_1", "repo_o3_1");
repo_o3_2 = new RepositoryMock("repo_o3_2", "repo_o3_2");
repo_o3_3 = new RepositoryMock("repo_o3_3", "repo_o3_3");
o3.getRepositories().add(repo_o3_1);
o3.getRepositories().add(repo_o3_2);
o3.getRepositories().add(repo_o3_3);
organizationalUnits.add(o3);
}
use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.
the class SocialEventModuleConstraintTest method setUp.
@Before
public void setUp() throws Exception {
Collection<OrganizationalUnit> ous = new ArrayList<OrganizationalUnit>();
final OrganizationalUnitImpl ou = new OrganizationalUnitImpl("ouname", "owner", "groupid");
final OrganizationalUnitImpl ouSpy = spy(ou);
Collection<Repository> repositories = new ArrayList<Repository>();
repository = new GitRepository("repo", new Space("space"));
repositories.add(repository);
ous.add(ouSpy);
when(ouSpy.getRepositories()).thenReturn(repositories);
when(organizationalUnitService.getOrganizationalUnits()).thenReturn(ous);
when(authorizationManager.authorize(ou, user)).thenReturn(true);
when(authorizationManager.authorize(repository, user)).thenReturn(true);
when(userCDIContextHelper.getUser()).thenReturn(user);
when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(true);
socialEventModuleConstraint = createSocialEventModuleConstraint();
}
Aggregations