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);
}
}
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);
}
}
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());
}
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();
}
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();
}
}
Aggregations