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