Permalink
Browse files

added asObjSeq method

  • Loading branch information...
1 parent 44e7c7d commit 020e86e4d9a39f1fb79f1aebb9346537e4bc1582 @michelegonella committed Oct 30, 2012
Showing with 21 additions and 1 deletion.
  1. +21 −1 zen-dataobject/src/test/java/com/nominanuda/dataobject/DataStructHelperTest.java
@@ -23,6 +23,7 @@
import org.junit.*;
import org.xml.sax.*;
+import static com.nominanuda.dataobject.DataStructHelper.STRUCT;
public class DataStructHelperTest {
@@ -89,6 +90,25 @@ public void shouldTranslateDataArrayWith2EqualsObjectIntoAListWith2EqualsMap() {
assertEquals(2, list.size());
assertEquals(list.get(0), list.get(1));
}
-
+
+ @Test
+ public void testSaObjSeq() {
+ DataArray a0 = STRUCT.newArray();
+ DataArray a1 = STRUCT.newArray().with(STRUCT.newObject());
+ DataArray a2 = STRUCT.newArray().with("");
+
+ for(DataObject o : STRUCT.asObjSeq(a0)) {
+ assertFalse(o.exists("foo"));
+ }
+ for(DataObject o : STRUCT.asObjSeq(a1)) {
+ assertFalse(o.exists("foo"));
+ }
+ try {
+ for(DataObject o : STRUCT.asObjSeq(a2)) {
+ assertFalse(o.exists("foo"));
+ }
+ fail();
+ } catch(ClassCastException e) {}
+ }
}

0 comments on commit 020e86e

Please sign in to comment.