Search in sources :

Example 21 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class MainDataObjectFieldEditor method onNameChange.

@Override
public void onNameChange() {
    if (getObjectField() == null) {
        return;
    }
    view.setNameOnError(false);
    final String oldValue = getObjectField().getName();
    final String newValue = DataModelerUtils.unCapitalize(view.getName());
    final String originalClassName = getContext() != null ? getContext().getEditorModelContent().getOriginalClassName() : null;
    final Path currentPath = getContext() != null && getContext().getEditorModelContent() != null ? getContext().getEditorModelContent().getPath() : null;
    if (originalClassName != null) {
        showAssetUsagesDisplayer.showAssetPartUsages(Constants.INSTANCE.modelEditor_confirm_renaming_of_used_field(oldValue), currentPath, originalClassName, oldValue, PartType.FIELD, () -> doFieldNameChange(oldValue, newValue), () -> view.setName(oldValue));
    } else {
        doFieldNameChange(oldValue, newValue);
    }
}
Also used : Path(org.uberfire.backend.vfs.Path)

Example 22 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class DMNPathsHelperImplTest method testGetStandaloneRootPath.

@Test
public void testGetStandaloneRootPath() {
    final Path path = mock(Path.class);
    final org.uberfire.java.nio.file.Path expectedPath = mock(org.uberfire.java.nio.file.Path.class);
    doReturn(path).when(pathsHelper).newPath(STANDALONE_FILE_NAME, STANDALONE_URI);
    doReturn(expectedPath).when(pathsHelper).convertPath(path);
    final org.uberfire.java.nio.file.Path actualPath = pathsHelper.getStandaloneRootPath();
    assertEquals(expectedPath, actualPath);
}
Also used : Path(org.uberfire.backend.vfs.Path) Test(org.junit.Test)

Example 23 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class DMNMarshallerImportsHelperStandaloneImplTest method testGetPMMLDocumentPaths.

@Test
public void testGetPMMLDocumentPaths() {
    final Metadata metadata = mock(Metadata.class);
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Path projectPath = mock(Path.class);
    when(metadata.getPath()).thenReturn(projectPath);
    when(projectService.resolveProject(any(Path.class))).thenReturn(project);
    helper.getPMMLDocumentPaths(metadata);
    verify(projectService).resolveProject(projectPath);
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Test(org.junit.Test)

Example 24 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class DMNMarshallerImportsHelperStandaloneImplTest method testLoadPath.

@Test
public void testLoadPath() {
    final Path path = mock(Path.class);
    final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class);
    final String expectedContent = "<dmn/>";
    final byte[] contentBytes = expectedContent.getBytes();
    doReturn(nioPath).when(helper).convertPath(path);
    when(ioService.newInputStream(nioPath)).thenReturn(new ByteArrayInputStream(contentBytes));
    final Optional<InputStream> inputStream = helper.loadPath(path);
    assertTrue(inputStream.isPresent());
    assertEquals(expectedContent, new Scanner(new InputStreamReader(inputStream.get())).next());
}
Also used : Path(org.uberfire.backend.vfs.Path) Scanner(java.util.Scanner) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 25 with Path

use of org.uberfire.backend.vfs.Path in project kie-wb-common by kiegroup.

the class DMNMarshallerImportsHelperStandaloneImplTest method testGetPMMLDocuments.

@Test
public void testGetPMMLDocuments() {
    final Path dmnModelPath = mock(Path.class);
    final Metadata metadata = mock(Metadata.class);
    final PMMLDocumentMetadata pmmlDocument = mock(PMMLDocumentMetadata.class);
    final Import import1 = mock(Import.class);
    final List<Import> imports = singletonList(import1);
    final Path path1 = mock(Path.class);
    final Path path2 = mock(Path.class);
    final List<Path> paths = asList(path1, path2);
    when(metadata.getPath()).thenReturn(dmnModelPath);
    when(import1.getLocationURI()).thenReturn("document1.pmml");
    when(pathsHelper.getRelativeURI(dmnModelPath, path1)).thenReturn("document1.pmml");
    when(pathsHelper.getRelativeURI(dmnModelPath, path2)).thenReturn("document2.pmml");
    when(pmmlDocumentFactory.getDocumentByPath(path1)).thenReturn(pmmlDocument);
    doReturn(paths).when(helper).getPMMLDocumentPaths(metadata);
    final Map<Import, PMMLDocumentMetadata> importDefinitions = helper.getPMMLDocuments(metadata, imports);
    assertEquals(1, importDefinitions.size());
    assertEquals(pmmlDocument, importDefinitions.get(import1));
}
Also used : Path(org.uberfire.backend.vfs.Path) Import(org.kie.dmn.model.api.Import) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Test(org.junit.Test)

Aggregations

Path (org.uberfire.backend.vfs.Path)607 Test (org.junit.Test)408 URL (java.net.URL)93 Package (org.guvnor.common.services.project.model.Package)87 KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)71 CreationalContext (javax.enterprise.context.spi.CreationalContext)66 Bean (javax.enterprise.inject.spi.Bean)66 ArrayList (java.util.ArrayList)63 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)51 Module (org.guvnor.common.services.project.model.Module)48 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)41 KieModule (org.kie.workbench.common.services.shared.project.KieModule)38 List (java.util.List)37 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)30 Branch (org.guvnor.structure.repositories.Branch)29 HashMap (java.util.HashMap)28 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)28 ObservablePath (org.uberfire.backend.vfs.ObservablePath)27 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)25 Before (org.junit.Before)25