View Javadoc

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  
16  package org.kuali.student.common.assembly.dictionary.old;
17  
18  import static org.junit.Assert.assertTrue;
19  
20  import java.util.Map;
21  
22  import org.junit.Test;
23  import org.kuali.student.common.assembly.data.Metadata;
24  import org.kuali.student.common.assembly.dictionary.old.MetadataServiceImpl;
25  import org.kuali.student.common.dictionary.service.impl.old.DictionaryServiceSpringImpl;
26  
27  /**
28   * Tests for MetadataServiceImpl 
29   * 
30   * @author Kuali Student Team
31   *
32   */
33  public class TestMetadataServiceImpl {
34  
35      public static final String DICTIONARY_CONFIG_LOCATION = "classpath:messages-test-dictionary-config.xml"; 
36      public static final String ORCH_DICTIONARY_CONFIG_LOCATION = "classpath:test-orchestration-dictionary.xml";
37  
38      
39      @Test
40      public void testDictionaryBasedMetadata(){
41          MockDictionaryService mockDictionaryService = new MockDictionaryService();
42          mockDictionaryService.setDictionaryServiceDelegate(new DictionaryServiceSpringImpl(DICTIONARY_CONFIG_LOCATION));
43          
44          MetadataServiceImpl metadataService = new MetadataServiceImpl(mockDictionaryService);
45          Metadata metadata = metadataService.getMetadata("Message", "default", "default");
46          
47          Map<String, Metadata> properties = metadata.getProperties();
48          assertTrue(properties.containsKey("groupName"));
49          assertTrue(properties.containsKey("locale"));
50          assertTrue(properties.containsKey("value"));
51          
52      }
53      
54      @Test
55      public void testOrchestrationDictionaryMetadata(){
56          MetadataServiceImpl metadataService = new MetadataServiceImpl(ORCH_DICTIONARY_CONFIG_LOCATION);
57                        
58          Metadata metadata = metadataService.getMetadata("CreditCourseProposal", "default", "default");
59          
60          Map<String, Metadata> properties = metadata.getProperties();        
61          assertTrue(properties.containsKey("course"));        
62          metadata = properties.get("course");
63          
64          properties = metadata.getProperties();        
65          assertTrue(properties.containsKey("formats"));
66          metadata = properties.get("formats");
67          
68          properties = metadata.getProperties();
69          assertTrue(properties.containsKey("*"));
70          metadata = properties.get("*");
71                 
72          properties = metadata.getProperties();
73          assertTrue(properties.containsKey("activities"));
74          
75          metadata = metadataService.getMetadata("joints", "default", "default");
76          properties = metadata.getProperties();
77          
78          metadata = properties.get("_runtimeData");
79          properties = metadata.getProperties();
80          assertTrue(properties.containsKey("created"));
81      }
82  }