use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class DefaultRemoteExecutorTest method buildAndInstallNonExistentProject.
@Test
public void buildAndInstallNonExistentProject() throws Exception {
DefaultRemoteExecutor executor = new DefaultRemoteExecutor(executorService);
CompletableFuture<KieCompilationResponse> futureRes = executor.buildAndInstall(tmpRoot.toAbsolutePath().toString(), mavenRepoPath, TestUtilMaven.getSettingsFile());
KieCompilationResponse res = futureRes.get();
assertThat(res.isSuccessful()).isFalse();
}
use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class ClassLoaderProviderTest method getResourcesFromADroolsPRJ.
@Test
// https://issues.redhat.com/browse/AF-2892
@Ignore
public void getResourcesFromADroolsPRJ() throws Exception {
/**
* If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
*/
String alternateSettingsAbsPath = TestUtilMaven.getSettingsFile();
Path tmpRoot = Files.createTempDirectory("repo");
Path tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_SINGLE_RESOURCES);
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.STORE_KIE_OBJECTS, KieDecorator.STORE_BUILD_CLASSPATH, KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri()));
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
if (!res.isSuccessful()) {
List<String> msgs = res.getMavenOutput();
for (String msg : msgs) {
logger.info(msg);
}
}
assertThat(res.isSuccessful()).isTrue();
Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
assertThat(metaDataOptional).isPresent();
KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
assertThat(kieModuleMetaInfo).isNotNull();
Optional<KieModule> kieModuleOptional = res.getKieModule();
assertThat(kieModuleOptional).isPresent();
KieModule kModule = kieModuleOptional.get();
assertThat(res.getDependenciesAsURI()).hasSize(4);
KieModuleMetaData kieModuleMetaData = new KieModuleMetaDataImpl((InternalKieModule) kModule, res.getDependenciesAsURI());
assertThat(kieModuleMetaData).isNotNull();
List<String> resources = CompilerClassloaderUtils.getStringFromTargets(tmpRoot);
assertThat(resources).hasSize(3);
}
use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class ClassLoaderProviderTest method getResourcesFromADroolsPRJWithErrorWithMavenSkip.
@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void getResourcesFromADroolsPRJWithErrorWithMavenSkip() throws Exception {
System.setProperty(MAVEN_MAIN_SKIP, Boolean.TRUE.toString());
/**
* If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
*/
Path tmpRoot = Files.createTempDirectory("repo");
Path tmp = TestUtil.createAndCopyToDirectory(tmpRoot, "dummy", ResourcesConstants.KJAR_2_SINGLE_RESOURCES_WITH_ERROR);
final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.STORE_KIE_OBJECTS, KieDecorator.ENABLE_INCREMENTAL_BUILD));
WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri()));
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + TestUtilMaven.getSettingsFile() }, Boolean.FALSE);
KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
TestUtil.saveMavenLogIfCompilationResponseNotSuccessfull(tmp, res, this.getClass(), testName);
if (!res.isSuccessful()) {
List<String> msgs = res.getMavenOutput();
for (String msg : msgs) {
logger.info(msg);
}
}
assertThat(res.isSuccessful()).isTrue();
Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
assertThat(metaDataOptional).isPresent();
KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
assertThat(kieModuleMetaInfo).isNotNull();
Optional<KieModule> kieModuleOptional = res.getKieModule();
assertThat(kieModuleOptional).isPresent();
List<String> classloaderOptional = CompilerClassloaderUtils.getStringFromTargets(tmpRoot);
assertThat(classloaderOptional).hasSize(3);
}
use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class KieAfterDecoratorTest method compileWithouKieMavenPlugin.
@Test
public void compileWithouKieMavenPlugin() throws Exception {
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, createdNewPrjInRepo("normal-dummy", ResourcesConstants.DUMMY), new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
KieAfterDecorator decorator = new KieAfterDecorator(new BaseMavenCompiler(false, false));
KieCompilationResponse kieRes = (KieCompilationResponse) decorator.compile(req);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(kieRes.isSuccessful()).isTrue();
softly.assertThat(kieRes.getMavenOutput()).isEmpty();
softly.assertThat(kieRes.getKieModule()).isNotNull();
softly.assertThat(kieRes.getKieModuleMetaInfo()).isNotNull();
});
}
use of org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse in project kie-wb-common by kiegroup.
the class KieAfterDecoratorTest method compileWithOverrideTest.
@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void compileWithOverrideTest() throws Exception {
Map<Path, InputStream> override = new HashMap<>();
Path path = Paths.get(tmpRoot + "/src/main/java/org/kie/maven/plugin/test/Person.java");
InputStream input = new FileInputStream(new File(ResourcesConstants.KJAR_2_SINGLE_RESOURCES_OVERRIDE + "/src/main/java/org/kie/maven/plugin/test/Person.java"));
override.put(path, input);
CompilationRequest req = new DefaultCompilationRequest(mavenRepoPath, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE);
KieAfterDecorator decorator = new KieAfterDecorator(new BaseMavenCompiler(false, false));
KieCompilationResponse kieRes = (KieCompilationResponse) decorator.compile(req, override);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(kieRes.isSuccessful()).isTrue();
softly.assertThat(kieRes.getMavenOutput()).isEmpty();
softly.assertThat(kieRes.getKieModule()).isNotNull();
softly.assertThat(kieRes.getKieModuleMetaInfo()).isNotNull();
});
}
Aggregations