Clover Coverage Report - KS LUM UI 1.1-SNAPSHOT
Coverage timestamp: Thu Mar 3 2011 06:08:32 EST
43   120   3   43
2   93   0.07   1
1     3  
1    
 
  TestOldMetadataServiceDictionary       Line # 36 43 0% 3 8 82.6% 0.82608694
 
  (1)
 
1    /**
2    * Copyright 2010 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    package org.kuali.student.lum.ui;
16   
17    import java.io.File;
18    import java.io.FileNotFoundException;
19    import java.io.FileOutputStream;
20    import java.io.OutputStream;
21    import java.io.PrintStream;
22    import java.util.Date;
23    import java.util.HashSet;
24    import java.util.LinkedHashMap;
25    import java.util.LinkedHashSet;
26    import java.util.Map;
27    import java.util.Set;
28   
29    import org.junit.Test;
30    import static org.junit.Assert.*;
31    import org.kuali.student.core.assembly.data.Metadata;
32    import org.kuali.student.core.assembly.dictionary.MetadataFormatter;
33    import org.kuali.student.core.assembly.dictionary.old.MetadataServiceImpl;
34    import org.kuali.student.lum.lu.assembly.OldMetadataLoaderTest;
35   
 
36    public class TestOldMetadataServiceDictionary
37    {
38   
 
39  1 toggle @Test
40    public void testMetadataService ()
41    {
42  1 Set<String> startingClasses = new LinkedHashSet ();
43  1 Map<String, Set<String>> types = new LinkedHashMap ();
44  1 startingClasses.add ("course");
45  1 startingClasses.add ("proposal");
46  1 startingClasses.add ("BrowseCourseCatalog");
47  1 startingClasses.add ("search");
48  1 startingClasses.add ("cluset");
49   
50    // startingClasses.add (StatementTreeViewInfo.class);
51   
52  1 Set<String> typesForClass = new LinkedHashSet ();
53   
54  1 MetadataServiceImpl metadataService =
55    new MetadataServiceImpl (OldMetadataLoaderTest.ORCH_DICTIONARY_CONFIG_LOCATION);
56   
57  1 Metadata metadata =
58    metadataService.getMetadata ("CreditCourseProposal", "default", "default");
59  1 Map<String, Metadata> properties = metadata.getProperties ();
60  1 assertTrue (properties.containsKey ("course"));
61  1 metadata = properties.get ("course");
62   
63  1 String outFile = "target/oldmetadata.txt";
64  1 File file = new File (outFile);
65  1 OutputStream outputStream = null;
66  1 try
67    {
68  1 outputStream = new FileOutputStream (file, false);
69    }
70    catch (FileNotFoundException ex)
71    {
72  0 throw new RuntimeException (ex);
73    }
74  1 PrintStream out = new PrintStream (outputStream);
75  1 out.println ("(!) This page was automatically generated on "
76    + new Date ());
77  1 out.println ("DO NOT UPDATE MANUALLY!");
78  1 out.println ("");
79  1 out.print (
80    "This page represents a formatted view of the lum ui dictionary");
81  1 for (String className: startingClasses)
82    {
83  5 out.println ("# " + className);
84    }
85  1 out.println ("");
86  1 out.println ("----");
87  1 out.println ("{toc}");
88  1 out.println ("----");
89   
90  1 for (String className: startingClasses)
91    {
92    // out.println ("getting meta data for " + className);
93  5 metadata =
94    metadataService.getMetadata (className, "default", "default");
95  5 assertNotNull (metadata);
96  5 MetadataFormatter formatter = new MetadataFormatter (className,
97    metadata, null,
98    null, new HashSet (),
99    1);
100  5 out.println (formatter.formatForWiki ());
101  5 if (types.get (className) == null)
102    {
103  5 continue;
104    }
105  0 for (String type: types.get (className))
106    {
107  0 System.out.println ("*** Generating formatted version for " + type);
108  0 metadata =
109    metadataService.getMetadata (className, type, (String) "default");
110  0 assertNotNull (metadata);
111  0 formatter = new MetadataFormatter (className,
112    metadata, type,
113    null, new HashSet (),
114    1);
115  0 out.println (formatter.formatForWiki ());
116    }
117    }
118    }
119   
120    }