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: GroupDefinitionTest.java 1377 2006-07-05 20:24:46Z pramirez $ 
15  //
16  
17  package gov.nasa.pds.tools.dict;
18  
19  import gov.nasa.pds.tools.dict.GroupDefinition;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  import junit.framework.*;
25  
26  /***
27   * @author pramirez
28   * @version $Revision: 1377 $
29   * 
30   */
31  public class GroupDefinitionTest extends TestCase {
32      public GroupDefinitionTest(String name) {
33          super(name);
34      }
35      
36      public void testCtor() {
37          GroupDefinition group = new GroupDefinition("PARAMETERS");
38          
39          assertEquals("PARAMETERS", group.getIdentifier());
40          assertEquals(0, group.getRequiredElements().size());
41          assertEquals(0, group.getOptionalElements().size());
42      }
43      
44      public void testSetters() {
45          GroupDefinition group = new GroupDefinition("PARAMETERS");
46          
47          assertEquals("PARAMETERS", group.getIdentifier());
48          group.setIdentifier("PARAMETERS_TEST");
49          assertEquals("PARAMETERS_TEST", group.getIdentifier());
50          
51          assertEquals(0, group.getRequiredElements().size());
52          List elements = new ArrayList();
53          elements.add("TEST");
54          group.setRequiredElements(elements);
55          assertEquals("TEST", group.getRequiredElements().get(0));
56          
57          assertEquals(0, group.getOptionalElements().size());
58          group.setOptionalElements(elements);
59          assertEquals("TEST", group.getOptionalElements().get(0));
60      }
61      
62      public void testObjectMethods() {
63          GroupDefinition group = new GroupDefinition("PARAMETERS");
64          
65          List elements = new ArrayList();
66          elements.add("TEST");
67          group.setRequiredElements(elements);
68          assertTrue(group.canHaveElement("TEST"));
69          assertTrue(group.mustHaveElement("TEST"));
70      }
71  }