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