Search in sources :

Example 11 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption in project kie-wb-common by kiegroup.

the class AbstractVFSDiagramService method saveOrUpdateSvg.

@Override
public Path saveOrUpdateSvg(Path diagramPath, String rawDiagramSvg) {
    final org.uberfire.java.nio.file.Path svgPath = getDiagramSvgFilePath(getDiagramByPath(diagramPath));
    LOG.info("Saving diagram SVG " + svgPath);
    getIoService().write(svgPath, rawDiagramSvg, new CommentedOption(identity.getIdentifier()));
    return convertToBackendPath(svgPath);
}
Also used : CommentedOption(org.uberfire.java.nio.base.options.CommentedOption)

Example 12 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption in project kie-wb-common by kiegroup.

the class ProjectDiagramServiceImplTest method testSaveAsXml.

@Test
public void testSaveAsXml() {
    final String xml = "xml";
    final String comment = "comment";
    final Map<String, Object> attributes = Collections.singletonMap("key", "value");
    final Path path = mock(Path.class);
    final Metadata metadata = mock(Metadata.class);
    final CommentedOption options = mock(CommentedOption.class);
    when(metadataService.setUpAttributes(path, metadata)).thenReturn(attributes);
    when(commentedOptionFactory.makeCommentedOption(comment)).thenReturn(options);
    diagramService.saveAsXml(path, xml, metadata, comment);
    verify(diagramServiceController, times(1)).saveAsXml(eq(path), eq(xml), eq(attributes), eq(options));
}
Also used : Path(org.uberfire.backend.vfs.Path) 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 13 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption 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 = Collections.singletonMap("key", "value");
    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) 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 14 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption in project kie-wb-common by kiegroup.

the class ProjectDiagramServiceControllerTest method testSaveAsXml.

@Test
public void testSaveAsXml() {
    final Path path = mock(Path.class);
    final String xml = "xml";
    final Map<String, ?> attributes = Collections.singletonMap("key", "value");
    final CommentedOption option = mock(CommentedOption.class);
    when(path.toURI()).thenReturn(FILE_URI);
    final org.uberfire.java.nio.file.Path expectedNioPath = Paths.convert(path);
    ((ProjectDiagramServiceController) diagramService).saveAsXml(path, xml, attributes, option);
    verify(ioService, times(1)).write(eq(expectedNioPath), eq(xml), eq(attributes), eq(option));
}
Also used : Path(org.uberfire.backend.vfs.Path) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) AbstractVFSDiagramServiceTest(org.kie.workbench.common.stunner.core.backend.service.AbstractVFSDiagramServiceTest) Test(org.junit.Test)

Example 15 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption in project kie-wb-common by kiegroup.

the class BPMNVFSFormDefinitionGeneratorServiceTest method setup.

@Before
public void setup() throws IOException {
    when(projectService.resolveModule(any())).thenReturn(module);
    when(projectClassLoaderHelper.getModuleClassLoader(module)).thenReturn(this.getClass().getClassLoader());
    source = mock(Path.class);
    simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    when(source.toURI()).thenReturn("default:///src/main/resources/test.frm");
    when(commentedOptionFactory.makeCommentedOption(Mockito.<String>any())).then(invocationOnMock -> new CommentedOption("1", invocationOnMock.getArguments()[0].toString()));
    formModelHandlerManager = new TestFormModelHandlerManager(projectService, projectClassLoaderHelper, fieldManager, modelFinderService);
    when(modelReaderService.getModelReader(any())).thenReturn(modelReader);
    service = new BPMNVFSFormDefinitionGeneratorService(fieldManager, modelReaderService, formModelHandlerManager, formFinderService, formSerializer, ioService, commentedOptionFactory, new FormModelSynchronizationUtilImpl(fieldManager, templateGenerator));
}
Also used : Path(org.uberfire.backend.vfs.Path) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) TestFormModelHandlerManager(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.test.TestFormModelHandlerManager) FormModelSynchronizationUtilImpl(org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl) Before(org.junit.Before)

Aggregations

CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)19 Test (org.junit.Test)11 Path (org.uberfire.backend.vfs.Path)8 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)6 HashMap (java.util.HashMap)3 Before (org.junit.Before)2 ProjectMetadata (org.kie.workbench.common.stunner.project.diagram.ProjectMetadata)2 Path (org.uberfire.java.nio.file.Path)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URISyntaxException (java.net.URISyntaxException)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 Event (javax.enterprise.event.Event)1 IOUtils (org.apache.commons.io.IOUtils)1 DecisionTableParseException (org.drools.template.parser.DecisionTableParseException)1 DecisionTableXLSConversionService (org.drools.workbench.screens.dtablexls.service.DecisionTableXLSConversionService)1