@Override public String getKey() { return path.toUri().toString(); } };
protected String getBranchName(final org.uberfire.java.nio.file.Path path) { URI uri = path.toUri(); String gitBranch = uri.getAuthority(); if (gitBranch.indexOf("@") != -1) { return gitBranch.split("@")[0]; } return gitBranch; } }
public static String makeErrorMessage( final Path path, final DroolsError... errors ) { final StringBuilder sb = new StringBuilder( "Unable to parse DRL for '" ).append( path.toUri().toString() ).append( "'." ); for ( DroolsError error : errors ) { sb.append( "\n" ).append( error.getMessage() ); } return sb.toString(); }
@Override public boolean accepts( final Path path ) { final String pattern = getPattern(); final String suffix = "." + pattern; final String uri = path.toUri().toString(); return uri.substring( uri.length() - suffix.length() ).equals( suffix ); }
private String destinationPath(final Path resource) { final String destinationPath = EncodingUtil.decode(resource.toUri().toString().substring(projectPrefix.length())); if (destinationPath.startsWith("/")) { // File in sub module return destinationPath.substring(1); } else { // File in main module return destinationPath; } }
public Path getPath(Path path, String version) throws URISyntaxException { String authority = path.toUri().getAuthority(); // master@uf-playground authority = version + authority.substring(authority.indexOf("@")); String scheme = path.getFileSystem().provider().getScheme(); // git String rawPath = path.toUri().getRawPath(); // projectname/org/something/file.txt String uri = scheme + "://" + authority + rawPath; return ioService.get(new URI(uri)); }
public Path getPath(Path path, String version) throws URISyntaxException { String authority = path.toUri().getAuthority(); // master@uf-playground authority = version + authority.substring(authority.indexOf("@")); String scheme = path.getFileSystem().provider().getScheme(); // git String rawPath = path.toUri().getRawPath(); // projectname/org/something/file.txt String uri = scheme + "://" + authority + rawPath; return ioService.get(new URI(uri)); }
@Override public Object value() { return file.toUri().toString(); } });
@Override public Path write( Path path, String content, OpenOption... options ) throws IllegalArgumentException, IOException, UnsupportedOperationException { fileSystem.put( path.toUri().getPath(), content ); return path; }
private Path makePath(final String prefix, final String suffix) throws URISyntaxException { Path path = mock(Path.class); when( path.toUri() ).thenReturn( new URI(prefix + suffix) ); return path; }
private void assertContains(String uri, List<org.uberfire.java.nio.file.Path> allValues) { boolean contains = false; for (org.uberfire.java.nio.file.Path path : allValues) { if (uri.equals(path.toUri())) { contains = true; break; } } assertTrue("Values should contain " + uri, contains); } //
@Before public void setup() throws Exception { rootUri = new URI(ROOT_URI); when(fileSystem.supportedFileAttributeViews()).thenReturn(FS_ATTRIBUTES); when(rootPath.toUri()).thenReturn(rootUri); when(rootPath.getFileSystem()).thenReturn(fileSystem); doAnswer((Answer<org.uberfire.java.nio.file.Path>) invocationOnMock -> { final URI arg = (URI) invocationOnMock.getArguments()[0]; return arg.toURL().toString().equals(ROOT_URI) ? rootPath : null; }).when(ioService).get(any(URI.class)); tested = new VFSServicesServerImpl(ioService); }
@Override public URI toUri() throws IOException, SecurityException { if (!isAbsolute()) { return toAbsolutePath().toUri(); } if (fs.provider().isDefault() && !isRealPath) { return URI.create("default://" + host + toURIString()); } return URI.create(fs.provider().getScheme() + "://" + host + toURIString()); }
protected void assertContains(final Iterable<KObject> results, final Path path) { for (KObject kObject : results) { final String key = kObject.getKey(); final String fileName = path.getFileName().toString(); if (key.endsWith(fileName)) { return; } } fail("Results do not contain expected Path '" + path.toUri().toString()); }
@Test public void addNullDepTest() { boolean result = editor.addDependency(null, PathFactory.newPath(tmp.toAbsolutePath().toString() + File.separator + POM, tmp.toUri().toString() + File.separator + POM)); assertThat(result).isFalse(); }
@Test public void addDuplicatedDepsTest() { DynamicPomDependency dep = new DynamicPomDependency(TestUtil.GROUP_ID_TEST, TestUtil.ARTIFACT_ID_TEST, TestUtil.VERSION_ID_TEST, ""); List<DynamicPomDependency> deps = Arrays.asList(dep); boolean result = editor.addDependencies(deps, PathFactory.newPath(tmp.toAbsolutePath().toString() + File.separator + POM, tmp.toUri().toString() + File.separator + POM)); assertThat(result).isFalse(); }
@Test public void addEmptyDepTest() { DynamicPomDependency dep = new DynamicPomDependency("", "", "", ""); boolean result = editor.addDependency(dep, PathFactory.newPath(tmp.toAbsolutePath().toString() + File.separator + POM, tmp.toUri().toString() + File.separator + POM)); assertThat(result).isFalse(); }
@Test public void addNullArtifactIDTest() { DynamicPomDependency dep = new DynamicPomDependency("junit", null, "4.12", ""); boolean result = editor.addDependency(dep, PathFactory.newPath(tmp.toAbsolutePath().toString() + File.separator + POM, tmp.toUri().toString() + File.separator + POM)); assertThat(result).isFalse(); }
public BaseCompilerTest(String prjName) { try { mavenRepoPath = TestUtilMaven.getMavenRepo(); tmpRoot = Files.createTempDirectory("repo"); alternateSettingsAbsPath = new File("src/test/settings.xml").getAbsolutePath(); Path tmp = Files.createDirectories(Paths.get(tmpRoot.toString(), "dummy")); TestUtil.copyTree(Paths.get(prjName), tmp); info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri())); } catch (Exception e) { logger.error(e.getMessage()); } }
@Test public void checkGetFileStore() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); assertThat(fsProvider.getFileStore(path)).isNotNull(); assertThat(fsProvider.getFileSystem(path.toUri()).getFileStores()).isNotNull().contains(fsProvider.getFileStore(path)); }