Search in sources :

Example 1 with LibraryOrganizationalUnitPreferences

use of org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences in project kie-wb-common by kiegroup.

the class AddProjectPopUpPresenterTest method testRestoreAdvancedOptionsWithoutActiveOrganizationalUnit.

@Test
public void testRestoreAdvancedOptionsWithoutActiveOrganizationalUnit() {
    LibraryPreferences loadedLibraryPreferences = mock(LibraryPreferences.class);
    LibraryProjectPreferences libraryProjectPreferences = mock(LibraryProjectPreferences.class);
    LibraryOrganizationalUnitPreferences libraryOrganizationalUnitPreferences = mock(LibraryOrganizationalUnitPreferences.class);
    doReturn(libraryProjectPreferences).when(loadedLibraryPreferences).getProjectPreferences();
    doReturn("version").when(libraryProjectPreferences).getVersion();
    doReturn(libraryOrganizationalUnitPreferences).when(loadedLibraryPreferences).getOrganizationalUnitPreferences();
    when(libraryOrganizationalUnitPreferences.getGroupId()).thenReturn("group");
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
    when(view.getName()).thenReturn("Project Test");
    executeParametrizedCommandWith(0, loadedLibraryPreferences).when(libraryPreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
    presenter.restoreAdvancedOptions();
    verify(view).setVersion("version");
    verify(view).setGroupId("group");
    verify(view, never()).setDescription(any());
    verify(view).setArtifactId("ProjectTest");
}
Also used : LibraryOrganizationalUnitPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences) LibraryPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences) LibraryProjectPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Test(org.junit.Test)

Example 2 with LibraryOrganizationalUnitPreferences

use of org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences in project kie-wb-common by kiegroup.

the class NewWorkspaceProjectHandlerTest method testGetCommandWithActiveRepository.

@Test
public void testGetCommandWithActiveRepository() {
    final LibraryOrganizationalUnitPreferences libraryOrganizationalUnitPreferences = mock(LibraryOrganizationalUnitPreferences.class);
    when(libraryOrganizationalUnitPreferences.getName()).thenReturn("myOU");
    when(libraryPreferences.getOrganizationalUnitPreferences()).thenReturn(libraryOrganizationalUnitPreferences);
    when(context.getActiveWorkspaceProject()).thenReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mock(Module.class))));
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getDefaultGroupId()).thenReturn("defaultGroupId");
    when(organizationalUnitService.getOrganizationalUnit("myOU")).thenReturn(organizationalUnit);
    doAnswer(new Answer() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            when(context.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
            return null;
        }
    }).when(projectContextChangeEvent).fire(any(WorkspaceProjectContextChangeEvent.class));
    final Command command = handler.getCommand(newResourcePresenter);
    assertNotNull(command);
    command.execute();
    ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
    verify(wizard, times(1)).initialise(pomArgumentCaptor.capture());
    verify(wizard, times(1)).start(any(org.uberfire.client.callbacks.Callback.class), anyBoolean());
    assertEquals("defaultGroupId", pomArgumentCaptor.getValue().getGav().getGroupId());
    assertEquals("kjar", pomArgumentCaptor.getValue().getPackaging());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) POM(org.guvnor.common.services.project.model.POM) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) LibraryOrganizationalUnitPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences) Callback(com.google.gwt.core.client.Callback) ValidatorWithReasonCallback(org.uberfire.ext.editor.commons.client.validation.ValidatorWithReasonCallback) Command(org.uberfire.mvp.Command) Branch(org.guvnor.structure.repositories.Branch) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 3 with LibraryOrganizationalUnitPreferences

use of org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method setup.

@Before
public void setup() {
    ous = Arrays.asList(ou1, ou2);
    when(ouService.getOrganizationalUnits()).thenReturn(ous);
    when(ou1.getIdentifier()).thenReturn("ou1");
    when(ou2.getIdentifier()).thenReturn("ou2");
    when(repo1.getAlias()).thenReturn("repo_created_by_user");
    final List<Branch> repo1Branches = Arrays.asList(makeBranch("repo1-branch1", repo1.getAlias()), makeBranch("repo1-branch2", repo1.getAlias()));
    when(repo1.getBranches()).thenReturn(repo1Branches);
    when(repo1.getBranch(anyString())).then(inv -> repo1Branches.stream().filter(b -> b.getName().equals(inv.getArgument(0, String.class))).findFirst());
    when(repo2Default.getAlias()).thenReturn("ou2-repo-alias");
    final List<Branch> repo2Branches = Collections.singletonList(makeBranch("repo2-branch1", repo2Default.getAlias()));
    when(repo2Default.getBranches()).thenReturn(repo2Branches);
    when(ou2.getRepositories()).thenReturn(Arrays.asList(repo1, repo2Default));
    when(indexOracle.isIndexed(any())).thenReturn(true);
    modulesMock = new HashSet<>();
    modulesMock.add(mock(Module.class));
    modulesMock.add(mock(Module.class));
    modulesMock.add(mock(Module.class));
    when(preferences.getOrganizationalUnitPreferences()).thenReturn(spy(new LibraryOrganizationalUnitPreferences()));
    when(preferences.getProjectPreferences()).thenReturn(spy(new LibraryProjectPreferences()));
    sessionInfo = new SessionInfoMock();
    libraryService = spy(new LibraryServiceImpl(ouService, refactoringQueryService, preferences, authorizationManager, sessionInfo, explorerServiceHelper, projectService, moduleService, examplesService, ioService, userManagerService, indexOracle, spaceConfigStorageRegistry, clusterService, archetypeService));
}
Also used : LibraryOrganizationalUnitPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences) SessionInfoMock(org.uberfire.mocks.SessionInfoMock) Branch(org.guvnor.structure.repositories.Branch) Module(org.guvnor.common.services.project.model.Module) LibraryProjectPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences) Before(org.junit.Before)

Aggregations

LibraryOrganizationalUnitPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences)3 Module (org.guvnor.common.services.project.model.Module)2 Branch (org.guvnor.structure.repositories.Branch)2 Test (org.junit.Test)2 LibraryProjectPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences)2 Callback (com.google.gwt.core.client.Callback)1 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)1 POM (org.guvnor.common.services.project.model.POM)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)1 Before (org.junit.Before)1 LibraryPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1 ValidatorWithReasonCallback (org.uberfire.ext.editor.commons.client.validation.ValidatorWithReasonCallback)1 SessionInfoMock (org.uberfire.mocks.SessionInfoMock)1 Command (org.uberfire.mvp.Command)1 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)1