01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. 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 distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.form.controller;
16:
17: import java.util.ArrayList;
18: import java.util.Collections;
19: import java.util.List;
20:
21: import org.apache.commons.collections.comparators.ReverseComparator;
22: import org.strecks.validator.IntegerValidator;
23: import org.strecks.validator.internal.ValidatorWrapper;
24: import org.strecks.validator.message.DefaultMessageParameterProvider;
25: import org.testng.annotations.Test;
26:
27: /**
28: * @author Phil Zoio
29: */
30: public class TestValidatorWrapper {
31:
32: @SuppressWarnings("unchecked")
33: @Test
34: public void testSortValidatorWrapper() {
35: DefaultMessageParameterProvider provider = new DefaultMessageParameterProvider();
36:
37: ValidatorWrapper wrapper1 = new ValidatorWrapper("key1", 20,
38: Collections.emptyList(), new IntegerValidator(), this
39: .getClass().getMethods()[0], provider);
40: ValidatorWrapper wrapper2 = new ValidatorWrapper("key2", 10,
41: Collections.emptyList(), new IntegerValidator(), this
42: .getClass().getMethods()[0], provider);
43:
44: List<ValidatorWrapper> list = new ArrayList<ValidatorWrapper>();
45: list.add(wrapper1);
46: list.add(wrapper2);
47:
48: Collections.sort(list, new ReverseComparator());
49:
50: assert list.get(0) == wrapper2;
51: }
52: }
|