Search in sources :

Example 1 with OrganizationalUnitImpl

use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.

the class SocialEventOUConstraintTest method setUp.

@Before
public void setUp() throws Exception {
    Collection<OrganizationalUnit> ous = new ArrayList<OrganizationalUnit>();
    final OrganizationalUnitImpl ou = new OrganizationalUnitImpl("ouname", "owner", "groupid");
    ous.add(ou);
    when(organizationalUnitService.getOrganizationalUnits()).thenReturn(ous);
    when(authorizationManager.authorize(ou, user)).thenReturn(true);
    when(userCDIContextHelper.getUser()).thenReturn(user);
    when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(true);
    socialEventOUConstraint = new SocialEventOUConstraint(organizationalUnitService, authorizationManager, repositoryService, userCDIContextHelper);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) Before(org.junit.Before)

Example 2 with OrganizationalUnitImpl

use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.

the class SocialEventRepositoryConstraintTest 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);
    socialEventRepositoryConstraint = createSocialEventRepositoryContraint();
}
Also used : Space(org.uberfire.spaces.Space) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) Before(org.junit.Before)

Example 3 with OrganizationalUnitImpl

use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.

the class ImportRepositoryPopUpPresenterTest method setup.

@Before
public void setup() {
    ou = new OrganizationalUnitImpl("test-ou", "test-admin", "test-id");
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(ou));
    libraryServiceCaller = new CallerMock<>(libraryService);
    presenter = new ImportRepositoryPopUpPresenter(view, libraryPlaces, projectContext, libraryServiceCaller);
}
Also used : OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) Before(org.junit.Before)

Example 4 with OrganizationalUnitImpl

use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.

the class OrganizationalUnitsScreenTest method setup.

@Before
public void setup() {
    when(translationService.getTranslation(anyString())).thenReturn("");
    libraryServiceCaller = new CallerMock<>(libraryService);
    organizationalUnit1 = new OrganizationalUnitImpl("ou1", "owner1", "defaultGroupId1");
    organizationalUnit2 = new OrganizationalUnitImpl("ou2", "owner2", "defaultGroupId2");
    organizationalUnit3 = new OrganizationalUnitImpl("ou3", "owner3", "defaultGroupId3");
    List<OrganizationalUnit> organizationalUnits = new ArrayList<>();
    organizationalUnits.add(organizationalUnit1);
    organizationalUnits.add(organizationalUnit2);
    organizationalUnits.add(organizationalUnit3);
    doReturn(organizationalUnits).when(libraryService).getOrganizationalUnits();
    presenter = spy(new OrganizationalUnitsScreen(view, libraryPlaces, libraryServiceCaller, organizationalUnitPopUpPresenter, organizationalUnitController, organizationalUnitTileWidgets, projectContextChangeEvent, mock(WorkspaceProjectContext.class), libraryInternalPreferences, emptyOrganizationalUnitsScreen));
    doReturn(true).when(organizationalUnitController).canCreateOrgUnits();
    doReturn(true).when(organizationalUnitController).canReadOrgUnits();
    doReturn(true).when(organizationalUnitController).canReadOrgUnit(any());
    doReturn(tileWidget).when(organizationalUnitTileWidgets).get();
    doReturn(mock(EmptyOrganizationalUnitsScreen.View.class)).when(emptyOrganizationalUnitsScreen).getView();
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) Before(org.junit.Before)

Example 5 with OrganizationalUnitImpl

use of org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl in project kie-wb-common by kiegroup.

the class EditContributorsPopUpPresenterTest 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(null).when(organizationalUnitService).getOrganizationalUnit(anyString());
    doAnswer(invocationOnMock -> new OrganizationalUnitImpl((String) invocationOnMock.getArguments()[0], (String) invocationOnMock.getArguments()[1], (String) invocationOnMock.getArguments()[2])).when(organizationalUnitService).updateOrganizationalUnit(anyString(), anyString(), anyString(), any());
    doReturn(mock(ContributorsManagementPresenter.View.class)).when(contributorsManagementPresenter).getView();
    presenter = spy(new EditContributorsPopUpPresenter(view, contributorsManagementPresenter, afterEditOrganizationalUnitEvent, notificationEvent, organizationalUnitController, organizationalUnitServiceCaller));
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) Before(org.junit.Before)

Aggregations

OrganizationalUnitImpl (org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl)10 Before (org.junit.Before)9 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)6 ArrayList (java.util.ArrayList)4 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)3 Repository (org.guvnor.structure.repositories.Repository)2 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)2 ConfigType (org.guvnor.structure.server.config.ConfigType)2 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)2 KieModule (org.kie.workbench.common.services.shared.project.KieModule)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Path (org.uberfire.backend.vfs.Path)2 Space (org.uberfire.spaces.Space)2 WorkspaceProjectContext (org.guvnor.common.services.project.client.context.WorkspaceProjectContext)1 Module (org.guvnor.common.services.project.model.Module)1 POM (org.guvnor.common.services.project.model.POM)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 Branch (org.guvnor.structure.repositories.Branch)1 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)1