Search in sources :

Example 26 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata 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 27 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.

the class ProjectScreenModelLoaderTest method testKModule.

@Test
public void testKModule() throws Exception {
    final KModuleModel kModuleModel = new KModuleModel();
    when(kModuleService.load(kmoduleXMLPath)).thenReturn(kModuleModel);
    final Metadata metadata = new Metadata();
    when(metadataService.getMetadata(kmoduleXMLPath)).thenReturn(metadata);
    ProjectScreenModel model = loader.load(pathToPom);
    assertEquals(kmoduleXMLPath, model.getPathToKModule());
    assertEquals(kModuleModel, model.getKModule());
    assertEquals(metadata, model.getKModuleMetaData());
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 28 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.

the class ProjectScreenModelLoaderTest method testLoadPom.

@Test
public void testLoadPom() throws Exception {
    final POM pom = new POM();
    when(pomService.load(pathToPom)).thenReturn(pom);
    final Metadata metadata = new Metadata();
    when(metadataService.getMetadata(pathToPom)).thenReturn(metadata);
    ProjectScreenModel model = loader.load(pathToPom);
    assertEquals(pathToPom, model.getPathToPOM());
    assertEquals(pom, model.getPOM());
    assertEquals(metadata, model.getPOMMetaData());
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 29 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.

the class ProjectScreenModelSaverTest method checkPOMSaveInvalidatesPomModelCache.

@Test
public void checkPOMSaveInvalidatesPomModelCache() {
    // See https://issues.jboss.org/browse/RHBRMS-2822
    // Saving the pom.xml (eventually) triggers an InvalidateDMOProjectCacheEvent once VFS's WatchService
    // has observed the file change after the batch has been committed. The InvalidateDMOProjectCacheEvent then
    // invalidates the PomModelCache. The PomModelCache is used to find the Project's GAV when the Project is
    // "Built (& Deployed)" and if it's content is stale can lead to the generated KJAR containing the
    // wrong GAV. Therefore invalidate the PomModelCache as soon as the save starts.
    final ProjectScreenModel model = new ProjectScreenModel();
    final Metadata pomMetaData = new Metadata();
    final POM pom = new POM();
    model.setPOM(pom);
    model.setPOMMetaData(pomMetaData);
    KieModule module = mock(KieModule.class);
    when(moduleService.resolveModule(pathToPom)).thenReturn(module);
    saver.save(pathToPom, model, DeploymentMode.FORCED, "message");
    verify(pomModelCache).invalidateCache(module);
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) KieModule(org.kie.workbench.common.services.shared.project.KieModule) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 30 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata 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) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Aggregations

Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)62 Test (org.junit.Test)45 Path (org.uberfire.backend.vfs.Path)35 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)13 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)9 Package (org.guvnor.common.services.project.model.Package)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 HashMap (java.util.HashMap)5 POM (org.guvnor.common.services.project.model.POM)5 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)5 ObservablePath (org.uberfire.backend.vfs.ObservablePath)5 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)5 Overview (org.guvnor.common.services.shared.metadata.model.Overview)4 WhiteList (org.kie.workbench.common.services.shared.whitelist.WhiteList)4 Map (java.util.Map)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 InvalidateDMOPackageCacheEvent (org.guvnor.common.services.project.builder.events.InvalidateDMOPackageCacheEvent)3 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)3 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)3 Mockito.anyString (org.mockito.Mockito.anyString)3