Search in sources :

Example 51 with Metadata

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

the class ScenarioSimulationServiceImplTest method saveAndRename.

@Test
public void saveAndRename() {
    final Metadata metadata = mock(Metadata.class);
    final ScenarioSimulationModel model = new ScenarioSimulationModel();
    service.saveAndRename(path, "newName.scesim", metadata, model, "comment");
    verify(saveAndRenameServiceMock).saveAndRename(path, "newName.scesim", metadata, model, "comment");
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Test(org.junit.Test)

Example 52 with Metadata

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

the class DecisionTableXLSToDecisionTableGuidedConverter method createNewImports.

private void createNewImports(final Path context, final List<Import> imports, final ConversionResult result) {
    if (imports == null || imports.isEmpty()) {
        return;
    }
    // Get Module's project.imports path
    final KieModule module = moduleService.resolveModule(context);
    final Path externalImportsPath = module.getImportsPath();
    // Load existing PackageImports
    final ProjectImports projectImports = loadProjectImports(externalImportsPath);
    // Make collections of existing Imports so we don't duplicate them when adding the new
    List<String> existingImports = new ArrayList<>();
    for (org.kie.soup.project.datamodel.imports.Import item : projectImports.getImports().getImports()) {
        existingImports.add(item.getType());
    }
    // Add imports
    boolean isModified = false;
    for (Import item : imports) {
        if (!existingImports.contains(item.getClassName())) {
            isModified = true;
            result.addMessage("Created Import for '" + item.getClassName() + "'.", ConversionMessageType.INFO);
            projectImports.getImports().addImport(new org.kie.soup.project.datamodel.imports.Import(item.getClassName()));
        }
    }
    // Save update
    if (isModified) {
        final Metadata metadata = metadataService.getMetadata(context);
        importsService.save(externalImportsPath, projectImports, metadata, "Imports added during XLS conversion");
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Import(org.drools.template.model.Import) ArrayList(java.util.ArrayList) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) KieModule(org.kie.workbench.common.services.shared.project.KieModule)

Example 53 with Metadata

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

the class DSLTextEditorServiceImplTest method testSaveAndRename.

@Test
public void testSaveAndRename() throws Exception {
    final Path path = mock(Path.class);
    final String newFileName = "newFileName";
    final Metadata metadata = mock(Metadata.class);
    final String content = "content";
    final String comment = "comment";
    service.saveAndRename(path, newFileName, metadata, content, comment);
    verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Example 54 with Metadata

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

the class DRLTextEditorServiceImplTest method testSave.

@Test
public void testSave() throws Exception {
    final String ruleContent = "rule \"empty\" when then";
    final String creationComment = "initial version";
    final Metadata metadata = mock(Metadata.class);
    when(metadataService.setUpAttributes(path, metadata)).thenReturn(Collections.EMPTY_MAP);
    when(commentedOptionFactory.makeCommentedOption(creationComment)).thenReturn(commentedOption);
    drlService.save(path, ruleContent, metadata, creationComment);
    verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), eq(ruleContent), eq(Collections.EMPTY_MAP), eq(commentedOption));
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 55 with Metadata

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

the class GuidedRuleTemplateEditorServiceImplTest method testSaveAndRename.

@Test
public void testSaveAndRename() throws Exception {
    final Path path = mock(Path.class);
    final String newFileName = "newFileName";
    final Metadata metadata = mock(Metadata.class);
    final TemplateModel content = mock(TemplateModel.class);
    final String comment = "comment";
    service.saveAndRename(path, newFileName, metadata, content, comment);
    verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) Test(org.junit.Test)

Aggregations

Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)75 Test (org.junit.Test)63 Path (org.uberfire.backend.vfs.Path)44 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)13 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)10 POM (org.guvnor.common.services.project.model.POM)8 HashMap (java.util.HashMap)6 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)6 ObservablePath (org.uberfire.backend.vfs.ObservablePath)6 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)5 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)5 GAV (org.guvnor.common.services.project.model.GAV)4 AllowList (org.kie.workbench.common.services.shared.allowlist.AllowList)4 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)4 Matchers.anyString (org.mockito.Matchers.anyString)4 Map (java.util.Map)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 WhiteList (org.kie.workbench.common.services.shared.whitelist.WhiteList)3