Coverage Report - com.aurea.maven.plugins.sonic.esb.ai.ServiceGroupGeneratorMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceGroupGeneratorMojo
0%
0/15
0%
0/2
4
 
 1  
 package com.aurea.maven.plugins.sonic.esb.ai;
 2  
 
 3  
 import java.io.File;
 4  
 import java.util.List;
 5  
 
 6  
 import org.apache.maven.plugin.MojoExecutionException;
 7  
 import org.apache.maven.plugin.MojoFailureException;
 8  
 
 9  
 import com.aurea.maven.plugins.sonic.esb.AbstractESBMojo;
 10  
 import com.aurea.maven.plugins.util.VelocityRunner;
 11  
 
 12  
 /**
 13  
  * This Mojo is an intermediate solution to generate AI configuration from a
 14  
  * given ESB project. The AI configuration is not immediately done in AI, but
 15  
  * uses a tool provided by BA. The input to that tool is is an undocumented /
 16  
  * unversioned XML format and the outcome of this plugin is created after given
 17  
  * samples. Also, the tool is NOT generic to cover all Actional use cases.
 18  
  * 
 19  
  * The generator first scans for all ESP processes in the current project,
 20  
  * creates an in-memory object graph of the objects found and runs each found
 21  
  * process though a velocity template.
 22  
  * 
 23  
  * For each process we will generate a file named svc-config-processname in a
 24  
  * subdirectory ai of our outputdirectory.
 25  
  * 
 26  
  * @goal ai-generate
 27  
  */
 28  0
 public class ServiceGroupGeneratorMojo extends AbstractESBMojo {
 29  
 
 30  
   /**
 31  
    * @parameter @required
 32  
    */
 33  
   private List<String> templateFiles;
 34  
 
 35  
   /**
 36  
    * @parameter 
 37  
    */
 38  
   private String propFileName;
 39  
   
 40  
   /**
 41  
    * @parameter @default-value="ai" @required
 42  
    */
 43  0
   private String aiOutputDirName = "ai";
 44  
   
 45  
   @Override
 46  
   protected void doExecute() throws MojoExecutionException, MojoFailureException {
 47  
 
 48  0
     getLog().info("Executing Velocity ....");
 49  
     
 50  0
     VelocityRunner runner = VelocityRunner.getInstance(project);
 51  0
     runner.setOutputDirectory(aiOutputDirName);
 52  0
     runner.addProperties("user", propFileName);
 53  0
     runner.addProperty("project", project);
 54  
     
 55  0
     for(String tplFile: templateFiles) {
 56  0
       getLog().debug("Generating Template: " + tplFile);
 57  
       try {
 58  0
         runner.run(tplFile, new File(tplFile).getName());
 59  0
       } catch (Exception e) {
 60  0
         throw new MojoExecutionException("Template generation failed.", e);
 61  0
       }
 62  0
     }
 63  0
   }
 64  
 }