Search in sources :

Example 6 with OrganizationalUnit

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

the class BaseViewPresenterTest method testAutomaticModuleBuildDisabled.

@Test
public void testAutomaticModuleBuildDisabled() {
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    final Repository repository = mock(Repository.class);
    final Module module = mock(Module.class);
    ApplicationPreferences.setUp(new HashMap<String, String>() {

        {
            put(ExplorerService.BUILD_PROJECT_PROPERTY_NAME, "true");
        }
    });
    when(activeContextItems.setupActiveModule(content)).thenReturn(true);
    final WorkspaceProject project = mock(WorkspaceProject.class);
    when(project.getOrganizationalUnit()).thenReturn(ou);
    when(project.getRepository()).thenReturn(repository);
    when(project.getBranch()).thenReturn(new Branch("master", mock(Path.class)));
    when(activeContextItems.getActiveProject()).thenReturn(project);
    when(activeContextItems.getActiveModule()).thenReturn(module);
    presenter.doContentCallback(content);
    verify(buildServiceActual, never()).build(any(Module.class));
}
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 7 with OrganizationalUnit

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

the class ProjectScreenServiceImplTest method testCopyNoPOM.

@Test
public void testCopyNoPOM() throws Exception {
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    final Path projectRoot = mock(Path.class);
    doReturn(ou).when(project).getOrganizationalUnit();
    doReturn(projectRoot).when(project).getRootPath();
    final Repository newRepository = mock(Repository.class);
    final Path newRepositoryRoot = PathFactory.newPath("root", "file:///root");
    doReturn(Optional.of(new Branch("master", newRepositoryRoot))).when(newRepository).getDefaultBranch();
    doReturn(newRepository).when(repositoryCopier).copy(ou, "newName", projectRoot);
    doReturn(null).when(pomService).load(any(Path.class));
    service.copy(project, "newName");
    verify(repositoryCopier).copy(ou, "newName", projectRoot);
    verify(metadataService, never()).getMetadata(any(Path.class));
    verify(pomService, never()).save(any(Path.class), any(POM.class), any(Metadata.class), anyString(), anyBoolean());
}
Also used : Path(org.uberfire.backend.vfs.Path) 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) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) MavenRepositoryMetadata(org.guvnor.common.services.project.model.MavenRepositoryMetadata) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 8 with OrganizationalUnit

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

the class NewWorkspaceProjectHandler method getCommand.

@Override
public Command getCommand(final NewResourcePresenter newResourcePresenter) {
    return new Command() {

        @Override
        public void execute() {
            if (!context.getActiveOrganizationalUnit().isPresent()) {
                ouService.call(new RemoteCallback<OrganizationalUnit>() {

                    @Override
                    public void callback(OrganizationalUnit organizationalUnit) {
                        projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(organizationalUnit));
                        init();
                    }
                }).getOrganizationalUnit(libraryPreferences.getOrganizationalUnitPreferences().getName());
            } else {
                init();
            }
        }
    };
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Command(org.uberfire.mvp.Command) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 9 with OrganizationalUnit

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

the class NewWorkspaceProjectWizardTest method testSetContentGAV.

@Test
public void testSetContentGAV() throws Exception {
    preferences.put("kie_version", "1.3.0");
    OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getDefaultGroupId()).thenReturn("mygroup");
    when(moduleContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
    POM pom = new POM();
    pom.setName("another module");
    pom.getGav().setArtifactId("another.artifact");
    pom.getGav().setGroupId("another.group");
    pom.getGav().setVersion("1.2.3");
    wizard.initialise(pom);
    ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
    verify(pomWizardPage).setPom(pomArgumentCaptor.capture());
    POM result = pomArgumentCaptor.getValue();
    assertEquals("1.2.3", result.getGav().getVersion());
    assertEquals("another.artifact", result.getGav().getArtifactId());
    assertEquals("another.group", result.getGav().getGroupId());
    assertEquals("another module", result.getName());
    assertEquals(1, result.getBuild().getPlugins().size());
    assertEquals("1.3.0", result.getBuild().getPlugins().get(0).getVersion());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 10 with OrganizationalUnit

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

the class ContributorsManager method buildDataSet.

@Override
public DataSet buildDataSet(Map<String, String> params) {
    final DataSetBuilder dsBuilder = DataSetFactory.newDataSetBuilder();
    for (final DataColumnDef columnDef : dataSetdef.getColumns()) {
        dsBuilder.column(columnDef.getId(), columnDef.getColumnType());
    }
    final Collection<OrganizationalUnit> orgUnitList = organizationalUnitService.getOrganizationalUnits();
    for (final OrganizationalUnit orgUnit : orgUnitList) {
        final String org = orgUnit.getName();
        final Collection<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(orgUnit);
        if (projects.isEmpty()) {
            // org
            dsBuilder.row(// org
            org, // repo
            null, // project
            null, // author
            null, // message
            "Empty organizational unit", // date
            null);
        } else {
            for (final WorkspaceProject project : projects) {
                final String repoAlias = project.getRepository().getAlias();
                final String projectName = project.getName();
                org.uberfire.backend.vfs.Path rootPath = project.getRootPath();
                final Path projectRoot = Paths.convert(rootPath);
                final List<VersionRecord> recordList = recordService.loadVersionRecords(projectRoot);
                if (recordList.isEmpty()) {
                    // org
                    dsBuilder.row(// org
                    org, // repo
                    repoAlias, // project
                    null, // author
                    null, // mesage
                    "Empty project", // date
                    null);
                } else {
                    for (VersionRecord record : recordList) {
                        String alias = record.author();
                        String author = authorMappings.getProperty(alias);
                        author = author == null ? alias : author;
                        String msg = record.comment();
                        Date date = record.date();
                        dsBuilder.row(org, repoAlias, projectName, author, msg, date);
                    }
                }
            }
        }
    }
    DataSet dataSet = dsBuilder.buildDataSet();
    dataSet.setUUID(GIT_CONTRIB);
    return dataSet;
}
Also used : Path(org.uberfire.java.nio.file.Path) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) DataSet(org.dashbuilder.dataset.DataSet) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) DataSetBuilder(org.dashbuilder.dataset.DataSetBuilder) Date(java.util.Date) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) DataColumnDef(org.dashbuilder.dataset.def.DataColumnDef)

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