001 /**
002 * Copyright 2010 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 */
015
016 package org.kuali.student.common.assembly.dictionary.old;
017
018 import static org.junit.Assert.assertTrue;
019
020 import java.util.Map;
021
022 import org.junit.Test;
023 import org.kuali.student.common.assembly.data.Metadata;
024 import org.kuali.student.common.assembly.dictionary.old.MetadataServiceImpl;
025 import org.kuali.student.common.dictionary.service.impl.old.DictionaryServiceSpringImpl;
026
027 /**
028 * Tests for MetadataServiceImpl
029 *
030 * @author Kuali Student Team
031 *
032 */
033 public class TestMetadataServiceImpl {
034
035 public static final String DICTIONARY_CONFIG_LOCATION = "classpath:messages-test-dictionary-config.xml";
036 public static final String ORCH_DICTIONARY_CONFIG_LOCATION = "classpath:test-orchestration-dictionary.xml";
037
038
039 @Test
040 public void testDictionaryBasedMetadata(){
041 MockDictionaryService mockDictionaryService = new MockDictionaryService();
042 mockDictionaryService.setDictionaryServiceDelegate(new DictionaryServiceSpringImpl(DICTIONARY_CONFIG_LOCATION));
043
044 MetadataServiceImpl metadataService = new MetadataServiceImpl(mockDictionaryService);
045 Metadata metadata = metadataService.getMetadata("Message", "default", "default");
046
047 Map<String, Metadata> properties = metadata.getProperties();
048 assertTrue(properties.containsKey("groupName"));
049 assertTrue(properties.containsKey("locale"));
050 assertTrue(properties.containsKey("value"));
051
052 }
053
054 @Test
055 public void testOrchestrationDictionaryMetadata(){
056 MetadataServiceImpl metadataService = new MetadataServiceImpl(ORCH_DICTIONARY_CONFIG_LOCATION);
057
058 Metadata metadata = metadataService.getMetadata("CreditCourseProposal", "default", "default");
059
060 Map<String, Metadata> properties = metadata.getProperties();
061 assertTrue(properties.containsKey("course"));
062 metadata = properties.get("course");
063
064 properties = metadata.getProperties();
065 assertTrue(properties.containsKey("formats"));
066 metadata = properties.get("formats");
067
068 properties = metadata.getProperties();
069 assertTrue(properties.containsKey("*"));
070 metadata = properties.get("*");
071
072 properties = metadata.getProperties();
073 assertTrue(properties.containsKey("activities"));
074
075 metadata = metadataService.getMetadata("joints", "default", "default");
076 properties = metadata.getProperties();
077
078 metadata = properties.get("_runtimeData");
079 properties = metadata.getProperties();
080 assertTrue(properties.containsKey("created"));
081 }
082 }