Search in sources :

Example 21 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit 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 22 with OrganizationalUnit

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

the class EditContributorsPopUpPresenterTest method showWithPermissionTest.

@Test
public void showWithPermissionTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    presenter.show(organizationalUnit);
    verify(contributorsManagementPresenter).setup(organizationalUnit);
    verify(view).append(any());
    verify(view).show(organizationalUnit);
    assertEquals(organizationalUnit, presenter.organizationalUnit);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Test(org.junit.Test)

Example 23 with OrganizationalUnit

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

the class ContributorsListPresenterTest method organizationalUnitEditedTest.

@Test
public void organizationalUnitEditedTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final AfterEditOrganizationalUnitEvent afterEditOrganizationalUnitEvent = mock(AfterEditOrganizationalUnitEvent.class);
    doReturn(organizationalUnit).when(afterEditOrganizationalUnitEvent).getEditedOrganizationalUnit();
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
    presenter.organizationalUnitEdited(afterEditOrganizationalUnitEvent);
    verify(view).clearFilterText();
    verify(presenter).updateContributors(organizationalUnit);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) AfterEditOrganizationalUnitEvent(org.guvnor.structure.events.AfterEditOrganizationalUnitEvent) Test(org.junit.Test)

Example 24 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit 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("John");
    presenter.contributors.add("Mary");
    presenter.contributors.add("Jonathan");
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn("Mary").when(organizationalUnit).getOwner();
    doReturn(presenter.contributors).when(organizationalUnit).getContributors();
    doReturn(Optional.of(organizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    presenter.filterContributors("h");
    verify(view).clearContributors();
    order.verify(contributorsListItemPresenter).setup("John", "Contributor");
    order.verify(contributorsListItemPresenter).setup("Jonathan", "Contributor");
    verify(view, times(2)).addContributor(any());
}
Also used : InOrder(org.mockito.InOrder) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Test(org.junit.Test)

Example 25 with OrganizationalUnit

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

the class ContributorsListPresenterTest method getContributorsCountTest.

@Test
public void getContributorsCountTest() {
    final List<String> contributors = new ArrayList<>();
    contributors.add("B");
    contributors.add("c");
    contributors.add("a");
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn("B").when(organizationalUnit).getOwner();
    doReturn(contributors).when(organizationalUnit).getContributors();
    doReturn(Optional.of(organizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    assertEquals(3, presenter.getContributorsCount());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)60 Test (org.junit.Test)33 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)19 ArrayList (java.util.ArrayList)18 Repository (org.guvnor.structure.repositories.Repository)17 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)13 Module (org.guvnor.common.services.project.model.Module)11 POM (org.guvnor.common.services.project.model.POM)10 Branch (org.guvnor.structure.repositories.Branch)10 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)10 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)9 Before (org.junit.Before)8 Path (org.uberfire.backend.vfs.Path)7 OrganizationalUnitImpl (org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl)6 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)6 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)5 NewProjectEvent (org.guvnor.common.services.project.events.NewProjectEvent)3 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Command (org.uberfire.mvp.Command)3