KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > action > BaseParameterizedItemDefinitionImplTest


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.action;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22 import junit.framework.TestCase;
23
24 import org.alfresco.service.cmr.action.ParameterDefinition;
25 import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
26 import org.alfresco.service.namespace.QName;
27
28 /**
29  * @author Roy Wetherall
30  */

31 public abstract class BaseParameterizedItemDefinitionImplTest extends TestCase
32 {
33     protected static final String JavaDoc NAME = "name";
34     protected static final String JavaDoc TITLE = "title";
35     protected static final String JavaDoc DESCRIPTION = "description";
36     protected List JavaDoc<ParameterDefinition> paramDefs = new ArrayList JavaDoc<ParameterDefinition>();
37     protected List JavaDoc<ParameterDefinition> duplicateParamDefs = new ArrayList JavaDoc<ParameterDefinition>();
38     
39     private static final String JavaDoc PARAM1_DISPLAYNAME = "param1-displayname";
40     private static final String JavaDoc PARAM1_NAME = "param1-name";
41     private static final QName PARAM1_TYPE = DataTypeDefinition.TEXT;
42     private static final QName PARAM2_TYPE = DataTypeDefinition.TEXT;
43     private static final String JavaDoc PARAM2_DISPLAYNAME = "param2-displaname";
44     private static final String JavaDoc PARAM2_NAME = "param2-name";
45     
46     @Override JavaDoc
47     protected void setUp() throws Exception JavaDoc
48     {
49         // Create param def lists
50
this.paramDefs.add(new ParameterDefinitionImpl(PARAM1_NAME, PARAM1_TYPE, false, PARAM1_DISPLAYNAME));
51         this.paramDefs.add(new ParameterDefinitionImpl(PARAM2_NAME, PARAM2_TYPE, false, PARAM2_DISPLAYNAME));
52         this.duplicateParamDefs.add(new ParameterDefinitionImpl(PARAM1_NAME, PARAM1_TYPE, false, PARAM1_DISPLAYNAME));
53         this.duplicateParamDefs.add(new ParameterDefinitionImpl(PARAM1_NAME, PARAM1_TYPE, false, PARAM1_DISPLAYNAME));
54     }
55     
56     public void testConstructor()
57     {
58         create();
59     }
60
61     protected abstract ParameterizedItemDefinitionImpl create();
62     
63     public void testGetName()
64     {
65         ParameterizedItemDefinitionImpl temp = create();
66         assertEquals(NAME, temp.getName());
67     }
68     
69     public void testGetParameterDefintions()
70     {
71         ParameterizedItemDefinitionImpl temp = create();
72         List JavaDoc<ParameterDefinition> params = temp.getParameterDefinitions();
73         assertNotNull(params);
74         assertEquals(2, params.size());
75         int i = 0;
76         for (ParameterDefinition definition : params)
77         {
78             if (i == 0)
79             {
80                 assertEquals(PARAM1_NAME, definition.getName());
81                 assertEquals(PARAM1_TYPE, definition.getType());
82                 assertEquals(PARAM1_DISPLAYNAME, definition.getDisplayLabel());
83             }
84             else
85             {
86                 assertEquals(PARAM2_NAME, definition.getName());
87                 assertEquals(PARAM2_TYPE, definition.getType());
88                 assertEquals(PARAM2_DISPLAYNAME, definition.getDisplayLabel());
89             }
90             i++;
91         }
92     }
93     
94     public void testGetParameterDefinition()
95     {
96         ParameterizedItemDefinitionImpl temp = create();
97         ParameterDefinition definition = temp.getParameterDefintion(PARAM1_NAME);
98         assertNotNull(definition);
99         assertEquals(PARAM1_NAME, definition.getName());
100         assertEquals(PARAM1_TYPE, definition.getType());
101         assertEquals(PARAM1_DISPLAYNAME, definition.getDisplayLabel());
102         
103         ParameterDefinition nullDef = temp.getParameterDefintion("bobbins");
104         assertNull(nullDef);
105     }
106 }
107
Popular Tags