Search in sources :

Example 71 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 72 with Metadata

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

the class ScenarioTestEditorServiceImpl method save.

@Override
public Path save(final Path resource, final Scenario content, final Metadata metadata, final String comment) {
    try {
        Metadata currentMetadata = metadataService.getMetadata(resource);
        ioService.write(Paths.convert(resource), ScenarioXMLPersistence.getInstance().marshal(content), 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) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 73 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project appformer by kiegroup.

the class MetadataCreatorTest method testGeneratedAttributes.

@Test
public void testGeneratedAttributes() {
    when(generatedFileAttributes.isGenerated()).thenReturn(true);
    when(generatedAttributesView.readAttributes()).thenReturn(generatedFileAttributes);
    Metadata metadata = service.create();
    assertTrue(metadata.isGenerated());
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Example 74 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project appformer by kiegroup.

the class MetadataServiceImplTest method testSaveMetaData.

@Test
public void testSaveMetaData() throws IOException {
    final InputStream is = spy(new ByteArrayInputStream("hello".getBytes(StandardCharsets.UTF_8)));
    doReturn(is).when(ioService).newInputStream(any(), any());
    final CommentedOption comment = new CommentedOption("comment");
    doReturn(comment).when(commentedOptionFactory).makeCommentedOption("comment");
    service.saveMetadata(Paths.convert(path), new Metadata(), "comment");
    verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), any(byte[].class), anyMap(), eq(comment));
    verify(is).close();
}
Also used : Path(org.uberfire.java.nio.file.Path) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 75 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project appformer by kiegroup.

the class MetadataServiceImplTest method testSaveMetaDataException.

@Test(expected = GenericPortableException.class)
public void testSaveMetaDataException() throws IOException {
    final InputStream is = new ByteArrayInputStream("hello".getBytes(StandardCharsets.UTF_8));
    try {
        doReturn(is).when(ioService).newInputStream(any(), any());
        PowerMockito.mockStatic(IOUtils.class);
        BDDMockito.given(IOUtils.toByteArray(Mockito.<InputStream>any())).willThrow(IOException.class);
        service.saveMetadata(Paths.convert(path), new Metadata(), "comment");
    } finally {
        is.close();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) 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