Author: nbelaevski
Date: 2008-03-26 12:50:25 -0400 (Wed, 26 Mar 2008)
New Revision: 7267
Modified:
trunk/ui/tree/src/test/java/org/richfaces/component/ListRowKeyTest.java
trunk/ui/tree/src/test/java/org/richfaces/component/TreeModelTest.java
Log:
Unit tests for tree fixed
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/ListRowKeyTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/ListRowKeyTest.java 2008-03-26
16:37:43 UTC (rev 7266)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/ListRowKeyTest.java 2008-03-26
16:50:25 UTC (rev 7267)
@@ -41,19 +41,19 @@
public class ListRowKeyTest extends TestCase {
public void testConstructors() {
- ListRowKey key = new ListRowKey();
+ ListRowKey<Long> key = new ListRowKey<Long>();
assertEquals(0, key.depth());
assertEquals(0, key.getPath().length());
- List list = new LinkedList();
+ List<Long> list = new LinkedList<Long>();
list.add(new Long(2));
list.add(new Long(4));
- key = new ListRowKey(list);
+ key = new ListRowKey<Long>(list);
assertEquals(2, key.depth());
- Iterator iterator = key.iterator();
+ Iterator<Long> iterator = key.iterator();
assertTrue(iterator.hasNext());
assertEquals(new Long(2), iterator.next());
@@ -62,7 +62,7 @@
assertFalse(iterator.hasNext());
- key = new ListRowKey(new Long(5));
+ key = new ListRowKey<Long>(new Long(5));
assertEquals(1, key.depth());
iterator = key.iterator();
assertTrue(iterator.hasNext());
@@ -70,7 +70,7 @@
assertFalse(iterator.hasNext());
- key = new ListRowKey(new ListRowKey(new Long(6)), new Long(7));
+ key = new ListRowKey<Long>(new ListRowKey<Long>(new Long(6)), new
Long(7));
assertEquals(2, key.depth());
iterator = key.iterator();
assertTrue(iterator.hasNext());
@@ -81,7 +81,7 @@
assertFalse(iterator.hasNext());
- key = new ListRowKey(key);
+ key = new ListRowKey<Long>(key);
assertEquals(2, key.depth());
iterator = key.iterator();
assertTrue(iterator.hasNext());
@@ -91,29 +91,6 @@
assertEquals(new Long(7), iterator.next());
assertFalse(iterator.hasNext());
-
- key = new ListRowKey("12_:34:56__78_:9");
- assertEquals(2, key.depth());
- iterator = key.iterator();
- assertTrue(iterator.hasNext());
- assertEquals("12:34", iterator.next());
-
- assertTrue(iterator.hasNext());
- assertEquals("56_78:9", iterator.next());
-
- assertFalse(iterator.hasNext());
-
-
- key = new ListRowKey("12_:34:56__78_:9:");
- assertEquals(2, key.depth());
- iterator = key.iterator();
- assertTrue(iterator.hasNext());
- assertEquals("12:34", iterator.next());
-
- assertTrue(iterator.hasNext());
- assertEquals("56_78:9", iterator.next());
-
- assertFalse(iterator.hasNext());
}
public void testObjectMethods() {
@@ -121,13 +98,13 @@
"test1", "test:2", "test3"
};
- ListRowKey key1 = new ListRowKey(Arrays.asList(data));
+ ListRowKey<String> key1 = new ListRowKey<String>(Arrays.asList(data));
- ListRowKey key2 = new ListRowKey();
+ ListRowKey<String> key2 = new ListRowKey<String>();
for (int i = 0; i < data.length; i++) {
String string = data[i];
- key2 = new ListRowKey(key2, string);
+ key2 = new ListRowKey<String>(key2, string);
}
assertTrue(key1.hashCode() == key2.hashCode());
@@ -136,23 +113,23 @@
}
public void testEqualsAndHash() {
- List keyBase = new ArrayList();
+ List<Object> keyBase = new ArrayList<Object>();
keyBase.add(new Long(12));
keyBase.add("string");
- List keyBase1 = new ArrayList();
+ List<Object> keyBase1 = new ArrayList<Object>();
keyBase1.add(keyBase);
keyBase1.add(new Double(23.56));
keyBase1.add("moreStrings");
- List keyBase2 = new ArrayList();
+ List<Object> keyBase2 = new ArrayList<Object>();
keyBase2.add(keyBase);
keyBase2.add(new Double(23.56));
keyBase2.add("moreStrings");
- ListRowKey rowKey = new ListRowKey(keyBase);
- ListRowKey rowKey1 = new ListRowKey(keyBase1);
- ListRowKey rowKey2 = new ListRowKey(keyBase2);
+ ListRowKey<Object> rowKey = new ListRowKey<Object>(keyBase);
+ ListRowKey<Object> rowKey1 = new ListRowKey<Object>(keyBase1);
+ ListRowKey<Object> rowKey2 = new ListRowKey<Object>(keyBase2);
assertTrue(rowKey.equals(rowKey));
assertTrue(rowKey1.equals(rowKey1));
@@ -170,7 +147,7 @@
assertFalse(rowKey1.equals(null));
assertFalse(rowKey2.equals(null));
- TreeRowKey treeKey = new TreeRowKey() {
+ TreeRowKey<Object> treeKey = new TreeRowKey<Object>() {
/**
*
@@ -181,7 +158,7 @@
throw new UnsupportedOperationException();
}
- public int getCommonPathLength(TreeRowKey otherRowKey) {
+ public int getCommonPathLength(TreeRowKey<Object> otherRowKey) {
throw new UnsupportedOperationException();
}
@@ -189,11 +166,11 @@
throw new UnsupportedOperationException();
}
- public Iterator getSubPathIterator(int fromIndex) {
+ public Iterator<Object> getSubPathIterator(int fromIndex) {
throw new UnsupportedOperationException();
}
- public Iterator iterator() {
+ public Iterator<Object> iterator() {
throw new UnsupportedOperationException();
}
@@ -210,12 +187,12 @@
}
public void testSubPathIterator() throws Exception {
- List keyBase = new ArrayList();
+ List<Object> keyBase = new ArrayList<Object>();
keyBase.add(new Long(13));
keyBase.add("string");
- ListRowKey listRowKey = new ListRowKey(keyBase);
- Iterator iterator = listRowKey.getSubPathIterator(0);
+ ListRowKey<Object> listRowKey = new ListRowKey<Object>(keyBase);
+ Iterator<Object> iterator = listRowKey.getSubPathIterator(0);
assertTrue(iterator.hasNext());
assertEquals(new Long(13), iterator.next());
assertTrue(iterator.hasNext());
@@ -232,19 +209,19 @@
}
public void testIsSubkey() throws Exception {
- List keyBase = new ArrayList();
+ List<Object> keyBase = new ArrayList<Object>();
keyBase.add(new Long(12));
- ListRowKey listRowKey = new ListRowKey(keyBase);
+ ListRowKey<Object> listRowKey = new ListRowKey<Object>(keyBase);
keyBase.add("string");
- ListRowKey listRowKey1 = new ListRowKey(keyBase);
+ ListRowKey<Object> listRowKey1 = new ListRowKey<Object>(keyBase);
- assertTrue(new ListRowKey().isSubKey(listRowKey1));
- assertTrue(new ListRowKey().isSubKey(listRowKey));
- assertFalse(listRowKey.isSubKey(new ListRowKey()));
- assertFalse(listRowKey1.isSubKey(new ListRowKey()));
+ assertTrue(new ListRowKey<Object>().isSubKey(listRowKey1));
+ assertTrue(new ListRowKey<Object>().isSubKey(listRowKey));
+ assertFalse(listRowKey.isSubKey(new ListRowKey<Object>()));
+ assertFalse(listRowKey1.isSubKey(new ListRowKey<Object>()));
assertTrue(listRowKey.isSubKey(listRowKey1));
assertFalse(listRowKey1.isSubKey(listRowKey));
@@ -255,7 +232,7 @@
assertFalse(listRowKey.isSubKey(null));
assertFalse(listRowKey1.isSubKey(null));
- TreeRowKey treeRowKey = new TreeRowKey() {
+ TreeRowKey<Object> treeRowKey = new TreeRowKey<Object>() {
/**
*
@@ -272,7 +249,7 @@
return 3;
}
- public int getCommonPathLength(TreeRowKey otherRowKey) {
+ public int getCommonPathLength(TreeRowKey<Object> otherRowKey) {
throw new UnsupportedOperationException();
}
@@ -280,11 +257,11 @@
return "12:string:3.14159265";
}
- public Iterator getSubPathIterator(int fromIndex) {
+ public Iterator<Object> getSubPathIterator(int fromIndex) {
throw new UnsupportedOperationException();
}
- public Iterator iterator() {
+ public Iterator<Object> iterator() {
return new ArrayIterator(data);
}
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/TreeModelTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/TreeModelTest.java 2008-03-26
16:37:43 UTC (rev 7266)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/TreeModelTest.java 2008-03-26
16:50:25 UTC (rev 7267)
@@ -112,29 +112,42 @@
}
}, null, null);
- model.setRowKey(new ListRowKey<String>("testId:displayName"));
+ List<String> list = new ArrayList<String>();
+ list.add("testId");
+ list.add("displayName");
+ model.setRowKey(new ListRowKey<String>(list));
assertEquals("tree-demo", ((XmlNodeData) model.getRowData()).getText());
- model.setRowKey(new ListRowKey<String>("testId:1:1"));
+ List<String> list1 = new ArrayList<String>();
+ list1.add("testId");
+ list1.add("1");
+ list1.add("1");
+ model.setRowKey(new ListRowKey<String>(list1));
assertEquals(".xhtml", ((XmlNodeData) model.getRowData()).getText());
}
public void testWalkConstrained() throws Exception {
model.setWrappedData(node);
+ List<String> list = new ArrayList<String>();
+ list.add("testId");
+ list.add("4");
+
+ ListRowKey<String> key = new ListRowKey<String>(list);
+
Walker2 walker = new Walker2(model);
- model.walk(null, walker, null, new ListRowKey("testId:4"), null, false);
+ model.walk(null, walker, null, key, null, false);
List walked = walker.getWalked();
assertEquals(3, walked.size());
- model.setRowKey(new ListRowKey("testId:4"));
+ model.setRowKey(key);
assertSame(walked.get(0), model.getTreeNode());
- model.setRowKey(new ListRowKey("testId:4:0"));
+ model.setRowKey(new ListRowKey<String>(key, "0"));
assertSame(walked.get(1), model.getTreeNode());
- model.setRowKey(new ListRowKey("testId:4:1"));
+ model.setRowKey(new ListRowKey<String>(key, "1"));
assertSame(walked.get(2), model.getTreeNode());
}