Added LIST constraint

- An optionally case-insensitive list of supported values
 - Supports any types that can be converted to String by our type-converter.
Simple parameter values for constraints must not be in a <value> element, just like Spring properties (sorry)
Constraint parameters of type java.util.List are now supported:
   <list>
      <value>
      <value>
   </list>


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2660 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-04-15 20:30:14 +00:00
parent 9bd553336b
commit 912b8dead9
11 changed files with 277 additions and 24 deletions

View File

@@ -18,6 +18,7 @@ package org.alfresco.repo.dictionary.constraint;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import junit.framework.TestCase;
@@ -148,6 +149,32 @@ public class ConstraintsTest extends TestCase
evaluate(constraint, Arrays.asList("abc", "abcdefg"), true);
}
public void testListOfValuesConstraint() throws Exception
{
ListOfValuesConstraint constraint = new ListOfValuesConstraint();
try
{
constraint.setAllowedValues(Collections.<String>emptyList());
}
catch (DictionaryException e)
{
// expected
checkI18NofExceptionMessage(e);
}
List<String> allowedValues = Arrays.asList(new String[] {"abc", "def", "ghi"});
constraint.setAllowedValues(allowedValues);
evaluate(constraint, "def", false);
evaluate(constraint, "DEF", true);
evaluate(constraint, Arrays.asList("abc", "def"), false);
evaluate(constraint, Arrays.asList("abc", "DEF"), true);
// now make it case-insensitive
constraint.setCaseSensitive(false);
evaluate(constraint, "DEF", false);
evaluate(constraint, Arrays.asList("abc", "DEF"), false);
}
public void testNumericRangeConstraint() throws Exception
{
NumericRangeConstraint constraint = new NumericRangeConstraint();