Search in sources :

Example 6 with ProjectImports

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

the class ProjectScreenModelLoaderTest method testImports.

@Test
public void testImports() throws Exception {
    final ProjectImports projectImports = new ProjectImports();
    when(projectImportsService.load(importsPath)).thenReturn(projectImports);
    final Metadata metadata = new Metadata();
    when(metadataService.getMetadata(importsPath)).thenReturn(metadata);
    ProjectScreenModel model = loader.load(pathToPom);
    assertEquals(importsPath, model.getPathToImports());
    assertEquals(projectImports, model.getProjectImports());
    assertEquals(metadata, model.getProjectImportsMetaData());
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 7 with ProjectImports

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

the class ProjectScreenServiceImplTest method setup.

@Before
public void setup() {
    projectImports = new ProjectImports();
    moduleRepositories = new ModuleRepositories();
    loader = new ProjectScreenModelLoader(moduleService, pomService, metadataService, kModuleService, importsService, repositoriesService, allowListService, projectService) {

        @Override
        protected boolean fileExists(final Path path) {
            return true;
        }
    };
    saver = new ProjectScreenModelSaver(pomService, kModuleService, importsService, repositoriesService, allowListService, ioService, moduleService, repositoryResolver, commentedOptionFactory, pomModelCache);
    service = new ProjectScreenServiceImpl(projectService, repositoryService, moduleService, loader, saver, repositoryCopier, pomService, metadataService, newProjectEvent);
    when(module.getKModuleXMLPath()).thenReturn(pathToKieModule);
    when(module.getImportsPath()).thenReturn(pathToModuleImports);
    when(module.getRepositoriesPath()).thenReturn(pathToModuleRepositories);
    when(module.getPom()).thenReturn(pom);
    when(pathToPom.toURI()).thenReturn("default://pom.xml");
    when(pomService.load(eq(pathToPom))).thenReturn(pom);
    when(kModuleService.load(eq(pathToKieModule))).thenReturn(kmodule);
    when(importsService.load(eq(pathToModuleImports))).thenReturn(projectImports);
    when(repositoriesService.load(eq(pathToModuleRepositories))).thenReturn(moduleRepositories);
    when(moduleService.resolveModule(eq(pathToPom))).thenReturn(module);
    when(metadataService.getMetadata(eq(pathToPom))).thenReturn(pomMetaData);
    when(metadataService.getMetadata(eq(pathToKieModule))).thenReturn(kmoduleMetaData);
    when(metadataService.getMetadata(eq(pathToModuleImports))).thenReturn(projectImportsMetaData);
    when(projectService.resolveProject((Path) any())).thenReturn(spy(new WorkspaceProject(mock(OrganizationalUnit.class), new GitRepository("alias", mock(Space.class), emptyList()), mock(Branch.class), mock(Module.class))));
}
Also used : Path(org.uberfire.backend.vfs.Path) ModuleRepositories(org.guvnor.common.services.project.model.ModuleRepositories) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Branch(org.guvnor.structure.repositories.Branch) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) Module(org.guvnor.common.services.project.model.Module) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Before(org.junit.Before)

Example 8 with ProjectImports

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

the class ProjectScreenModelSaverTest method testImportsSave.

@Test
public void testImportsSave() throws Exception {
    final ProjectScreenModel model = new ProjectScreenModel();
    final ProjectImports projectImports = new ProjectImports();
    model.setProjectImports(projectImports);
    final Path pathToImports = mock(Path.class);
    model.setPathToImports(pathToImports);
    final Metadata metadata = new Metadata();
    model.setProjectImportsMetaData(metadata);
    saver.save(pathToPom, model, DeploymentMode.FORCED, "message imports");
    verify(importsService).save(eq(pathToImports), eq(projectImports), eq(metadata), eq("message imports"));
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) MavenRepositoryMetadata(org.guvnor.common.services.project.model.MavenRepositoryMetadata) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 9 with ProjectImports

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

the class ProjectScreenModelTest method testHashCode.

@Test
public void testHashCode() {
    final ProjectScreenModel model = new ProjectScreenModel();
    model.setPOM(new POM("test", "test", "url", new GAV("groupID", "artifactID", "version")));
    final MavenRepository repository = new MavenRepository();
    repository.setId("guvnor-m2-repo");
    repository.setName("Guvnor M2 Repo");
    repository.setUrl("http://localhost/maven2/");
    model.getPOM().addRepository(repository);
    model.setPOMMetaData(new Metadata());
    model.setKModule(new KModuleModel());
    model.setKModuleMetaData(new Metadata());
    model.setProjectTagsMetaData(new Metadata());
    model.setProjectImports(new ProjectImports());
    model.setProjectImportsMetaData(new Metadata());
    final int hashCode1 = model.hashCode();
    assertTrue(hashCode1 <= Integer.MAX_VALUE);
    assertTrue(hashCode1 >= Integer.MIN_VALUE);
    model.getProjectImports().getImports().addImport(new Import("java.lang.List"));
    final int hashCode2 = model.hashCode();
    assertTrue(hashCode2 <= Integer.MAX_VALUE);
    assertTrue(hashCode2 >= Integer.MIN_VALUE);
    assertNotEquals(hashCode1, hashCode2);
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) MavenRepository(org.guvnor.common.services.project.model.MavenRepository) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) GAV(org.guvnor.common.services.project.model.GAV) POM(org.guvnor.common.services.project.model.POM) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 10 with ProjectImports

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

the class ExternalDataObjectsPresenterTest method testSetup.

@Test
public void testSetup() {
    final ProjectScreenModel model = mock(ProjectScreenModel.class);
    doReturn(new ProjectImports()).when(model).getProjectImports();
    externalDataObjectsPresenter.setup(model).catch_(i -> {
        Assert.fail("Promise should've been resolved!");
        return promises.resolve();
    });
    verify(view).init(eq(externalDataObjectsPresenter));
    verify(itemPresenters).setup(any(), any(), any());
}
Also used : ProjectImports(org.guvnor.common.services.project.model.ProjectImports) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Aggregations

ProjectImports (org.guvnor.common.services.project.model.ProjectImports)18 Test (org.junit.Test)12 Import (org.kie.soup.project.datamodel.imports.Import)8 Path (org.uberfire.backend.vfs.Path)8 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)6 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)4 InputStream (java.io.InputStream)2 ConversionResult (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult)2 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 GAV (org.guvnor.common.services.project.model.GAV)2 MavenRepository (org.guvnor.common.services.project.model.MavenRepository)2 POM (org.guvnor.common.services.project.model.POM)2 Imports (org.kie.soup.project.datamodel.imports.Imports)2 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)2 KieModule (org.kie.workbench.common.services.shared.project.KieModule)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 PomModel (org.appformer.maven.support.PomModel)1