Search in sources :

Example 41 with Metadata

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

the class ProjectDiagramServiceImplTest method testSave.

@Test
public void testSave() {
    Metadata metadata = mock(Metadata.class);
    String comment = "COMMENT";
    Map<String, Object> attributes = new HashMap<>();
    CommentedOption options = mock(CommentedOption.class);
    when(metadataService.setUpAttributes(path, metadata)).thenReturn(attributes);
    when(commentedOptionFactory.makeCommentedOption(comment)).thenReturn(options);
    when(diagramServiceController.save(path, diagram, attributes, options)).thenReturn(resultPath);
    Path result = diagramService.save(path, diagram, metadata, comment);
    verify(diagramServiceController, times(1)).save(path, diagram, attributes, options);
    assertEquals(resultPath, result);
}
Also used : Path(org.uberfire.backend.vfs.Path) HashMap(java.util.HashMap) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectMetadata(org.kie.workbench.common.stunner.project.diagram.ProjectMetadata) Test(org.junit.Test)

Example 42 with Metadata

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

the class PackageNameWhiteListSaverTest method testSave.

@Test
public void testSave() throws Exception {
    final Path path = testFileSystem.createTempFile("whitelist");
    final WhiteList whiteList = new WhiteList();
    whiteList.add("org.drools");
    whiteList.add("org.guvnor");
    final Metadata metadata = new Metadata();
    final String comment = "comment";
    final HashMap<String, Object> attributes = new HashMap<String, Object>();
    when(metadataService.setUpAttributes(path, metadata)).thenReturn(attributes);
    final CommentedOption commentedOption = mock(CommentedOption.class);
    when(commentedOptionFactory.makeCommentedOption("comment")).thenReturn(commentedOption);
    saver.save(path, whiteList, metadata, comment);
    ArgumentCaptor<String> whiteListTextArgumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), whiteListTextArgumentCaptor.capture(), eq(attributes), eq(commentedOption));
    final String whiteListAsText = whiteListTextArgumentCaptor.getValue();
    assertTrue(whiteListAsText.contains("org.drools"));
    assertTrue(whiteListAsText.contains("org.guvnor"));
}
Also used : Path(org.uberfire.backend.vfs.Path) HashMap(java.util.HashMap) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) WhiteList(org.kie.workbench.common.services.shared.whitelist.WhiteList) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Example 43 with Metadata

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

the class GuidedDecisionTableGraphEditorServiceImpl method save.

@Override
public Path save(final Path path, final GuidedDecisionTableEditorGraphModel model, final Metadata metadata, final String comment) {
    try {
        final Metadata currentMetadata = metadataService.getMetadata(path);
        versionEntriesPaths(model);
        ioService.write(Paths.convert(path), GuidedDTGraphXMLPersistence.getInstance().marshal(model), metadataService.setUpAttributes(path, metadata), commentedOptionFactory.makeCommentedOption(comment));
        fireMetadataSocialEvents(path, currentMetadata, metadata);
        return path;
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 44 with Metadata

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

the class GuidedDecisionTableGraphEditorServiceImplTest method checkSave.

@Test
@SuppressWarnings("unchecked")
public void checkSave() {
    final Path path = mock(Path.class);
    final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
    final Metadata metadata = mock(Metadata.class);
    final String comment = "comment";
    when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
    service.save(path, model, metadata, comment);
    verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any(CommentedOption.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Map(java.util.Map) Test(org.junit.Test)

Example 45 with Metadata

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

the class BaseGuidedDecisionTablePresenterTest method makeDecisionTableContent.

protected GuidedDecisionTableEditorContent makeDecisionTableContent(final int hashCode) {
    final GuidedDecisionTable52 model = new GuidedDecisionTable52() {

        @Override
        public int hashCode() {
            return hashCode;
        }

        @Override
        public boolean equals(Object o) {
            return super.equals(o);
        }
    };
    final Overview overview = mock(Overview.class);
    final Metadata metadata = mock(Metadata.class);
    when(overview.getMetadata()).thenReturn(metadata);
    return new GuidedDecisionTableEditorContent(model, Collections.<PortableWorkDefinition>emptySet(), overview, mock(PackageDataModelOracleBaselinePayload.class));
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) Overview(org.guvnor.common.services.shared.metadata.model.Overview)

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