001 /**
002 * Copyright 2013 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 *
015 * Created by Mezba Mahtab (mezba.mahtab@utoronto.ca) on 3/8/13
016 */
017 package org.kuali.student.mock.mojo;
018
019 import org.apache.maven.plugin.MojoExecutionException;
020 import org.apache.maven.plugin.MojoFailureException;
021 import org.apache.maven.project.MavenProject;
022 import org.kuali.student.common.mojo.AbstractKSMojo;
023 import org.kuali.student.contract.model.ServiceContractModel;
024 import org.kuali.student.contract.model.impl.ServiceContractModelPescXsdLoader;
025 import org.slf4j.Logger;
026 import org.slf4j.LoggerFactory;
027
028 import java.util.ArrayList;
029 import java.util.HashMap;
030 import java.util.List;
031 import java.util.Map;
032
033 /**
034 * This class associates a mojo to create the conformance tests.
035 *
036 * @goal kscreateconftest
037 * @phase site
038 * @requiresProject true
039 * @author Mezba Mahtab (mezba.mahtab@utoronto.ca)
040 */
041 public class KSCreateConformanceTestMojo extends AbstractKSMojo {
042
043 private static Logger log = LoggerFactory.getLogger(KSCreateConformanceTestMojo.class);
044
045 ///////////////////////////
046 // Data Variables
047 ///////////////////////////
048
049 private String targetDir;
050
051 ///////////////////////////
052 // Getters and Setters
053 ///////////////////////////
054
055 public String getTargetDir() {
056 return targetDir;
057 }
058
059 public void setTargetDir(String targetDir) {
060 this.targetDir = targetDir;
061 }
062
063 ///////////////////////////
064 // Constructor
065 ///////////////////////////
066
067 public KSCreateConformanceTestMojo() {}
068
069 ////////////////////////////
070 // Functional Methods
071 ////////////////////////////
072
073 @Override
074 public void execute() throws MojoExecutionException, MojoFailureException {
075
076 ServiceContractModel model = getModel();
077 validate(model);
078 if (targetDir == null) {
079 targetDir = "target/generated-conf-tests";
080 }
081 boolean isR1 = false;
082 ConformanceTestWriter instance =
083 new ConformanceTestWriter(model,
084 targetDir,
085 MockImplWriter.ROOT_PACKAGE,
086 null,
087 isR1);
088 instance.write();
089 }
090
091 public static void main (String [] args) {
092 log.info("execute");
093 List<String> srcDirs = new ArrayList<String>();
094 srcDirs.add("C:/Users/mahtabme/kuali/student/enrollment/aggregate/branches/services/ks-api/ks-common-api/src/main/java"); // common
095 srcDirs.add("C:/Users/mahtabme/kuali/student/enrollment/aggregate/branches/services/ks-api/ks-core-api/src/main"); // core
096 srcDirs.add("C:/Users/mahtabme/kuali/student/enrollment/aggregate/branches/services/ks-api/ks-lum-api/src/main/java"); // lum
097 srcDirs.add("C:/Users/mahtabme/kuali/student/enrollment/aggregate/branches/services/ks-api/ks-enroll-api/src/main/java"); // enroll
098 KSCreateConformanceTestMojo instance = new KSCreateConformanceTestMojo();
099 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 }