01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.internal;
16:
17: import java.util.Collections;
18: import java.util.List;
19: import java.util.Map;
20:
21: import org.apache.tapestry.OptionGroupModel;
22: import org.apache.tapestry.OptionModel;
23: import org.testng.Assert;
24: import org.testng.annotations.Test;
25:
26: public class OptionGroupModelImplTest extends Assert {
27: @Test
28: public void basics() {
29: List<OptionModel> options = Collections.emptyList();
30:
31: OptionGroupModel group = new OptionGroupModelImpl("Label",
32: true, options);
33:
34: assertEquals(group.toString(), "OptionGroupModel[Label]");
35: assertTrue(group.isDisabled());
36: assertNull(group.getAttributes());
37: assertSame(group.getOptions(), options);
38: }
39:
40: @Test
41: public void map_contructor_retains_map() {
42: List<OptionModel> options = Collections.emptyList();
43: Map<String, String> attributes = Collections.emptyMap();
44:
45: OptionGroupModel group = new OptionGroupModelImpl("Label",
46: true, options, attributes);
47:
48: assertSame(group.getAttributes(), attributes);
49: }
50:
51: @Test
52: public void strings_contructor_builds_map() {
53: List<OptionModel> options = Collections.emptyList();
54:
55: OptionGroupModel group = new OptionGroupModelImpl("Label",
56: true, options, "fred", "flintstone", "barney", "rubble");
57:
58: Map<String, String> attributes = group.getAttributes();
59:
60: assertEquals(attributes.size(), 2);
61: assertEquals(attributes.get("fred"), "flintstone");
62: assertEquals(attributes.get("barney"), "rubble");
63: }
64: }
|