private Path decodePath(String uri, String prefix) { final String name = uri.substring(uri.lastIndexOf('/') + 1, uri.length()); final String decodedURI = uri.substring(prefix.length(), uri.length()); return PathFactory.newPath(name, decodedURI); }
public FileSystemImpl(final Map<String, String> roots, final Set<String> supportedViews) { checkNotNull("roots", roots); this.rootDirectories = new ArrayList<Path>(roots.size()); for (final Map.Entry<String, String> entry : roots.entrySet()) { this.rootDirectories.add(newPath(entry.getValue(), entry.getKey())); } this.supportedViews = new HashSet<String>(checkNotNull("supportedViews", supportedViews)); }
private Path getEmptyScenarioPath() throws URISyntaxException { final URL scenarioResource = getClass().getResource(EMPTY_SCENARIO_FILENAME); return PathFactory.newPath(scenarioResource.getFile(), scenarioResource.toURI().toString()); } }
@Test public void checkNPE() { final Map<Path, String> hashMap = new HashMap<>(); final Path path = newPath("defaultPackage", "default://guvnor-jcr2vfs-migration/defaultPackage/"); hashMap.put(path, "content"); assertThat(hashMap.get(path)).isEqualTo("content"); assertThat(hashMap.get(newPath("defaultPackage", "default://guvnor-jcr2vfs-migration/defaultPackage/"))).isEqualTo("content"); } }
private Path getVersionedPath() { return PathFactory.newPath("fileName", "uri", new HashMap<String, Object>() { { put(PathFactory.VERSION_PROPERTY, true); } }); }
private Path stripFileName( final Path path ) { String uri = path.toURI(); uri = uri.replace( path.getFileName(), "" ); return PathFactory.newPath( path.getFileSystem(), path.getFileName(), uri ); }
@Override public org.uberfire.java.nio.file.Path answer(InvocationOnMock invocationOnMock) throws Throwable { return Paths.convert(PathFactory.newPath("file", invocationOnMock.getArguments()[0].toString())); } }).when(ioService).get(any(URI.class));
@Test public void scoreTypeChangedScoreHolderGlobalFileNonExisting() { Path sourcePath = PathFactory.newPath("TestSource.java", "file:///dataObjects"); Path destinationPath = PathFactory.newPath("TestSource.java", "file:///dataObjects"); testPlanningSolutionSaved(false, sourcePath, destinationPath); }
@Override public org.uberfire.java.nio.file.Path answer(InvocationOnMock invocationOnMock) throws Throwable { return Paths.convert(PathFactory.newPath("file", invocationOnMock.getArguments()[0].toString())); } }).when(ioService).get(any(URI.class));
private void mockIoService() { final String artifact = "existentModule"; final String uri = repository.getUri() + fileSystem.getSeparator() + artifact; final Path path = PathFactory.newPath(artifact, uri); doReturn(fileSystem).when(ioService).getFileSystem(any(URI.class)); doReturn(Paths.convert(path)).when(ioService).get(eq(uri)); doReturn(true).when(ioService).exists(eq(Paths.convert(path))); } }
@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(); }
private WorkspaceProject makeProject(final Repository repository, final OrganizationalUnit organizationalUnit, final String moduleName) throws IOException { final Module module = mock(Module.class); when(module.getModuleName()).thenReturn(moduleName); return new WorkspaceProject(organizationalUnit, repository, new Branch("master", PathFactory.newPath("testFile", "file:///" + moduleName)), module); }
@Test public void addDepTest() { DynamicPomDependency dep = new DynamicPomDependency("junit", "junit", "4.12", ""); boolean result = editor.addDependency(dep, PathFactory.newPath(tmp.toAbsolutePath().toString() + File.separator + POM, tmp.toUri().toString() + File.separator + POM)); assertThat(result).isTrue(); }
@Test public void addDuplicatedDepTest() { DynamicPomDependency dep = new DynamicPomDependency(TestUtil.GROUP_ID_TEST, TestUtil.ARTIFACT_ID_TEST, TestUtil.VERSION_ID_TEST, ""); 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 addNullGroupIDTest() { DynamicPomDependency dep = new DynamicPomDependency(null, "junit", "4.12", ""); 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 boolean hasPersistenceFile(Path path) { KieModule kieModule = moduleService.resolveModule(path); if (kieModule != null && kieModule.getRootPath() != null) { //ok, we have a well formed project String persistenceURI = kieModule.getRootPath().toURI() + "/src/main/resources/META-INF/persistence.xml"; Path persistencePath = PathFactory.newPath("persistence.xml", persistenceURI); return ioService.exists(Paths.convert(persistencePath)); } return false; }
@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"); }
private String targetFileName(final String originalFileName, final String newFileName) { final Path path = PathFactory.newPath(originalFileName, PATH_PREFIX + originalFileName); fileSystemTestingUtils.getIoService().write(Paths.convert(path), "content"); return pathNamingService.buildTargetPath(path, newFileName).getFileName(); }