View Javadoc

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