@Override public String getMessage(final Path path) { return path.toURI() + " cannot be deleted, moved or renamed. It contains the following locked files: " + lockInfos; } };
@Override protected Map<String, String> getParameters() { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("path", path.toURI()); return parameters; }
/** * <p>Returns the download URL for a given file provided by a servlet method.</p> * @param path The path of the file. */ public String getDownloadFileUrl(final Path path) { final StringBuilder sb = new StringBuilder(GWT.getModuleBaseURL() + EXPORT_SERVLET_URL); sb.append("?").append("path").append("=").append(URL.encode(path.toURI())); return sb.toString(); }
protected ConfigGroup findProjectConfig(final Path projectRoot) { final Collection<ConfigGroup> groups = configurationService.getConfiguration(ConfigType.PROJECT); if (groups != null) { for (ConfigGroup groupConfig : groups) { if (groupConfig.getName().equals(projectRoot.toURI())) { return groupConfig; } } } return null; }
private Path stripFileName( final Path path ) { String uri = path.toURI(); uri = uri.replace( path.getFileName(), "" ); return PathFactory.newPathBasedOn( path.getFileName(), uri, path ); }
protected Predicate<ValidationMessage> fromValidatedPath(final Path path) { return message -> { final String destinationPathURI = removeFileExtension(Paths.normalizePath(path).toURI()); final String messageURI = message.getPath() != null ? removeFileExtension(Paths.normalizePath(message.getPath()).toURI()) : ""; return messageURI.isEmpty() || destinationPathURI.endsWith(messageURI); }; }
private void thenPathWasNotCopiedIfExists(final Path path, final RuntimeException e) { assertEquals(path.toURI() + " cannot be copied.", e.getMessage()); }
private Path stripFileName( final Path path ) { String uri = path.toURI(); uri = uri.replace( path.getFileName(), "" ); return PathFactory.newPath( path.getFileSystem(), path.getFileName(), uri ); }
private void thenPathWasNotDeleted(final Path path, final RuntimeException e) { assertEquals(path.toURI() + " cannot be deleted, moved or renamed. It is locked by: lockedBy", e.getMessage()); }
protected List<Path> getQueryList(Path assetPath, RefactorOperationBuilder<QueryOperationRequest>.RequiresModule builder) { KieModule project = moduleService.resolveModule(assetPath); String branch = "master"; org.uberfire.java.nio.file.Path nioPath = Paths.convert(assetPath); if (nioPath instanceof SegmentedPath) { branch = ((SegmentedPath) nioPath).getSegmentId(); } QueryOperationRequest request = builder.inModuleRootPathURI(project.getRootPath().toURI()).onBranch(branch); return refactoringQueryService.queryToList(request).stream().map(row -> (Path) row.getValue()).collect(Collectors.toList()); } }
protected KieModule getKieModuleMock(final String testModuleRoot, final String testModuleName) { final org.uberfire.backend.vfs.Path mockRoot = mock(org.uberfire.backend.vfs.Path.class); when(mockRoot.toURI()).thenReturn(testModuleRoot); final KieModule mockModule = mock(KieModule.class); when(mockModule.getRootPath()).thenReturn(mockRoot); when(mockModule.getModuleName()).thenReturn(testModuleName); return mockModule; }
@Test public void lockTest() { Path path = mock(Path.class); when(path.toURI()).thenReturn("default://master@myteam/dora/src/main/resources/com/myteam/dora/sample.drl"); assertEquals("default://locks@system/system/myteam/master/dora/src/main/resources/com/myteam/dora/sample.drl.ulock", PathFactory.newLock(path).toURI()); Path lockPath = PathFactory.newLockPath(path); Path extractedPath = PathFactory.fromLock(lockPath); assertEquals(path.toURI(), extractedPath.toURI()); } }
@Test public void testReImport() throws Exception { when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://project1/pom.xml"); when(resourceResolver.resolveProject(any(Path.class))).thenReturn(project); abstractProjectService.reImport(path); verify(invalidateDMOCache).fire(any(InvalidateDMOProjectCacheEvent.class)); }
@Test public void testDownload() { final String expectedDownloadURL = "defaulteditor/download?path=default://master@MySpace/Mortgages/src/main/resources/rule.drl"; when(path.toURI()).thenReturn("default://master@MySpace/Mortgages/src/main/resources/rule.drl"); doNothing().when(downloadMenuItem).open(any()); downloadMenuItem.download(pathSupplier); verify(downloadMenuItem).open(eq(expectedDownloadURL)); } }
public static ProjectConcurrentChangePopup newConcurrentChange( final Path project, final User identity, final Command onIgnore, final Command onReOpen ) { final String message = ProjectConcurrentChangePopupConstants.INSTANCE.ConcurrentChange( identity != null ? SafeHtmlUtils.htmlEscape( identity.getIdentifier() != null ? identity.getIdentifier() : "" ) : null, project.toURI() ); return new ProjectConcurrentChangePopup( message, onIgnore, onReOpen ); }
@Before public void setup() { this.service = new RuleNameServiceImpl(queryService, projectService); when(projectService.resolveModule(any(Path.class))).thenReturn(module); when(module.getRootPath()).thenReturn(projectRootPath); when(projectRootPath.toURI()).thenReturn(PROJECT_ROOT_URI); when(queryService.query(eq(FindRulesByModuleQuery.NAME), anySetOf(ValueIndexTerm.class))).thenReturn(getResults()); }
@Test public void returnModule() throws Exception { doReturn(new POM()).when(pomService).load(pathArgumentCaptor.capture()); assertNotNull(resolver.makeModule(Paths.convert(PathFactory.newPath("testFile", "file:///testFile")))); final String pathThatWasUsedToLoadTheModulePomXml = pathArgumentCaptor.getValue().toURI(); assertThat(pathThatWasUsedToLoadTheModulePomXml).endsWith(":///testFile/pom.xml"); }