View Javadoc
1   package org.andromda.translation.ocl.testsuite;
2   
3   import java.net.URL;
4   import java.util.LinkedHashMap;
5   import java.util.Map;
6   
7   /**
8    * Represents a TranslatorTest object loaded and executed by the ExpressionTranslatorTest object.
9    *
10   * @author Chad Brandon
11   */
12  public class TranslationTest
13  {
14      private String translation;
15      private Map<String, ExpressionTest> expressionConfigs = new LinkedHashMap<String, ExpressionTest>();
16      private URL uri;
17  
18      /**
19       * Sets the name of the translator for which this TranslationTest will be used to test.
20       *
21       * @param translation the name the translation to test.
22       */
23      public void setTranslation(String translation)
24      {
25          this.translation = translation;
26      }
27  
28      /**
29       * Returns the name of the translator, for which this TranslationTest will be used to test.
30       *
31       * @return String
32       */
33      public String getTranslation()
34      {
35          String methodName = "getTranslation";
36          if (this.translation == null)
37          {
38              throw new TranslationTestProcessorException(methodName + " - translation can not be null");
39          }
40          return this.translation;
41      }
42  
43      /**
44       * Adds an ExpressionTest to this TranslationTest.
45       *
46       * @param config a ExpressionTest instance.
47       */
48      public void addExpression(ExpressionTest config)
49      {
50          this.expressionConfigs.put(config.getFrom(), config);
51      }
52  
53      /**
54       * Returns all the ExpressionTest objects in a Map keyed by the from element body.
55       *
56       * @return Map
57       */
58      public Map<String, ExpressionTest> getExpressionConfigs()
59      {
60          return this.expressionConfigs;
61      }
62  
63      /**
64       * Gets the URI for the test which this TranslationTest was loaded from.
65       *
66       * @return Returns the uri.
67       */
68      public URL getUri()
69      {
70          return uri;
71      }
72  
73      /**
74       * Sets the URI for the test which this TranslationTest was loaded from.
75       *
76       * @param uri The uri to set.
77       */
78      protected void setUri(URL uri)
79      {
80          this.uri = uri;
81      }
82  
83  }