1   // Copyright 2006, by the California Institute of 
2   // Technology. ALL RIGHTS RESERVED. United States Government 
3   // Sponsorship acknowledged. Any commercial use must be negotiated with 
4   // the Office of Technology Transfer at the California Institute of 
5   // Technology.
6   //
7   // This software may be subject to U.S. export control laws. By 
8   // accepting this software, the user agrees to comply with all 
9   // applicable U.S. export laws and regulations. User has the 
10  // responsibility to obtain export licenses, or other export authority 
11  // as may be required before exporting such information to foreign 
12  // countries or providing access to foreign persons.
13  //
14  // $Id: ElementDefinitionTest.java 2937 2007-09-27 20:20:25Z pramirez $ 
15  //
16  
17  package gov.nasa.pds.tools.dict;
18  
19  import gov.nasa.pds.tools.dict.ElementDefinition;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  import junit.framework.*;
25  
26  /***
27   * @author pramirez
28   * @version $Revision: 2937 $
29   * 
30   */
31  public class ElementDefinitionTest extends TestCase {
32      public ElementDefinitionTest(String name) {
33          super(name);
34      }
35      
36      public void testCtor() {
37          ElementDefinition definition = new ElementDefinition("TEST");
38          
39          assertEquals("TEST", definition.getIdentifier());
40          assertEquals("NULL", definition.getDataType());
41          assertEquals("NONE", definition.getUnitId());
42          assertEquals("NONE", definition.getValueType());
43          assertEquals(0, definition.getMinLength());
44          assertEquals(Integer.MAX_VALUE, definition.getMaxLength());
45          assertEquals(0, definition.getValues().size());
46      }
47      
48      public void testSetters() {
49          ElementDefinition definition = new ElementDefinition("TEST");
50          
51          assertEquals("TEST", definition.getIdentifier());
52          definition.setIdentifier("TEST_NEW");
53          assertEquals("TEST_NEW", definition.getIdentifier());
54          
55          assertEquals("NULL", definition.getDataType());
56          definition.setDataType("DATA_TYPE");
57          assertEquals("DATA_TYPE", definition.getDataType());
58          
59          assertEquals("NONE", definition.getUnitId());
60          definition.setUnitId("m**2");
61          assertEquals("m**2", definition.getUnitId());
62          
63          assertEquals("NONE", definition.getValueType());
64          definition.setValueType("INTEGER");
65          assertEquals("INTEGER", definition.getValueType());
66          
67          assertEquals(0, definition.getMinLength());
68          definition.setMinLength(10);
69          assertEquals(10, definition.getMinLength());
70          
71          assertEquals(Integer.MAX_VALUE, definition.getMaxLength());
72          definition.setMaxLength(100);
73          assertEquals(100, definition.getMaxLength());
74          
75          assertEquals(0, definition.getValues().size());
76          List values = new ArrayList();
77          values.add("TEST");
78          definition.setValues(values);
79          assertEquals("TEST", ((ArrayList) definition.getValues()).get(0));
80      }
81  }