use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class WorkItemsEditorServiceImplTest 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 String content = "content";
final String comment = "comment";
service.saveAndRename(path, newFileName, metadata, content, comment);
verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
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("file://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());
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class GlobalsEditorServiceImpl method createInternal.
private Path createInternal(final Path context, final String fileName, final GlobalsModel content, final String comment, final boolean generate) {
try {
final Package pkg = moduleService.resolvePackage(context);
final String packageName = (pkg == null ? null : pkg.getPackageName());
content.setPackageName(packageName);
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
if (generate) {
Metadata metadata = MetadataBuilder.newMetadata().withGenerated(true).build();
ioService.write(nioPath, GlobalsPersistence.getInstance().marshal(content), metadataService.configAttrs(new HashMap<>(), metadata), commentedOptionFactory.makeCommentedOption(comment));
} else {
ioService.write(nioPath, GlobalsPersistence.getInstance().marshal(content), commentedOptionFactory.makeCommentedOption(comment));
}
return newPath;
} 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 EnumServiceImplTest method testSave.
@Test
public void testSave() throws Exception {
final String fileName = "enum.enumeration";
final String fileContent = "'Person.age' : [10,20,30]\n";
final String comment = "comment of the author";
final Metadata metadata = mock(Metadata.class);
final Path path = PathFactory.newPath(fileName, getClass().getResource("enums").toString());
when(commentedOptionFactory.makeCommentedOption(comment)).thenReturn(commentedOption);
when(metadataService.setUpAttributes(path, metadata)).thenReturn(Collections.EMPTY_MAP);
enumService.save(path, fileContent, metadata, comment);
verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), eq(fileContent), eq(Collections.EMPTY_MAP), eq(commentedOption));
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class EnumServiceImplTest 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 String content = "content";
final String comment = "comment";
enumService.saveAndRename(path, newFileName, metadata, content, comment);
verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
Aggregations