@Override public void createDirectory(final Path dir, final FileAttribute<?>... attrs) throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull("dir", dir); final Path realDir = dir.toAbsolutePath(); if (realDir.toFile().exists()) { throw new FileAlreadyExistsException(dir.toString()); } realDir.toFile().mkdirs(); }
public DefaultHttpCompilationResponse(KieCompilationResponse res) { this.successful = res.isSuccessful(); this.mavenOutput = new ArrayList<>(res.getMavenOutput()); if (res.getWorkingDir().isPresent()) { this.workingDir = res.getWorkingDir().get().toAbsolutePath().toString(); } else { this.workingDir = StringUtils.EMPTY; } this.targetContent = new ArrayList<>(res.getTargetContent()); this.projectDependencies = new ArrayList<>(res.getDependencies()); }
@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{ 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 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 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 addDepsTest() { DynamicPomDependency dep = new DynamicPomDependency("junit", "junit", "4.12", ""); 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).isTrue(); }
@Test public void buildAndSkipDepsNonExistentProject() throws Exception{ DefaultRemoteExecutor executor = new DefaultRemoteExecutor(executorService); CompletableFuture<KieCompilationResponse> futureRes = executor.build(tmpRoot.toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile(), Boolean.FALSE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isFalse(); assertThat(res.getDependencies()).isEmpty(); }
@Test public void buildRemoteAndInstallSkipDepsNonExistentProject() throws Exception { AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.buildAndInstall(tmpRoot.toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile(), Boolean.FALSE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isFalse(); assertThat(res.getDependencies()).isEmpty(); }
@Test public void buildRemoteAndSkipDepsNonExistentProject() throws Exception { AFCompilerService service = new DefaultKieCompilerService(); CompletableFuture<KieCompilationResponse> futureRes = service.build(tmpRoot.toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile(), Boolean.FALSE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isFalse(); assertThat(res.getDependencies()).isEmpty(); }
@Test public void buildSpecializedNonExistentProject() throws Exception{ DefaultRemoteExecutor executor = new DefaultRemoteExecutor(executorService); CompletableFuture<KieCompilationResponse> futureRes = executor.buildSpecialized(tmpRoot.toAbsolutePath().toString(), mavenRepoPath, new String[]{MavenCLIArgs.ALTERNATE_USER_SETTINGS + TestUtilMaven.getSettingsFile(), MavenCLIArgs.COMPILE}); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isFalse(); }
@Test public void buildSpecializedSkipDepsNonExistentProject() throws Exception{ DefaultRemoteExecutor executor = new DefaultRemoteExecutor(executorService); CompletableFuture<KieCompilationResponse> futureRes = executor.buildSpecialized(tmpRoot.toAbsolutePath().toString(), mavenRepoPath, new String[]{MavenCLIArgs.ALTERNATE_USER_SETTINGS + TestUtilMaven.getSettingsFile(), MavenCLIArgs.COMPILE}, Boolean.TRUE); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).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(); }
@Test public void buildNonExistentProject() throws Exception{ DefaultRemoteExecutor executor = new DefaultRemoteExecutor(executorService); CompletableFuture<KieCompilationResponse> futureRes = executor.build(tmpRoot.toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile()); KieCompilationResponse res = futureRes.get(); assertThat(res.isSuccessful()).isFalse(); }
@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 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 { 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); }