Search in sources :

Example 36 with OrganizationalUnit

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

the class LibraryServiceImplTest method newModuleTest.

@Test
public void newModuleTest() {
    when(preferences.getOrganizationalUnitPreferences().getName()).thenReturn("ou2");
    when(preferences.getOrganizationalUnitPreferences().getAliasInSingular()).thenReturn("team");
    when(preferences.getProjectPreferences().getBranch()).thenReturn("master");
    when(preferences.getProjectPreferences().getVersion()).thenReturn("1.0");
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getDefaultGroupId()).thenReturn("ouGroupID");
    libraryService.createProject("Module Name!", organizationalUnit, "description", DeploymentMode.VALIDATED);
    verify(projectService).newProject(eq(organizationalUnit), pomArgumentCaptor.capture(), any());
    final POM pom = pomArgumentCaptor.getValue();
    assertEquals("Module Name!", pom.getName());
    assertEquals("ouGroupID", pom.getGav().getGroupId());
    assertEquals("ModuleName", pom.getGav().getArtifactId());
    assertEquals("description", pom.getDescription());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 37 with OrganizationalUnit

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

the class ImportRepositoryPopUpPresenter method importRepository.

public void importRepository() {
    final String repositoryUrl = view.getRepositoryURL();
    if (isEmpty(repositoryUrl)) {
        view.showError(view.getEmptyRepositoryURLValidationMessage());
        return;
    }
    OrganizationalUnit ou = context.getActiveOrganizationalUnit().orElseThrow(() -> new IllegalStateException("Cannot import project without an active organizational unit."));
    view.showBusyIndicator(view.getLoadingMessage());
    libraryService.call((WorkspaceProject project) -> {
        view.hideBusyIndicator();
        view.hide();
        libraryPlaces.goToProject(project);
    }, new DefaultErrorCallback() {

        @Override
        public boolean error(Message message, Throwable throwable) {
            view.hideBusyIndicator();
            view.showError(view.getNoProjectsToImportMessage());
            return false;
        }
    }).importProject(ou, repositoryUrl, view.getUserName(), view.getPassword());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Message(org.jboss.errai.bus.client.api.messaging.Message) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject)

Example 38 with OrganizationalUnit

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

the class BaseViewPresenterTest method testAutomaticModuleBuildEnabled.

@Test
public void testAutomaticModuleBuildEnabled() {
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    final Repository repository = mock(Repository.class);
    final Module module = mock(Module.class);
    ApplicationPreferences.setUp(new HashMap<String, String>());
    when(activeContextItems.setupActiveModule(content)).thenReturn(true);
    final WorkspaceProject project = mock(WorkspaceProject.class);
    when(activeContextItems.getActiveProject()).thenReturn(project);
    when(project.getOrganizationalUnit()).thenReturn(ou);
    when(project.getRepository()).thenReturn(repository);
    when(project.getBranch()).thenReturn(new Branch("master", mock(Path.class)));
    when(activeContextItems.getActiveModule()).thenReturn(module);
    presenter.doContentCallback(content);
    verify(buildServiceActual, times(1)).build(module);
}
Also used : Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Branch(org.guvnor.structure.repositories.Branch) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 39 with OrganizationalUnit

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

the class BaseViewPresenterTest method testAutomaticModuleBuildDisabledSystemProperty.

@Test
public void testAutomaticModuleBuildDisabledSystemProperty() {
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    final Repository repository = mock(Repository.class);
    final Module module = mock(Module.class);
    String spBuildDisableModuleExplorer = null;
    try {
        spBuildDisableModuleExplorer = System.getProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME);
        System.setProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME, "true");
        final ExplorerPreferencesLoader preferencesLoader = new ExplorerPreferencesLoader();
        ApplicationPreferences.setUp(preferencesLoader.load());
        when(activeContextItems.setupActiveModule(content)).thenReturn(true);
        final WorkspaceProject project = mock(WorkspaceProject.class);
        when(activeContextItems.getActiveProject()).thenReturn(project);
        when(project.getOrganizationalUnit()).thenReturn(ou);
        when(project.getRepository()).thenReturn(repository);
        when(project.getBranch()).thenReturn(new Branch("master", mock(Path.class)));
        when(activeContextItems.getActiveModule()).thenReturn(module);
        presenter.doContentCallback(content);
        verify(buildServiceActual, never()).build(any(Module.class));
    } finally {
        if (spBuildDisableModuleExplorer != null) {
            System.setProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME, spBuildDisableModuleExplorer);
        }
    }
}
Also used : Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Branch(org.guvnor.structure.repositories.Branch) ExplorerPreferencesLoader(org.kie.workbench.common.screens.explorer.backend.server.preferences.ExplorerPreferencesLoader) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 40 with OrganizationalUnit

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

the class LibraryServiceImplTest method importProjectWithoutCredentialsTest.

@Test
public void importProjectWithoutCredentialsTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final Repository repo = mock(Repository.class);
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final String repositoryURL = "file:///some/path/to/fake-repo.git";
    final String username = null;
    final String password = null;
    final ArgumentCaptor<RepositoryEnvironmentConfigurations> configCaptor = ArgumentCaptor.forClass(RepositoryEnvironmentConfigurations.class);
    when(repositoryService.createRepository(any(), any(), any(), configCaptor.capture())).thenReturn(repo);
    when(projectService.resolveProject(any(Repository.class))).thenReturn(project);
    final WorkspaceProject observedProject = libraryService.importProject(organizationalUnit, repositoryURL, username, password);
    verify(repositoryService).createRepository(same(organizationalUnit), eq(GitRepository.SCHEME.toString()), eq("fake-repo"), any());
    RepositoryEnvironmentConfigurations observedConfig = configCaptor.getValue();
    assertEquals(username, observedConfig.getUserName());
    assertEquals(password, observedConfig.getPassword());
    assertEquals(repositoryURL, observedConfig.getOrigin());
    verify(projectService).resolveProject(same(repo));
    assertSame(project, observedProject);
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) RepositoryEnvironmentConfigurations(org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) 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