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 |
|
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 |
|
|
|
|
| 82.6% |
Uncovered Elements: 8 (46) |
Complexity: 3 |
Complexity Density: 0.07 |
|
36 |
|
public class TestOldMetadataServiceDictionary |
37 |
|
{ |
38 |
|
|
|
|
| 82.2% |
Uncovered Elements: 8 (45) |
Complexity: 3 |
Complexity Density: 0.07 |
1
PASS
|
|
39 |
1
|
@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 |
|
|
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 |
|
|
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 |
|
} |