Search in sources :

Example 56 with Metadata

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Example 57 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("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());
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Map(java.util.Map) Test(org.junit.Test)

Example 58 with Metadata

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);
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) HashMap(java.util.HashMap) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Package(org.guvnor.common.services.project.model.Package) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 59 with Metadata

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));
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Example 60 with Metadata

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) 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