use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class BuildServiceImplTest method testBuild.
@Test
public void testBuild() {
when(buildServiceHelper.localBuild(module)).thenReturn(buildResults);
BuildResults result = buildService.build(module);
assertEquals(buildResults, result);
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class ModuleDataModelConcurrencyTest method testConcurrentResourceUpdates.
@Test
public void testConcurrentResourceUpdates() throws URISyntaxException {
final URL pomUrl = this.getClass().getResource("/DataModelBackendTest1/pom.xml");
final org.uberfire.java.nio.file.Path nioPomPath = ioService.get(pomUrl.toURI());
final Path pomPath = paths.convert(nioPomPath);
final URL resourceUrl = this.getClass().getResource("/DataModelBackendTest1/src/main/resources/empty.rdrl");
final org.uberfire.java.nio.file.Path nioResourcePath = ioService.get(resourceUrl.toURI());
final Path resourcePath = paths.convert(nioResourcePath);
// Force full build before attempting incremental changes
final KieModule module = moduleService.resolveModule(resourcePath);
final BuildResults buildResults = buildService.build(module);
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
// Perform incremental build
final int THREADS = 200;
final Result result = new Result();
ExecutorService es = Executors.newCachedThreadPool();
for (int i = 0; i < THREADS; i++) {
final int operation = (i % 3);
switch(operation) {
case 0:
es.execute(new Runnable() {
@Override
public void run() {
try {
logger.debug("[Thread: " + Thread.currentThread().getName() + "] Request to update POM received");
invalidateCaches(module, pomPath);
buildChangeListener.updateResource(pomPath);
logger.debug("[Thread: " + Thread.currentThread().getName() + "] POM update completed");
} catch (Throwable e) {
result.setFailed(true);
result.setMessage(e.getMessage());
ExceptionUtils.printRootCauseStackTrace(e);
}
}
});
break;
case 1:
es.execute(new Runnable() {
@Override
public void run() {
try {
logger.debug("[Thread: " + Thread.currentThread().getName() + "] Request to update Resource received");
invalidateCaches(module, resourcePath);
buildChangeListener.addResource(resourcePath);
logger.debug("[Thread: " + Thread.currentThread().getName() + "] Resource update completed");
} catch (Throwable e) {
result.setFailed(true);
result.setMessage(e.getMessage());
ExceptionUtils.printRootCauseStackTrace(e);
}
}
});
break;
case 2:
es.execute(new Runnable() {
@Override
public void run() {
try {
logger.debug("[Thread: " + Thread.currentThread().getName() + "] Request for DataModel received");
dataModelService.getDataModel(resourcePath);
logger.debug("[Thread: " + Thread.currentThread().getName() + "] DataModel request completed");
} catch (Throwable e) {
result.setFailed(true);
result.setMessage(e.getMessage());
ExceptionUtils.printRootCauseStackTrace(e);
}
}
});
}
}
es.shutdown();
try {
es.awaitTermination(5, TimeUnit.MINUTES);
} catch (InterruptedException e) {
}
if (result.isFailed()) {
fail(result.getMessage());
}
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class BuilderKieScannerWarningIntegrationTest method testBuilderKieScannerWarning.
@Test
public // https://bugzilla.redhat.com/show_bug.cgi?id=1161577
void testBuilderKieScannerWarning() throws URISyntaxException {
final URL resourceUrl = this.getClass().getResource("/BuilderKieScannerRepo/src/main/resources/update.drl");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
final Path resourcePath = paths.convert(nioResourcePath);
// Build and look for warnings..
final KieModule module = moduleService.resolveModule(resourcePath);
final BuildResults buildResults = buildService.build(module);
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class BuildExecutorTest method testBuildAndDeployCommandFail.
@Test
public void testBuildAndDeployCommandFail() {
BuildMessage message = mock(BuildMessage.class);
List<BuildMessage> messages = new ArrayList<>();
messages.add(message);
BuildResults results = mock(BuildResults.class);
when(results.getErrorMessages()).thenReturn(messages);
when(buildServiceMock.buildAndDeploy(any(KieModule.class), any(DeploymentMode.class))).thenReturn(results);
buildExecutor.triggerBuildAndDeploy();
verifyNotification(ProjectEditorResources.CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR);
verifyBusyShowHideAnyString(1, 1, ProjectEditorResources.CONSTANTS.Building());
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class BuildExecutorTest method testBuildCommandFail.
@Test
public void testBuildCommandFail() {
BuildMessage message = mock(BuildMessage.class);
List<BuildMessage> messages = new ArrayList<>();
messages.add(message);
BuildResults results = mock(BuildResults.class);
when(results.getErrorMessages()).thenReturn(messages);
when(buildServiceMock.build(any(KieModule.class))).thenReturn(results);
buildExecutor.triggerBuild();
verifyNotification(ProjectEditorResources.CONSTANTS.BuildFailed(), NotificationEvent.NotificationType.ERROR);
verifyBusyShowHideAnyString(1, 1, ProjectEditorResources.CONSTANTS.Building());
}
Aggregations