Search in sources :

Example 16 with Metadata

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

the class GuidedDecisionTreeEditorServiceImplTest 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 GuidedDecisionTree content = mock(GuidedDecisionTree.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) GuidedDecisionTree(org.drools.workbench.models.guided.dtree.shared.model.GuidedDecisionTree) Test(org.junit.Test)

Example 17 with Metadata

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

the class GuidedDecisionTableEditorPresenterTest method testGetMetadataSupplier.

@Test
public void testGetMetadataSupplier() {
    final GuidedDecisionTableView.Presenter document = mock(GuidedDecisionTableView.Presenter.class);
    final Overview overview = mock(Overview.class);
    final Metadata expectedMetadata = mock(Metadata.class);
    doReturn(document).when(presenter).getActiveDocument();
    doReturn(overview).when(document).getOverview();
    doReturn(expectedMetadata).when(overview).getMetadata();
    final Metadata actualMetadata = presenter.getMetadataSupplier().get();
    assertEquals(expectedMetadata, actualMetadata);
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Test(org.junit.Test)

Example 18 with Metadata

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

the class GuidedRuleEditorServiceImpl method save.

@Override
public Path save(final Path resource, final RuleModel model, final Metadata metadata, final String comment) {
    try {
        final Package pkg = moduleService.resolvePackage(resource);
        final String packageName = (pkg == null ? null : pkg.getPackageName());
        model.setPackageName(packageName);
        Metadata currentMetadata = metadataService.getMetadata(resource);
        ioService.write(Paths.convert(resource), toSourceUnexpanded(resource, model), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
        fireMetadataSocialEvents(resource, currentMetadata, metadata);
        return resource;
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Package(org.guvnor.common.services.project.model.Package) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 19 with Metadata

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

the class GuidedRuleEditorServiceImplTest 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 RuleModel content = mock(RuleModel.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) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Example 20 with Metadata

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

the class GuidedScoreCardEditorServiceImpl method save.

@Override
public Path save(final Path resource, final ScoreCardModel model, final Metadata metadata, final String comment) {
    try {
        final Package pkg = moduleService.resolvePackage(resource);
        final String packageName = (pkg == null ? null : pkg.getPackageName());
        model.setPackageName(packageName);
        Metadata currentMetadata = metadataService.getMetadata(resource);
        ioService.write(Paths.convert(resource), GuidedScoreCardXMLPersistence.getInstance().marshal(model), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
        fireMetadataSocialEvents(resource, currentMetadata, metadata);
        return resource;
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Package(org.guvnor.common.services.project.model.Package) SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

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