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.validator.internal;
16:
17: import java.util.ArrayList;
18: import java.util.Collections;
19: import java.util.List;
20:
21: import org.testng.Assert;
22: import org.testng.annotations.Test;
23:
24: /**
25: * @author Phil Zoio
26: */
27: public class TestOrderedProperty {
28:
29: @Test
30: public void testSort() {
31: List<OrderedProperty> list = new ArrayList<OrderedProperty>();
32:
33: OrderedProperty v1 = getOrderedProperty(1);
34: OrderedProperty v2 = getOrderedProperty(11);
35: OrderedProperty v3 = getOrderedProperty(999);
36:
37: list.add(v1);
38: list.add(v2);
39: list.add(v3);
40:
41: Collections.sort(list);
42: assert v1 == list.iterator().next();
43:
44: list.clear();
45:
46: list.add(v3);
47: list.add(v2);
48: list.add(v1);
49:
50: Collections.sort(list);
51: assert v1 == list.iterator().next();
52: }
53:
54: @Test
55: public void testDeclaring() {
56: OrderedProperty orderedProperty = getOrderedProperty(20);
57: Assert.assertEquals(orderedProperty.getPropertyName(), "prop");
58: Assert.assertEquals(orderedProperty.getOrder().intValue(), 20);
59: }
60:
61: private OrderedProperty getOrderedProperty(int i) {
62: return new OrderedProperty("prop", i);
63: }
64:
65: }
|