private Path getWorkingDir(String workingDir){ if(workingDir!= null){ return Paths.get("file://"+workingDir); } return null; }
private Map<Path, InputStream> handleMap(final Git git, final Map<Path, InputStream> override) { final Map<Path, InputStream> result = new HashMap<>(override.size()); for (Map.Entry<Path, InputStream> entry : override.entrySet()) { if (entry.getKey().getFileSystem() instanceof JGitFileSystem) { final Path convertedToCheckedPath = Paths.get(git.getRepository().getDirectory().toPath().getParent().resolve(entry.getKey().toString().substring(1)).toUri()); result.put(convertedToCheckedPath, entry.getValue()); } } return result; }
public static Optional<ClassLoader> loadDependenciesClassloaderFromProject(String prjPath, String localRepo) { List<String> poms = MavenUtils.searchPoms(Paths.get(URI.create(CommonConstants.FILE_URI + prjPath))); List<URL> urls = getDependenciesURL(poms, localRepo); return buildResult(urls); }
private boolean processFoundPoms(List<String> poms, CompilationRequest request) { boolean result = true; for (String pom : poms) { Path tmpPom = Paths.get(URI.create(FILE_URI + pom)); PomPlaceHolder tmpPlaceHolder = editor.readSingle(tmpPom); if (!isPresent(tmpPlaceHolder)) { result = result && editor.write(tmpPom, request); } } return result; }
Repository getEventRepository(SocialActivitiesEvent event) { final Path path = Paths.get(event.getLinkTarget()); final FileSystem fileSystem = path.getFileSystem(); return configuredRepositories.getRepositoryByRepositoryFileSystem(fileSystem); }
WorkspaceProject getEventModule(final SocialActivitiesEvent event) { final Path path = Paths.get(event.getLinkTarget()); final org.uberfire.backend.vfs.Path vfsPath = org.uberfire.backend.server.util.Paths.convert(path); return projectService.resolveProject(vfsPath); } }
@Test public void newInputStreamNonExistent() { assertThatThrownBy(() -> Files.newInputStream(Paths.get("/path/to/some/file.txt"))) .isInstanceOf(NoSuchFileException.class); }
@Test public void readAttributesMapNoSuchFileException() { final Path path = Paths.get("/path/to/file.txt"); assertThatThrownBy(() -> Files.readAttributes(path, "*")) .isInstanceOf(NoSuchFileException.class); }
@Test public void getLastModifiedTimeNoSuchFileException() { final Path path = Paths.get("/path/to/file"); assertThatThrownBy(() -> Files.getLastModifiedTime(path)) .isInstanceOf(NoSuchFileException.class); }
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 buildRemoteAndInstallSkipDepsExistentProject() throws Exception { AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.buildAndInstall(Paths.get(tmpRoot.toAbsolutePath() + "/dummy").toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile(), Boolean.TRUE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); assertThat(res.getDependencies()).isEmpty(); }
@Test public void buildAndInstallSkipDepsExistentProject() throws Exception{ DefaultRemoteExecutor executor = new DefaultRemoteExecutor(executorService); CompletableFuture<KieCompilationResponse> futureRes = executor.buildAndInstall(Paths.get(tmpRoot.toAbsolutePath()+"/dummy").toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile(), Boolean.TRUE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); assertThat(res.getDependencies()).isEmpty(); }
@Test public void buildSpecializedSkipDepsExistentProject() throws Exception { AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.buildSpecialized(Paths.get(tmpRoot.toAbsolutePath() + "/dummy"), mavenRepoPath, new String[]{ MavenCLIArgs.ALTERNATE_USER_SETTINGS + TestUtilMaven.getSettingsFile(), MavenCLIArgs.COMPILE}, Boolean.TRUE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); }
@Test public void buildSpecializedSkipDepsExistentProject() throws Exception{ DefaultRemoteExecutor executor = new DefaultRemoteExecutor(executorService); CompletableFuture<KieCompilationResponse> futureRes = executor.buildSpecialized(Paths.get(tmpRoot.toAbsolutePath()+"/dummy").toAbsolutePath().toString(), mavenRepoPath, new String[]{MavenCLIArgs.ALTERNATE_USER_SETTINGS + TestUtilMaven.getSettingsFile(), MavenCLIArgs.COMPILE}, Boolean.TRUE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); }
@Test public void buildRemoteSpecializedSkipDepsExistentProject() throws Exception { AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.buildSpecialized(Paths.get(tmpRoot.toAbsolutePath() + "/dummy").toAbsolutePath().toString(), mavenRepoPath, new String[]{MavenCLIArgs.ALTERNATE_USER_SETTINGS + TestUtilMaven.getSettingsFile(), MavenCLIArgs.COMPILE}, Boolean.TRUE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); }
@Test public void buildRemoteAndInstallExistentProject() throws Exception { AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.buildAndInstall(Paths.get(tmpRoot.toAbsolutePath() + "/dummy").toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile()); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); assertThat(res.getDependencies()).isNotEmpty(); assertThat(res.getDependencies().size()).isGreaterThan(0); }
@Test public void buildAndInstallExistentProject() throws Exception{ DefaultRemoteExecutor executor = new DefaultRemoteExecutor(executorService); CompletableFuture<KieCompilationResponse> futureRes = executor.buildAndInstall(Paths.get(tmpRoot.toAbsolutePath()+"/dummy").toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile()); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); assertThat(res.getDependencies()).isNotEmpty(); assertThat(res.getDependencies().size()).isGreaterThan(0); }
@Test public void buildAndInstallExistentProject() throws Exception { AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.buildAndInstall(Paths.get(tmpRoot.toAbsolutePath() + "/dummy"), mavenRepoPath, TestUtilMaven.getSettingsFile()); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); assertThat(res.getDependencies()).isNotEmpty(); assertThat(res.getDependencies().size()).isGreaterThan(0); }
@Test public void buildAndInstallExistentProject() throws Exception{ DefaultLocalExecutor executor = new DefaultLocalExecutor(executorService); CompletableFuture<KieCompilationResponse> futureRes = executor.buildAndInstall(Paths.get(tmpRoot.toAbsolutePath()+"/dummy"), mavenRepoPath, TestUtilMaven.getSettingsFile()); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isTrue(); assertThat(res.getDependencies()).isNotEmpty(); assertThat(res.getDependencies().size()).isGreaterThan(0); }
@Test public void isReadable() { final Path path = Files.createTempFile("foo", "bar"); assertThat(Files.isReadable(path)).isTrue(); assertThat(Files.isReadable(newTempDir())).isTrue(); assertThat(Files.isReadable(Paths.get("/some/file"))).isFalse(); }