1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
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 |
|
|
32 |
|
import org.kuali.student.common.assembly.data.Metadata; |
33 |
|
import org.kuali.student.common.assembly.dictionary.MetadataFormatter; |
34 |
|
import org.kuali.student.common.assembly.dictionary.old.MetadataServiceImpl; |
35 |
|
import org.kuali.student.lum.lu.assembly.OldMetadataLoaderTest; |
36 |
|
|
|
|
| 82.6% |
Uncovered Elements: 8 (46) |
Complexity: 3 |
Complexity Density: 0.07 |
|
37 |
|
public class TestOldMetadataServiceDictionary |
38 |
|
{ |
39 |
|
|
|
|
| 82.2% |
Uncovered Elements: 8 (45) |
Complexity: 3 |
Complexity Density: 0.07 |
1
PASS
|
|
40 |
1
|
@Test... |
41 |
|
public void testMetadataService () |
42 |
|
{ |
43 |
1
|
Set<String> startingClasses = new LinkedHashSet (); |
44 |
1
|
Map<String, Set<String>> types = new LinkedHashMap (); |
45 |
1
|
startingClasses.add ("course"); |
46 |
1
|
startingClasses.add ("proposal"); |
47 |
1
|
startingClasses.add ("BrowseCourseCatalog"); |
48 |
1
|
startingClasses.add ("search"); |
49 |
1
|
startingClasses.add ("cluset"); |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
1
|
Set<String> typesForClass = new LinkedHashSet (); |
54 |
|
|
55 |
1
|
MetadataServiceImpl metadataService = |
56 |
|
new MetadataServiceImpl (OldMetadataLoaderTest.ORCH_DICTIONARY_CONFIG_LOCATION); |
57 |
|
|
58 |
1
|
Metadata metadata = |
59 |
|
metadataService.getMetadata ("CreditCourseProposal", "default", "default"); |
60 |
1
|
Map<String, Metadata> properties = metadata.getProperties (); |
61 |
1
|
assertTrue (properties.containsKey ("course")); |
62 |
1
|
metadata = properties.get ("course"); |
63 |
|
|
64 |
1
|
String outFile = "target/oldmetadata.txt"; |
65 |
1
|
File file = new File (outFile); |
66 |
1
|
OutputStream outputStream = null; |
67 |
1
|
try |
68 |
|
{ |
69 |
1
|
outputStream = new FileOutputStream (file, false); |
70 |
|
} |
71 |
|
catch (FileNotFoundException ex) |
72 |
|
{ |
73 |
0
|
throw new RuntimeException (ex); |
74 |
|
} |
75 |
1
|
PrintStream out = new PrintStream (outputStream); |
76 |
1
|
out.println ("(!) This page was automatically generated on " |
77 |
|
+ new Date ()); |
78 |
1
|
out.println ("DO NOT UPDATE MANUALLY!"); |
79 |
1
|
out.println (""); |
80 |
1
|
out.print ( |
81 |
|
"This page represents a formatted view of the lum ui dictionary"); |
82 |
1
|
for (String className: startingClasses) |
83 |
|
{ |
84 |
5
|
out.println ("# " + className); |
85 |
|
} |
86 |
1
|
out.println (""); |
87 |
1
|
out.println ("----"); |
88 |
1
|
out.println ("{toc}"); |
89 |
1
|
out.println ("----"); |
90 |
|
|
91 |
1
|
for (String className: startingClasses) |
92 |
|
{ |
93 |
|
|
94 |
5
|
metadata = |
95 |
|
metadataService.getMetadata (className, "default", "default"); |
96 |
5
|
assertNotNull (metadata); |
97 |
5
|
MetadataFormatter formatter = new MetadataFormatter (className, |
98 |
|
metadata, null, |
99 |
|
null, new HashSet (), |
100 |
|
1); |
101 |
5
|
out.println (formatter.formatForWiki ()); |
102 |
5
|
if (types.get (className) == null) |
103 |
|
{ |
104 |
5
|
continue; |
105 |
|
} |
106 |
0
|
for (String type: types.get (className)) |
107 |
|
{ |
108 |
0
|
System.out.println ("*** Generating formatted version for " + type); |
109 |
0
|
metadata = |
110 |
|
metadataService.getMetadata (className, type, (String) "default"); |
111 |
0
|
assertNotNull (metadata); |
112 |
0
|
formatter = new MetadataFormatter (className, |
113 |
|
metadata, type, |
114 |
|
null, new HashSet (), |
115 |
|
1); |
116 |
0
|
out.println (formatter.formatForWiki ()); |
117 |
|
} |
118 |
|
} |
119 |
|
} |
120 |
|
|
121 |
|
} |