View Javadoc
1   /*
2    * Copyright 2011 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.fatwire.gst.foundation.controller.action;
17  
18  import java.util.Collection;
19  
20  import junit.framework.TestCase;
21  
22  /**
23   * @deprecated 12c has native support for model maps
24   */
25  public class ModelTest extends TestCase {
26  
27      public void testAddStringObject() {
28          final Model m = new Model();
29          m.add("foo", "bar");
30          assertEquals(1, m.entries().size());
31          assertEquals("bar", m.entries().iterator().next().getValue());
32      }
33  
34      public void testAddStringObjectArray() {
35          final Model m = new Model();
36          m.add("foo", "bar", "bad");
37          assertEquals(1, m.entries().size());
38          final Object o = m.entries().iterator().next().getValue();
39          assertTrue(o instanceof Collection);
40  
41      }
42  
43      @SuppressWarnings("rawtypes")
44      public void testList() {
45          final Model m = new Model();
46          m.list("foo", "bad");
47          m.list("foo", "bad");
48          assertEquals(1, m.entries().size());
49          final Object o = m.entries().iterator().next().getValue();
50          assertTrue(o instanceof Collection);
51          assertEquals(2, ((Collection) o).size());
52  
53      }
54  
55  }