Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
20   81   8   2.86
2   52   0.4   7
7     1.14  
1    
 
  KSContractDocMojo       Line # 22 20 0% 8 29 0% 0.0
 
No Tests
 
1    package org.kuali.student.contract.mojo;
2   
3    import java.io.File;
4    import java.util.Collection;
5    import java.util.List;
6   
7    import org.apache.maven.plugin.AbstractMojo;
8    import org.apache.maven.plugin.MojoExecutionException;
9   
10    import org.kuali.student.contract.model.ServiceContractModel;
11    import org.kuali.student.contract.model.impl.ServiceContractModelCache;
12    import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader;
13    import org.kuali.student.contract.model.util.HtmlContractWriter;
14    import org.kuali.student.contract.model.validation.ServiceContractModelValidator;
15   
16    /**
17    * The plugin entrypoint which is used to generate the html wiki doc of the service interface.
18    * @goal kscontractdoc
19    * @phase site
20    * @requiresProject true
21    */
 
22    public class KSContractDocMojo extends AbstractMojo {
23   
24    /**
25    * @parameter
26    **/
27    private List<String> sourceDirs;
28    /**
29    * @parameter expression="${htmlDirectory}" default-value="${project.build.directory}/site/services/contractdocs"
30    */
31    private File htmlDirectory;
32   
 
33  0 toggle public File getHtmlDirectory() {
34  0 return htmlDirectory;
35    }
36   
 
37  0 toggle public List<String> getSourceDirs() {
38  0 return sourceDirs;
39    }
40   
 
41  0 toggle public void setHtmlDirectory(File htmlDirectory) {
42  0 this.htmlDirectory = htmlDirectory;
43    }
44   
 
45  0 toggle public void setSourceDirs(List<String> sourceDirs) {
46  0 this.sourceDirs = sourceDirs;
47    }
48   
 
49  0 toggle private ServiceContractModel getModel() {
50  0 ServiceContractModel instance = new ServiceContractModelQDoxLoader(
51    sourceDirs);
52  0 return new ServiceContractModelCache(instance);
53   
54    }
55   
 
56  0 toggle private boolean validate(ServiceContractModel model) {
57  0 Collection<String> errors = new ServiceContractModelValidator(model).validate();
58  0 if (errors.size() > 0) {
59  0 StringBuilder buf = new StringBuilder();
60  0 buf.append(errors.size()).append(" errors found while validating the data.");
61  0 return false;
62   
63   
64    }
65  0 return true;
66    }
67   
 
68  0 toggle @Override
69    public void execute() throws MojoExecutionException {
70  0 ServiceContractModel model = null;
71  0 HtmlContractWriter writer = null;
72  0 getLog().info("publishing wiki contracts");
73  0 model = this.getModel();
74  0 this.validate(model);
75  0 getLog().info("publishing to = " + this.htmlDirectory.toString());
76  0 writer = new HtmlContractWriter(htmlDirectory.toString(), model);
77  0 writer.write();
78   
79   
80    }
81    }