Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
27   133   9   3.38
2   87   0.33   8
8     1.12  
1    
 
  XmlKradBaseDictionaryCreatorTest       Line # 39 27 0% 9 37 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2011 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.osedu.org/licenses/ECL-2.0
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.contract.model.util;
17   
18    import java.io.File;
19    import java.util.ArrayList;
20    import java.util.Collection;
21    import java.util.List;
22    import org.junit.After;
23    import org.junit.AfterClass;
24    import org.junit.Before;
25    import org.junit.BeforeClass;
26    import org.junit.Test;
27    import org.kuali.student.contract.model.ServiceContractModel;
28    import org.kuali.student.contract.model.impl.ServiceContractModelCache;
29    import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader;
30    import org.kuali.student.contract.model.validation.ServiceContractModelValidator;
31   
32   
33    import static org.junit.Assert.*;
34   
35    /**
36    *
37    * @author nwright
38    */
 
39    public class XmlKradBaseDictionaryCreatorTest {
40   
 
41  0 toggle public XmlKradBaseDictionaryCreatorTest() {
42    }
43   
 
44  0 toggle @BeforeClass
45    public static void setUpClass() throws Exception {
46    }
47   
 
48  0 toggle @AfterClass
49    public static void tearDownClass() throws Exception {
50    }
51   
 
52  0 toggle @Before
53    public void setUp() {
54    }
55   
 
56  0 toggle @After
57    public void tearDown() {
58    }
59    private static final String CORE_DIRECTORY =
60    "C:/svn/ks-1.3/ks-core/ks-core-api/src/main/java";
61    // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
62    private static final String COMMON_DIRECTORY =
63    "C:/svn/ks-1.3/ks-common/ks-common-api/src/main/java";
64    private static final String ENROLL_DIRECTORY =
65    "C:/svn/ks-1.3/ks-enroll/ks-enroll-api/src/main/java";
66    private static final String LUM_DIRECTORY =
67    "C:/svn/ks-1.3/ks-lum/ks-lum-api/src/main/java";
68    private static final String RICE_DIRECTORY =
69    "C:/svn/rice/rice-release-1-0-2-1-br/api/src/main/java";
70    private static final String TEST_SOURCE_DIRECTORY =
71    "src/test/java/org/kuali/student/contract/model/test/source";
72    private static final String XML_DICTIONARY_DIRECTORY = "target/xml/dictionary";
73    private static final String RESOURCES_DIRECTORY =
74    // "C:/svn/student/ks-core/ks-core-api/src/main/java";
75    "src/main/resources";
76    private static final String PESC_CORE_MAIN = RESOURCES_DIRECTORY
77    + "/CoreMain_v1.8.0.xsd";
78   
 
79  0 toggle private ServiceContractModel getModel() {
80  0 List<String> srcDirs = new ArrayList<String>();
81    // srcDirs.add(TEST_SOURCE_DIRECTORY);
82  0 srcDirs.add(ENROLL_DIRECTORY);
83    // srcDirs.add(CORE_DIRECTORY);
84    // srcDirs.add(COMMON_DIRECTORY);
85    // srcDirs.add(LUM_DIRECTORY);
86  0 ServiceContractModel instance = new ServiceContractModelQDoxLoader(
87    srcDirs);
88  0 return new ServiceContractModelCache(instance);
89   
90    }
91   
 
92  0 toggle private void validate(ServiceContractModel model) {
93  0 Collection<String> errors =
94    new ServiceContractModelValidator(model).validate();
95  0 if (errors.size() > 0) {
96  0 StringBuilder buf = new StringBuilder();
97  0 buf.append(errors.size()
98    + " errors found while validating the data.");
99  0 int cnt = 0;
100  0 for (String msg : errors) {
101  0 cnt++;
102  0 buf.append("\n");
103  0 buf.append("*error*" + cnt + ":" + msg);
104    }
105   
106  0 fail(buf.toString());
107    }
108    }
109   
110    /**
111    * Test of run
112    */
 
113  0 toggle @Test
114    public void testRun() {
115  0 ServiceContractModel model = null;
116  0 XmlKradBaseDictionaryCreator writer = null;
117   
118  0 model = this.getModel();
119  0 this.validate(model);
120  0 String xmlObject = null;
121   
122  0 xmlObject = "atpInfo";
123  0 writer = new XmlKradBaseDictionaryCreator(XML_DICTIONARY_DIRECTORY, model, xmlObject);
124  0 writer.write();
125  0 assertTrue(new File(XML_DICTIONARY_DIRECTORY + "/" + "ks-" + xmlObject + "-dictionary.xml").exists());
126   
127  0 xmlObject = "atpInfo";
128  0 writer = new XmlKradBaseDictionaryCreator(XML_DICTIONARY_DIRECTORY, model, xmlObject);
129  0 writer.write();
130  0 assertTrue(new File(XML_DICTIONARY_DIRECTORY + "/" + "ks-" + xmlObject + "-dictionary.xml").exists());
131   
132    }
133    }