1   package com.sri.emo.dbobj.model_tree;
2   
3   import com.sri.emo.test.MockIViewable;
4   /***
5    * Factory that creates dummy nodes to test iteration and nesting of the
6    * model tree.
7    * @author Michael Rimov
8    *
9    */
10  public class ModelTreeFactoryTest {
11  
12      /***
13       * Instance of viewable that will only be attached to the root node.
14       */
15      public static final MockIViewable rootViewable = new MockIViewable();
16  
17      /***
18       * Instance of viewable that will be only attached to items nested one deep.
19       */
20      public static final MockIViewable level1Viewable = new MockIViewable();
21  
22      /***
23       * Instance of viewable that will be only attached to items nested two deep.
24       */
25      public static final MockIViewable level2Viewable = new MockIViewable();
26  
27  
28      /***
29       * Number of items at level 1
30       */
31      public static final int NUM_LEVEL_1 = 5;
32  
33  
34      /***
35       * Number of items at level 2
36       */
37      public static final int NUM_LEVEL_2 = 3;
38  
39      /***
40       * Default constructor.
41       */
42      public ModelTreeFactoryTest() {
43          super();
44      }
45  
46      /***
47       * Builds a test model that can be used to verify iteration and nesting structure
48       * of the tree.
49       * @return Model constructed model.
50       */
51      public Model buildTestModel() {
52  
53          DefaultModelNode root = new DefaultModelNode(rootViewable);
54          for (int i = 0; i < NUM_LEVEL_1; i++) {
55              DefaultModelNode childLevel1 = new DefaultModelNode(level1Viewable, root);
56  
57              for (int j = 0; j < NUM_LEVEL_2; j++) {
58              	//Automatically adds to parent.
59                  new DefaultModelNode(level2Viewable,childLevel1);
60                  
61              }
62          }
63  
64  
65          return new DefaultModel(root);
66      }
67  
68      /***
69       * Builds a model with a root node only.
70       * @return Model
71       */
72      public Model buildEmptyModel() {
73          return new DefaultModel(new DefaultModelNode(rootViewable));
74      }
75  }