use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderTest method testPomResourceUpdated.
@Test
public void testPomResourceUpdated() throws Exception {
// This tests changes pom.xml
final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/pom.xml");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(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 (Without a full Build first)
buildChangeListener.updateResource(resourcePath);
waitForBuildResults(buildResultsObserver);
final BuildResults buildResults2 = buildResultsObserver.getBuildResults();
assertNotNull(buildResults2);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNull(incrementalBuildResults);
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderTest method testNonPackageResourceUpdated.
@Test
public void testNonPackageResourceUpdated() throws Exception {
// This tests changes to a resource that is neither pom.xml nor kmodule.xml nor within a Package
final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/project.imports");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(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 (Without a full Build first)
buildChangeListener.updateResource(resourcePath);
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNull(incrementalBuildResults);
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderTest method testBatchResourceChanges.
@Test
public void testBatchResourceChanges() throws Exception {
final URL resourceUrl1 = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/add.drl");
final org.uberfire.java.nio.file.Path nioResourcePath1 = fs.getPath(resourceUrl1.toURI());
final Path resourcePath1 = paths.convert(nioResourcePath1);
final URL resourceUrl2 = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/update.drl");
final org.uberfire.java.nio.file.Path nioResourcePath2 = fs.getPath(resourceUrl2.toURI());
final Path resourcePath2 = paths.convert(nioResourcePath2);
final URL resourceUrl3 = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/delete.drl");
final org.uberfire.java.nio.file.Path nioResourcePath3 = fs.getPath(resourceUrl3.toURI());
final Path resourcePath3 = paths.convert(nioResourcePath3);
// final Set<ResourceChange> batch = new HashSet<ResourceChange>();
// batch.add( new ResourceChange( ChangeType.ADD,
// resourcePath1,
// new SessionInfoImpl( "id",
// new IdentityImpl( "user",
// Collections.<Role>emptyList() ) ) ) );
// batch.add( new ResourceChange( ChangeType.UPDATE,
// resourcePath2,
// new SessionInfoImpl( "id",
// new IdentityImpl( "user",
// Collections.<Role>emptyList() ) ) ) );
// batch.add( new ResourceChange( ChangeType.DELETE,
// resourcePath3,
// new SessionInfoImpl( "id",
// new IdentityImpl( "user",
// Collections.<Role>emptyList() ) ) ) );
final Map<Path, Collection<ResourceChange>> batch = new HashMap<Path, Collection<ResourceChange>>();
batch.put(resourcePath1, new ArrayList<ResourceChange>() {
{
add(new ResourceAdded(""));
}
});
batch.put(resourcePath2, new ArrayList<ResourceChange>() {
{
add(new ResourceUpdated(""));
}
});
batch.put(resourcePath3, new ArrayList<ResourceChange>() {
{
add(new ResourceUpdated(""));
}
});
// Force full build before attempting incremental changes
final KieModule module = moduleService.resolveModule(resourcePath1);
final BuildResults buildResults = buildService.build(module);
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
// Perform incremental build
buildChangeListener.batchResourceChanges(batch);
waitForIncrementalBuildResults(buildResultsObserver);
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNotNull(incrementalBuildResults);
assertEquals(0, incrementalBuildResults.getAddedMessages().size());
assertEquals(0, incrementalBuildResults.getRemovedMessages().size());
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderWithoutFullBuildTest method testBatchResourceChanges.
@Test
public void testBatchResourceChanges() throws Exception {
final Bean buildChangeListenerBean = (Bean) beanManager.getBeans(org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(buildChangeListenerBean);
final org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder buildChangeListener = (org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder) beanManager.getReference(buildChangeListenerBean, org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class, cc);
final URL resourceUrl1 = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/add.drl");
final org.uberfire.java.nio.file.Path nioResourcePath1 = fs.getPath(resourceUrl1.toURI());
final Path resourcePath1 = paths.convert(nioResourcePath1);
final URL resourceUrl2 = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/update.drl");
final org.uberfire.java.nio.file.Path nioResourcePath2 = fs.getPath(resourceUrl2.toURI());
final Path resourcePath2 = paths.convert(nioResourcePath2);
final URL resourceUrl3 = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/delete.drl");
final org.uberfire.java.nio.file.Path nioResourcePath3 = fs.getPath(resourceUrl3.toURI());
final Path resourcePath3 = paths.convert(nioResourcePath3);
final Map<Path, Collection<ResourceChange>> batch = new HashMap<Path, Collection<ResourceChange>>();
batch.put(resourcePath1, new ArrayList<ResourceChange>() {
{
add(new ResourceAdded(""));
}
});
batch.put(resourcePath2, new ArrayList<ResourceChange>() {
{
add(new ResourceUpdated(""));
}
});
batch.put(resourcePath3, new ArrayList<ResourceChange>() {
{
add(new ResourceUpdated(""));
}
});
// batch.add( new ResourceChange( ResourceChangeType.ADD,
// resourcePath1,
// new SessionInfoImpl( "id",
// new IdentityImpl( "user",
// Collections.<Role>emptyList() ) ) ) );
// batch.add( new ResourceChange( ResourceChangeType.UPDATE,
// resourcePath2,
// new SessionInfoImpl( "id",
// new IdentityImpl( "user",
// Collections.<Role>emptyList() ) ) ) );
// batch.add( new ResourceChange( ResourceChangeType.DELETE,
// resourcePath3,
// new SessionInfoImpl( "id",
// new IdentityImpl( "user",
// Collections.<Role>emptyList() ) ) ) );
// Perform incremental build (Without a full Build first)
buildChangeListener.batchResourceChanges(batch);
waitForBuildResults(buildResultsObserver);
final BuildResults buildResults = buildResultsObserver.getBuildResults();
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNull(incrementalBuildResults);
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderWithoutFullBuildTest method testResourceAdded.
@Test
public void testResourceAdded() throws Exception {
final Bean buildChangeListenerBean = (Bean) beanManager.getBeans(org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(buildChangeListenerBean);
final org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder buildChangeListener = (org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder) beanManager.getReference(buildChangeListenerBean, org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class, cc);
final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/add.drl");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
final Path resourcePath = paths.convert(nioResourcePath);
// Perform incremental build (Without a full Build first)
buildChangeListener.addResource(resourcePath);
waitForBuildResults(buildResultsObserver);
final BuildResults buildResults = buildResultsObserver.getBuildResults();
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNull(incrementalBuildResults);
}
Aggregations