Search in sources :

Example 11 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject 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 12 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class ProjectScreenServiceImplTest method testDelete.

@Test
public void testDelete() throws Exception {
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Repository repository = mock(Repository.class);
    final String ouName = "test-realm";
    final Space space = new Space(ouName);
    doReturn(repository).when(project).getRepository();
    doReturn("myrepo").when(repository).getAlias();
    doReturn(space).when(repository).getSpace();
    service.delete(project);
    verify(repositoryService).removeRepository(eq(space), eq("myrepo"));
}
Also used : Space(org.uberfire.spaces.Space) Repository(org.guvnor.structure.repositories.Repository) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Test(org.junit.Test)

Example 13 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject 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 14 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class NewWorkspaceProjectWizard method getSuccessCallback.

private RemoteCallback<WorkspaceProject> getSuccessCallback() {
    return new RemoteCallback<WorkspaceProject>() {

        @Override
        public void callback(final WorkspaceProject project) {
            NewWorkspaceProjectWizard.super.complete();
            invokeCallback(project);
            if (openEditor) {
                placeManager.goTo("ProjectSettings");
            }
            notificationEvent.fire(new NotificationEvent(CommonConstants.INSTANCE.ItemCreatedSuccessfully()));
            busyIndicatorView.hideBusyIndicator();
        }
    };
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 15 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject 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

WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)67 Test (org.junit.Test)42 Branch (org.guvnor.structure.repositories.Branch)29 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)28 Repository (org.guvnor.structure.repositories.Repository)26 Path (org.uberfire.backend.vfs.Path)26 Module (org.guvnor.common.services.project.model.Module)21 ArrayList (java.util.ArrayList)12 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)12 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)10 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)9 Before (org.junit.Before)8 KieModule (org.kie.workbench.common.services.shared.project.KieModule)7 POM (org.guvnor.common.services.project.model.POM)6 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)5 ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)5 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)5 Date (java.util.Date)4 HashSet (java.util.HashSet)4 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)4