001    package org.andromda.translation.ocl.testsuite;
002    
003    import java.net.URL;
004    import java.util.LinkedHashMap;
005    import java.util.Map;
006    
007    /**
008     * Represents a TranslatorTest object loaded and executed by the ExpressionTranslatorTest object.
009     *
010     * @author Chad Brandon
011     */
012    public class TranslationTest
013    {
014        private String translation;
015        private Map<String, ExpressionTest> expressionConfigs = new LinkedHashMap<String, ExpressionTest>();
016        private URL uri;
017    
018        /**
019         * Sets the name of the translator for which this TranslationTest will be used to test.
020         *
021         * @param translation the name the translation to test.
022         */
023        public void setTranslation(String translation)
024        {
025            this.translation = translation;
026        }
027    
028        /**
029         * Returns the name of the translator, for which this TranslationTest will be used to test.
030         *
031         * @return String
032         */
033        public String getTranslation()
034        {
035            String methodName = "getTranslation";
036            if (this.translation == null)
037            {
038                throw new TranslationTestProcessorException(methodName + " - translation can not be null");
039            }
040            return this.translation;
041        }
042    
043        /**
044         * Adds an ExpressionTest to this TranslationTest.
045         *
046         * @param config a ExpressionTest instance.
047         */
048        public void addExpression(ExpressionTest config)
049        {
050            this.expressionConfigs.put(config.getFrom(), config);
051        }
052    
053        /**
054         * Returns all the ExpressionTest objects in a Map keyed by the from element body.
055         *
056         * @return Map
057         */
058        public Map<String, ExpressionTest> getExpressionConfigs()
059        {
060            return this.expressionConfigs;
061        }
062    
063        /**
064         * Gets the URI for the test which this TranslationTest was loaded from.
065         *
066         * @return Returns the uri.
067         */
068        public URL getUri()
069        {
070            return uri;
071        }
072    
073        /**
074         * Sets the URI for the test which this TranslationTest was loaded from.
075         *
076         * @param uri The uri to set.
077         */
078        protected void setUri(URL uri)
079        {
080            this.uri = uri;
081        }
082    
083    }