Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2013 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.kie.workbench.common.services.datamodel.backend.server.builder;
 
 import java.net.URL;
 import java.util.List;
 
 import  org.guvnor.common.services.project.builder.model.BuildResults;
 import  org.guvnor.common.services.project.builder.service.BuildService;
 import  org.guvnor.structure.server.config.ConfigGroup;
 import  org.guvnor.structure.server.config.ConfigType;
 import  org.guvnor.structure.server.config.ConfigurationFactory;
 import  org.guvnor.structure.server.config.ConfigurationService;
 import  org.jboss.weld.environment.se.StartMain;
 import org.junit.Test;
 import  org.kie.workbench.common.services.backend.builder.LRUBuilderCache;
 import  org.kie.workbench.common.services.shared.project.KieProject;
 import  org.kie.workbench.common.services.shared.project.KieProjectService;
 import  org.uberfire.backend.server.util.Paths;
 import  org.uberfire.backend.vfs.Path;
 import  org.uberfire.java.nio.fs.file.SimpleFileSystemProvider;
 
 import static org.junit.Assert.*;
 
 public class BuilderKieScannerWarningTest {
 
     private static final String GLOBAL_SETTINGS = "settings";
 
     private final SimpleFileSystemProvider fs = new SimpleFileSystemProvider();
     private BeanManager beanManager;
 
     private Paths paths;
     private ConfigurationService configurationService;
     private ConfigurationFactory configurationFactory;
     private BuildService buildService;
     private KieProjectService projectService;
     private LRUBuilderCache builderCache;
 
     @Before
     public void setUp() throws Exception {
         //Bootstrap WELD container
         StartMain startMain = new StartMain( new String[ 0 ] );
          = startMain.go().getBeanManager();
 
         //Instantiate Paths used in tests for Path conversion
         final Bean pathsBean = (Bean.getBeans( Paths.class ).iterator().next();
         final CreationalContext cc1 = .createCreationalContextpathsBean );
          = (Paths) .getReferencepathsBean,
                                                   Paths.class,
                                                   cc1 );
 
         //Instantiate ConfigurationService
         final Bean configurationServiceBean = (Bean.getBeans( ConfigurationService.class ).iterator().next();
         final CreationalContext cc2 = .createCreationalContextconfigurationServiceBean );
          = (ConfigurationService) .getReferenceconfigurationServiceBean,
                                                                                 ConfigurationService.class,
                                                                                 cc2 );
 
         //Instantiate ConfigurationFactory
         final Bean configurationFactoryBean = (Bean.getBeans( ConfigurationFactory.class ).iterator().next();
         final CreationalContext cc3 = .createCreationalContextconfigurationFactoryBean );
          = (ConfigurationFactory) .getReferenceconfigurationFactoryBean,
                                                                                 ConfigurationFactory.class,
                                                                                 cc3 );
 
         //Instantiate BuildService
         final Bean buildServiceBean = (Bean.getBeans( BuildService.class ).iterator().next();
         final CreationalContext cc4 = .createCreationalContextbuildServiceBean );
          = (BuildService) .getReferencebuildServiceBean,
                                                                 BuildService.class,
                                                                 cc4 );
 
         //Instantiate ProjectService
         final Bean projectServiceBean = (Bean.getBeans( KieProjectService.class ).iterator().next();
         final CreationalContext cc5 = .createCreationalContextprojectServiceBean );
          = (KieProjectService) .getReferenceprojectServiceBean,
                                                                        KieProjectService.class,
                                                                        cc5 );
        //Instantiate LRUBuilderCache
        final Bean LRUBuilderCacheBean = (Bean.getBeans( LRUBuilderCache.class ).iterator().next();
        final CreationalContext cc6 = .createCreationalContextLRUBuilderCacheBean );
         = (LRUBuilderCache) .getReferenceLRUBuilderCacheBean,
                                                                   LRUBuilderCache.class,
                                                                   cc6 );
        //Instantiate LRUProjectDataModelOracleCache
        final Bean LRUProjectDataModelOracleCacheBean = (Bean.getBeansLRUProjectDataModelOracleCache.class ).iterator().next();
        final CreationalContext cc7 = .createCreationalContextLRUProjectDataModelOracleCacheBean );
         = (LRUProjectDataModelOracleCache.getReferenceLRUProjectDataModelOracleCacheBean,
                                                                                     LRUProjectDataModelOracleCache.class,
                                                                                     cc7 );
        //Define mandatory properties
        List<ConfigGroup> globalConfigGroups = .getConfiguration( ConfigType.GLOBAL );
        boolean globalSettingsDefined = false;
        for ( ConfigGroup globalConfigGroup : globalConfigGroups ) {
            if ( .equalsglobalConfigGroup.getName() ) ) {
                globalSettingsDefined = true;
                break;
            }
        }
        if ( !globalSettingsDefined ) {
            .addConfiguration( getGlobalConfiguration() );
        }
    }
    private ConfigGroup getGlobalConfiguration() {
        //Global Configurations used by many of Drools Workbench editors
        final ConfigGroup group = .newConfigGroup( ConfigType.GLOBAL,
                                                                       ,
                                                                       "" );
        group.addConfigItem( .newConfigItem( "build.enable-incremental",
                                                                 "true" ) );
        return group;
    }
    @Test
    //https://bugzilla.redhat.com/show_bug.cgi?id=1161577
    public void testBuilderKieScannerWarning() throws URISyntaxException {
        final URL resourceUrl = this.getClass().getResource"/BuilderKieScannerRepo/src/main/resources/update.drl" );
        final org.uberfire.java.nio.file.Path nioResourcePath = .getPath( resourceUrl.toURI() );
        final Path resourcePath = .convert( nioResourcePath );
        //Build and look for warnings..
        final KieProject project = .resolveProject( resourcePath );
        final BuildResults buildResults = .build( project );
        assertNotNullbuildResults );
        assertEquals( 0,
                      buildResults.getMessages().size() );
    }
New to GrepCode? Check out our FAQ X