View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.student.mock.mojo;
17  
18  import org.apache.maven.plugin.MojoExecutionException;
19  import org.apache.maven.plugin.MojoFailureException;
20  import org.apache.maven.project.MavenProject;
21  import org.kuali.student.common.mojo.AbstractKSMojo;
22  import org.kuali.student.contract.model.ServiceContractModel;
23  import org.kuali.student.contract.model.impl.ServiceContractModelPescXsdLoader;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  import java.util.ArrayList;
28  import java.util.HashMap;
29  import java.util.List;
30  import java.util.Map;
31  
32  /**
33   * This class associates a mojo to create the conformance tests.
34   *
35   * @goal kscreateconftest
36   * @phase site
37   * @requiresProject true
38   * @author Mezba Mahtab (mezba.mahtab@utoronto.ca)
39   */
40  public class KSCreateConformanceTestMojo extends AbstractKSMojo {
41  
42      private static Logger log = LoggerFactory.getLogger(KSCreateConformanceTestMojo.class);
43      
44      ///////////////////////////
45      // Data Variables
46      ///////////////////////////
47  
48      private String targetDir;
49  
50      ///////////////////////////
51      // Getters and Setters
52      ///////////////////////////
53  
54      public String getTargetDir() {
55          return targetDir;
56      }
57  
58      public void setTargetDir(String targetDir) {
59          this.targetDir = targetDir;
60      }
61  
62      ///////////////////////////
63      // Constructor
64      ///////////////////////////
65  
66      public KSCreateConformanceTestMojo() {}
67  
68      ////////////////////////////
69      // Functional Methods
70      ////////////////////////////
71  
72      @Override
73      public void execute() throws MojoExecutionException, MojoFailureException {
74  
75          ServiceContractModel model = getModel();
76          validate(model);
77          if (targetDir == null) {
78              targetDir = "target/generated-conf-tests";
79          }
80          boolean isR1 = false;
81          ConformanceTestWriter instance =
82                  new ConformanceTestWriter(model,
83                          targetDir,
84                          MockImplWriter.ROOT_PACKAGE,
85                          null,
86                          isR1);
87          instance.write();
88      }
89  
90      public static void main (String [] args) {
91          log.info("execute");
92          List<String> srcDirs = new ArrayList<String>();
93          srcDirs.add("D:/svn/ks/ks-api/ks-common-api/src/main/java"); // common
94          srcDirs.add("D:/svn/ks/ks-api/ks-core-api/src/main"); // core
95          srcDirs.add("D:/svn/ks/ks-api/ks-lum-api/src/main/java"); // lum
96          srcDirs.add("D:/svn/ks/ks-api/ks-enroll-api/src/main/java"); // enroll
97          KSCreateConformanceTestMojo instance = new KSCreateConformanceTestMojo();
98          Map pluginContext = new HashMap();
99          MavenProject project = new MavenProject();
100         pluginContext.put("project", project);
101         instance.setPluginContext(pluginContext);
102         instance.setSourceDirs(srcDirs);
103         instance.setTargetDir("D:/svn/ks/ks-api//target/generated-conf-tests");
104         try {
105             instance.execute();
106             //        assertTrue(new File(instance.getOutputDirectory() + "/" + "ks-LprInfo-dictionary.xml").exists());
107         } catch (MojoExecutionException ex) {
108             throw new RuntimeException(ex);
109         } catch (MojoFailureException ex) {
110             throw new RuntimeException(ex);
111         }
112 
113     }
114 
115 
116 }