1 17 package org.alfresco.repo.action; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 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 31 public abstract class BaseParameterizedItemDefinitionImplTest extends TestCase 32 { 33 protected static final String NAME = "name"; 34 protected static final String TITLE = "title"; 35 protected static final String DESCRIPTION = "description"; 36 protected List <ParameterDefinition> paramDefs = new ArrayList <ParameterDefinition>(); 37 protected List <ParameterDefinition> duplicateParamDefs = new ArrayList <ParameterDefinition>(); 38 39 private static final String PARAM1_DISPLAYNAME = "param1-displayname"; 40 private static final String 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 PARAM2_DISPLAYNAME = "param2-displaname"; 44 private static final String PARAM2_NAME = "param2-name"; 45 46 @Override 47 protected void setUp() throws Exception 48 { 49 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 <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 |