This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 127660d org.apache.juneau.http tests.
127660d is described below
commit 127660dc5be97b09c38dec2d0e95b22e71b90779
Author: JamesBognar <[email protected]>
AuthorDate: Wed Jul 8 18:38:44 2020 -0400
org.apache.juneau.http tests.
---
.../apache/juneau/http/ReaderResource_Test.java} | 69 +----
.../src/test/java/org/apache/juneau/http/Test.txt} | 63 +----
.../{LongAssertion.java => ArrayAssertion.java} | 32 +--
.../org/apache/juneau/assertions/Assertion.java | 17 ++
.../org/apache/juneau/assertions/Assertions.java | 106 +++++--
.../juneau/assertions/ByteArrayAssertion.java | 14 +-
...DateAssertion.java => CollectionAssertion.java} | 33 +--
...LongAssertion.java => ComparableAssertion.java} | 35 +--
.../apache/juneau/assertions/DateAssertion.java | 14 +-
.../juneau/assertions/FluentArrayAssertion.java | 222 +++++++++++++++
.../assertions/FluentByteArrayAssertion.java | 20 +-
.../assertions/FluentCollectionAssertion.java | 114 ++++++++
.../assertions/FluentComparableAssertion.java | 176 ++++++++++++
.../juneau/assertions/FluentDateAssertion.java | 126 +--------
.../juneau/assertions/FluentIntegerAssertion.java | 294 +-------------------
.../juneau/assertions/FluentListAssertion.java | 182 ++++++++++++
.../juneau/assertions/FluentLongAssertion.java | 308 +--------------------
.../juneau/assertions/FluentObjectAssertion.java | 208 ++++++++++++++
.../juneau/assertions/FluentStringAssertion.java | 80 +-----
.../apache/juneau/assertions/IntegerAssertion.java | 14 +-
.../{ObjectAssertion.java => ListAssertion.java} | 33 ++-
.../apache/juneau/assertions/LongAssertion.java | 14 +-
.../apache/juneau/assertions/ObjectAssertion.java | 14 +-
.../apache/juneau/assertions/StringAssertion.java | 20 +-
.../juneau/assertions/ThrowableAssertion.java | 14 +-
.../main/ConfigurablePropertyCodeGenerator.java | 8 +
.../client2/RestClient_Response_Body_Test.java | 2 +-
27 files changed, 1162 insertions(+), 1070 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/http/ReaderResource_Test.java
similarity index 55%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
copy to
juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/http/ReaderResource_Test.java
index aeec9a3..6fe733a 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
+++
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/http/ReaderResource_Test.java
@@ -10,65 +10,24 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.assertions;
+package org.apache.juneau.http;
-import org.apache.juneau.internal.*;
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.Assert.*;
+import static org.junit.runners.MethodSorters.*;
-/**
- * Used for assertion calls against longs.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Validates the response length isn't too long.</jc>
- * <jsm>assertLong</jsm>(responseLength).isLessThan(100000);
- * </p>
- */
-@FluentSetters(returns="LongAssertion")
-public class LongAssertion extends FluentLongAssertion<LongAssertion> {
+import org.junit.*;
- /**
- * Creator.
- *
- * @param l The object being wrapped.
- * @return A new {@link LongAssertion} object.
- */
- public static LongAssertion create(Long l) {
- return new LongAssertion(l);
- }
-
- /**
- * Creator.
- *
- * @param l The object being wrapped.
- */
- public LongAssertion(Long l) {
- super(l, null);
- }
-
- @Override
- protected LongAssertion returns() {
- return this;
- }
+@FixMethodOrder(NAME_ASCENDING)
+public class ReaderResource_Test {
- // <FluentSetters>
+ @Test
+ public void a01_basic() throws Exception {
+ ReaderResource rr = ReaderResource.create();
- @Override /* GENERATED - Assertion */
- public LongAssertion msg(String msg, Object...args) {
- super.msg(msg, args);
- return this;
+ assertNull(rr.getContentType());
+ assertNull(rr.getContent());
+ assertNull(rr.getContentEncoding());
+ assertList(rr.getHeaders()).isSize(0);
}
-
- @Override /* GENERATED - Assertion */
- public LongAssertion stderr() {
- super.stderr();
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public LongAssertion stdout() {
- super.stdout();
- return this;
- }
-
- // </FluentSetters>
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/http/Test.txt
similarity index 55%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
copy to
juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/http/Test.txt
index aeec9a3..da445d2 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
+++
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/http/Test.txt
@@ -10,65 +10,4 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
// * specific language governing permissions and limitations under the
License. *
//
***************************************************************************************************************************
-package org.apache.juneau.assertions;
-
-import org.apache.juneau.internal.*;
-
-/**
- * Used for assertion calls against longs.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Validates the response length isn't too long.</jc>
- * <jsm>assertLong</jsm>(responseLength).isLessThan(100000);
- * </p>
- */
-@FluentSetters(returns="LongAssertion")
-public class LongAssertion extends FluentLongAssertion<LongAssertion> {
-
- /**
- * Creator.
- *
- * @param l The object being wrapped.
- * @return A new {@link LongAssertion} object.
- */
- public static LongAssertion create(Long l) {
- return new LongAssertion(l);
- }
-
- /**
- * Creator.
- *
- * @param l The object being wrapped.
- */
- public LongAssertion(Long l) {
- super(l, null);
- }
-
- @Override
- protected LongAssertion returns() {
- return this;
- }
-
- // <FluentSetters>
-
- @Override /* GENERATED - Assertion */
- public LongAssertion msg(String msg, Object...args) {
- super.msg(msg, args);
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public LongAssertion stderr() {
- super.stderr();
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public LongAssertion stdout() {
- super.stdout();
- return this;
- }
-
- // </FluentSetters>
-}
+foo
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ArrayAssertion.java
similarity index 73%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
copy to
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ArrayAssertion.java
index aeec9a3..3ed7b5b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ArrayAssertion.java
@@ -15,57 +15,57 @@ package org.apache.juneau.assertions;
import org.apache.juneau.internal.*;
/**
- * Used for assertion calls against longs.
+ * Used for assertion calls against arrays.
*
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
- * <jc>// Validates the response length isn't too long.</jc>
- * <jsm>assertLong</jsm>(responseLength).isLessThan(100000);
+ * String[] <jv>array</jv> = <jk>new</jk> String[]{<js>"foo"</js>};
+ * <jsm>assertArray</jsm>(<jv>array</jv>).exists().isSize(1);
* </p>
*/
-@FluentSetters(returns="LongAssertion")
-public class LongAssertion extends FluentLongAssertion<LongAssertion> {
+@FluentSetters(returns="ArrayAssertion")
+public class ArrayAssertion extends FluentArrayAssertion<ArrayAssertion> {
/**
* Creator.
*
- * @param l The object being wrapped.
- * @return A new {@link LongAssertion} object.
+ * @param value The object being wrapped.
+ * @return A new {@link ArrayAssertion} object.
*/
- public static LongAssertion create(Long l) {
- return new LongAssertion(l);
+ public static ArrayAssertion create(Object value) {
+ return new ArrayAssertion(value);
}
/**
* Creator.
*
- * @param l The object being wrapped.
+ * @param value The object being wrapped.
*/
- public LongAssertion(Long l) {
- super(l, null);
+ public ArrayAssertion(Object value) {
+ super(value, null);
}
@Override
- protected LongAssertion returns() {
+ protected ArrayAssertion returns() {
return this;
}
// <FluentSetters>
@Override /* GENERATED - Assertion */
- public LongAssertion msg(String msg, Object...args) {
+ public ArrayAssertion msg(String msg, Object...args) {
super.msg(msg, args);
return this;
}
@Override /* GENERATED - Assertion */
- public LongAssertion stderr() {
+ public ArrayAssertion stderr() {
super.stderr();
return this;
}
@Override /* GENERATED - Assertion */
- public LongAssertion stdout() {
+ public ArrayAssertion stdout() {
super.stdout();
return this;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertion.java
index 5b9a71a..f4746e3 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertion.java
@@ -109,6 +109,23 @@ public class Assertion {
return ClassUtils.className(o);
}
+ /**
+ * Casts the specified object to the specified type.
+ *
+ * @param <T> The type to cast the object to.
+ * @param c The type to cast the object to.
+ * @param o The object to cast.
+ * @return The same object cast to the specified object.s
+ */
+ @SuppressWarnings("unchecked")
+ protected static <T> T cast(Class<T> c, Object o) {
+ if (o == null)
+ return null;
+ if (c.isInstance(o))
+ return (T)o;
+ throw new BasicAssertionError("Object was not expected type.
Expected={0}, actual={1}.", c.getClass().getName(), o.getClass().getName());
+ }
+
// <FluentSetters>
// </FluentSetters>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertions.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertions.java
index c77655a..f5921b7 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertions.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertions.java
@@ -28,14 +28,14 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the specified date is after the current
date.</jc>
- * <jsm>assertDate</jsm>(myDate).isAfterNow();
+ * <jsm>assertDate</jsm>(<jv>myDate</jv>).isAfterNow();
* </p>
*
- * @param date The date being wrapped.
+ * @param value The date being wrapped.
* @return A new {@link DateAssertion} object. Never <jk>null</jk>.
*/
- public static DateAssertion assertDate(Date date) {
- return new DateAssertion(date);
+ public static DateAssertion assertDate(Date value) {
+ return new DateAssertion(value);
}
/**
@@ -44,14 +44,14 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response status code is 200 or 404.</jc>
- * <jsm>assertInteger</jsm>(httpReponse).isAny(200,404);
+ * <jsm>assertInteger</jsm>(<jv>httpReponse<jv>).isAny(200,404);
* </p>
*
- * @param integer The object being wrapped.
+ * @param value The object being wrapped.
* @return A new {@link IntegerAssertion} object. Never <jk>null</jk>.
*/
- public static IntegerAssertion assertInteger(Integer integer) {
- return new IntegerAssertion(integer);
+ public static IntegerAssertion assertInteger(Integer value) {
+ return new IntegerAssertion(value);
}
/**
@@ -60,14 +60,14 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response length isn't too long.</jc>
- * <jsm>assertLong</jsm>(responseLength).isLessThan(100000);
+ *
<jsm>assertLong</jsm>(<jv>responseLength</jv>).isLessThan(100000);
* </p>
*
- * @param l The object being wrapped.
+ * @param value The object being wrapped.
* @return A new {@link LongAssertion} object. Never <jk>null</jk>.
*/
- public static LongAssertion assertLong(Long l) {
- return new LongAssertion(l);
+ public static LongAssertion assertLong(Long value) {
+ return new LongAssertion(value);
}
/**
@@ -76,14 +76,14 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the specified POJO is the specified type and
serializes to the specified value.</jc>
- *
<jsm>assertObject</jsm>(myPojo).instanceOf(MyBean.<jk>class</jk>).json().is(<js>"{foo:'bar'}"</js>);
+ *
<jsm>assertObject</jsm>(<jv>myPojo</jv>).instanceOf(MyBean.<jk>class</jk>).json().is(<js>"{foo:'bar'}"</js>);
* </p>
*
- * @param object The object being wrapped.
+ * @param value The object being wrapped.
* @return A new {@link ObjectAssertion} object. Never <jk>null</jk>.
*/
- public static ObjectAssertion assertObject(Object object) {
- return new ObjectAssertion(object);
+ public static ObjectAssertion assertObject(Object value) {
+ return new ObjectAssertion(value);
}
/**
@@ -92,14 +92,14 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response body of an HTTP call is the text
"OK".</jc>
- * <jsm>assertString</jsm>(httpBody).is(<js>"OK"</js>);
+ * <jsm>assertString</jsm>(<jv>httpBody</jv>).is(<js>"OK"</js>);
* </p>
*
- * @param text The string being wrapped.
+ * @param value The string being wrapped.
* @return A new {@link StringAssertion} object. Never <jk>null</jk>.
*/
- public static StringAssertion assertString(Object text) {
- return new StringAssertion(text);
+ public static StringAssertion assertString(Object value) {
+ return new StringAssertion(value);
}
/**
@@ -108,14 +108,64 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the throwable message or one of the parent
messages contain 'Foobar'.</jc>
- *
<jsm>assertThrowable</jsm>(throwable).contains(<js>"Foobar"</js>);
+ *
<jsm>assertThrowable</jsm>(<jv>throwable</jv>).contains(<js>"Foobar"</js>);
* </p>
*
- * @param throwable The throwable being wrapped.
+ * @param value The throwable being wrapped.
* @return A new {@link ThrowableAssertion} object. Never
<jk>null</jk>.
*/
- public static ThrowableAssertion assertThrowable(Throwable throwable) {
- return new ThrowableAssertion(throwable);
+ public static ThrowableAssertion assertThrowable(Throwable value) {
+ return new ThrowableAssertion(value);
+ }
+
+ /**
+ * Used for assertion calls against arrays.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * String[] <jv>array</jv> = <jk>new</jk> String[]{<js>"foo"</js>};
+ * <jsm>assertArray</jsm>(<jv>array</jv>).isSize(1);
+ * </p>
+ *
+ * @param value The object being wrapped.
+ * @return A new {@link ArrayAssertion} object. Never <jk>null</jk>.
+ */
+ public static ArrayAssertion assertArray(Object value) {
+ return new ArrayAssertion(value);
+ }
+
+ /**
+ * Used for assertion calls against {@link Collection} objects.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * List=<String> <jv>list</jv> =
AList.<jsm>of</jsm>(<js>"foo"</js>);
+ * <jsm>assertCollection</jsm>(<jv>list</jv>).isNotEmpty();
+ * </p>
+ *
+ * @param value The object being wrapped.
+ * @return A new {@link CollectionAssertion} object. Never
<jk>null</jk>.
+ */
+ @SuppressWarnings("rawtypes")
+ public static CollectionAssertion assertCollection(Collection value) {
+ return new CollectionAssertion(value);
+ }
+
+ /**
+ * Used for assertion calls against {@link Collection} objects.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * List=<String> <jv>list</jv> =
AList.<jsm>of</jsm>(<js>"foo"</js>);
+ *
<jsm>assertList</jsm>(<jv>list</jv>).item(0).isEquals(<js>"foo"</js>);
+ * </p>
+ *
+ * @param value The object being wrapped.
+ * @return A new {@link ListAssertion} object. Never <jk>null</jk>.
+ */
+ @SuppressWarnings("rawtypes")
+ public static ListAssertion assertList(List value) {
+ return new ListAssertion(value);
}
/**
@@ -124,7 +174,7 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Asserts that the specified method throws a
RuntimeException containing "Foobar" in the message. </jc>
- * <jsm>assertThrown</jsm>(() -> {foo.getBar();})
+ * <jsm>assertThrown</jsm>(()-><jv>foo</jv>.getBar())
* .exists()
* .isType(RuntimeException.<jk>class</jk>)
* .contains(<js>"Foobar"</js>);
@@ -148,7 +198,7 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates that the stream contains the string "foo".</jc>
- * <jsm>assertStream</jsm>(myStream).hex().is(<js>"666F6F"</js>);
+ *
<jsm>assertStream</jsm>(<jv>myStream</jv>).hex().is(<js>"666F6F"</js>);
* </p>
*
* @param is The input stream being wrapped.
@@ -165,7 +215,7 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates that the byte array contains the string
"foo".</jc>
- * <jsm>assertBytes</jsm>(myBytes).hex().is(<js>"666F6F"</js>);
+ *
<jsm>assertBytes</jsm>(<jv>myBytes</jv>).hex().is(<js>"666F6F"</js>);
* </p>
*
* @param bytes The byte array being wrapped.
@@ -181,7 +231,7 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the throwable message or one of the parent
messages contain 'Foobar'.</jc>
- * <jsm>assertReader</jsm>(myReader).is(<js>"foo"</js>);
+ * <jsm>assertReader</jsm>(<jv>myReader</jv>).is(<js>"foo"</js>);
* </p>
*
* @param r The reader being wrapped.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ByteArrayAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ByteArrayAssertion.java
index 7d6697f..ec637cd 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ByteArrayAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ByteArrayAssertion.java
@@ -20,7 +20,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the byte array contains the string "foo".</jc>
- * <jsm>assertBytes</jsm>(myByteArray).hex().is(<js>"666F6F"</js>);
+ *
<jsm>assertBytes</jsm>(<jv>myByteArray</jv>).hex().is(<js>"666F6F"</js>);
* </p>
*/
@FluentSetters(returns="ByteArrayAssertion")
@@ -29,20 +29,20 @@ public class ByteArrayAssertion extends
FluentByteArrayAssertion<ByteArrayAssert
/**
* Creator.
*
- * @param contents The contents being wrapped.
+ * @param value The contents being wrapped.
* @return A new {@link ByteArrayAssertion} object.
*/
- public static ByteArrayAssertion create(byte[] contents) {
- return new ByteArrayAssertion(contents);
+ public static ByteArrayAssertion create(byte[] value) {
+ return new ByteArrayAssertion(value);
}
/**
* Creator.
*
- * @param contents The contents being wrapped.
+ * @param value The contents being wrapped.
*/
- public ByteArrayAssertion(byte[] contents) {
- super(contents, null);
+ public ByteArrayAssertion(byte[] value) {
+ super(value, null);
}
@Override
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/DateAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/CollectionAssertion.java
similarity index 71%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/DateAssertion.java
copy to
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/CollectionAssertion.java
index 44d0d9c..5c88067 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/DateAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/CollectionAssertion.java
@@ -17,57 +17,58 @@ import java.util.*;
import org.apache.juneau.internal.*;
/**
- * Used for assertion calls against {@link Date} objects.
+ * Used for assertion calls against collections objects.
*
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
- * <jc>// Validates the specified date is after the current date.</jc>
- * <jsm>assertDate</jsm>(myDate).isAfterNow();
+ * <jc>// Validates the specified list is not empty.</jc>
+ * <jsm>assertCollection</jsm>(<jv>myList</jv>).isNotEmpty();
* </p>
*/
-@FluentSetters(returns="DateAssertion")
-public class DateAssertion extends FluentDateAssertion<DateAssertion> {
+@FluentSetters(returns="CollectionAssertion")
+@SuppressWarnings("rawtypes")
+public class CollectionAssertion extends
FluentCollectionAssertion<CollectionAssertion> {
/**
* Creator.
*
- * @param date The date being wrapped.
- * @return A new {@link DateAssertion} object.
+ * @param value The object being wrapped.
+ * @return A new {@link CollectionAssertion} object.
*/
- public static DateAssertion create(Date date) {
- return new DateAssertion(date);
+ public static CollectionAssertion create(Collection value) {
+ return new CollectionAssertion(value);
}
/**
* Creator.
*
- * @param date The date being wrapped.
+ * @param value The object being wrapped.
*/
- public DateAssertion(Date date) {
- super(date, null);
+ public CollectionAssertion(Collection value) {
+ super(value, null);
}
@Override
- protected DateAssertion returns() {
+ protected CollectionAssertion returns() {
return this;
}
// <FluentSetters>
@Override /* GENERATED - Assertion */
- public DateAssertion msg(String msg, Object...args) {
+ public CollectionAssertion msg(String msg, Object...args) {
super.msg(msg, args);
return this;
}
@Override /* GENERATED - Assertion */
- public DateAssertion stderr() {
+ public CollectionAssertion stderr() {
super.stderr();
return this;
}
@Override /* GENERATED - Assertion */
- public DateAssertion stdout() {
+ public CollectionAssertion stdout() {
super.stdout();
return this;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ComparableAssertion.java
similarity index 72%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
copy to
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ComparableAssertion.java
index aeec9a3..ec62f71 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ComparableAssertion.java
@@ -15,57 +15,52 @@ package org.apache.juneau.assertions;
import org.apache.juneau.internal.*;
/**
- * Used for assertion calls against longs.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Validates the response length isn't too long.</jc>
- * <jsm>assertLong</jsm>(responseLength).isLessThan(100000);
- * </p>
+ * Used for assertion calls against comparable objects.
*/
-@FluentSetters(returns="LongAssertion")
-public class LongAssertion extends FluentLongAssertion<LongAssertion> {
+@FluentSetters(returns="ComparableAssertion")
+@SuppressWarnings("rawtypes")
+public class ComparableAssertion extends
FluentComparableAssertion<ComparableAssertion> {
/**
* Creator.
*
- * @param l The object being wrapped.
- * @return A new {@link LongAssertion} object.
+ * @param value The object being wrapped.
+ * @return A new {@link ComparableAssertion} object.
*/
- public static LongAssertion create(Long l) {
- return new LongAssertion(l);
+ public static ComparableAssertion create(Comparable value) {
+ return new ComparableAssertion(value);
}
/**
* Creator.
*
- * @param l The object being wrapped.
+ * @param value The object being wrapped.
*/
- public LongAssertion(Long l) {
- super(l, null);
+ public ComparableAssertion(Comparable value) {
+ super(value, null);
}
@Override
- protected LongAssertion returns() {
+ protected ComparableAssertion returns() {
return this;
}
// <FluentSetters>
@Override /* GENERATED - Assertion */
- public LongAssertion msg(String msg, Object...args) {
+ public ComparableAssertion msg(String msg, Object...args) {
super.msg(msg, args);
return this;
}
@Override /* GENERATED - Assertion */
- public LongAssertion stderr() {
+ public ComparableAssertion stderr() {
super.stderr();
return this;
}
@Override /* GENERATED - Assertion */
- public LongAssertion stdout() {
+ public ComparableAssertion stdout() {
super.stdout();
return this;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/DateAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/DateAssertion.java
index 44d0d9c..724cff7 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/DateAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/DateAssertion.java
@@ -22,7 +22,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the specified date is after the current date.</jc>
- * <jsm>assertDate</jsm>(myDate).isAfterNow();
+ * <jsm>assertDate</jsm>(<jv>myDate</jv>).isAfterNow();
* </p>
*/
@FluentSetters(returns="DateAssertion")
@@ -31,20 +31,20 @@ public class DateAssertion extends
FluentDateAssertion<DateAssertion> {
/**
* Creator.
*
- * @param date The date being wrapped.
+ * @param value The date being wrapped.
* @return A new {@link DateAssertion} object.
*/
- public static DateAssertion create(Date date) {
- return new DateAssertion(date);
+ public static DateAssertion create(Date value) {
+ return new DateAssertion(value);
}
/**
* Creator.
*
- * @param date The date being wrapped.
+ * @param value The date being wrapped.
*/
- public DateAssertion(Date date) {
- super(date, null);
+ public DateAssertion(Date value) {
+ super(value, null);
}
@Override
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentArrayAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentArrayAssertion.java
new file mode 100644
index 0000000..903ef49
--- /dev/null
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentArrayAssertion.java
@@ -0,0 +1,222 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import org.apache.juneau.internal.*;
+
+/**
+ * Used for fluent assertion calls against array objects.
+ *
+ * @param <R> The return type.
+ */
+@FluentSetters(returns="FluentArrayAssertion<R>")
+public class FluentArrayAssertion<R> extends FluentObjectAssertion<R> {
+
+ private Object value;
+
+ /**
+ * Constructor.
+ *
+ * @param contents The byte array being tested.
+ * @param returns The object to return after the test.
+ */
+ public FluentArrayAssertion(Object contents, R returns) {
+ super(contents, returns);
+ this.value = contents;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param creator The assertion that created this assertion.
+ * @param contents The byte array being tested.
+ * @param returns The object to return after the test.
+ */
+ public FluentArrayAssertion(Assertion creator, Object contents, R
returns) {
+ super(creator, contents, returns);
+ this.value = contents;
+ }
+
+ /**
+ * Asserts that the collection exists and is empty.
+ *
+ * @return The object to return after the test.
+ * @throws AssertionError If assertion failed.
+ */
+ public R isEmpty() throws AssertionError {
+ exists();
+ if (Array.getLength(value) != 0)
+ throw error("Collection was not empty.");
+ return returns();
+ }
+
+ /**
+ * Asserts that the collection exists and is not empty.
+ *
+ * @return The object to return after the test.
+ * @throws AssertionError If assertion failed.
+ */
+ public R isNotEmpty() throws AssertionError {
+ exists();
+ if (Array.getLength(value) == 0)
+ throw error("Collection was empty.");
+ return returns();
+ }
+
+ /**
+ * Asserts that the collection exists and is the specified size.
+ *
+ * @param size The expected size.
+ * @return The object to return after the test.
+ * @throws AssertionError If assertion failed.
+ */
+ public R isSize(int size) throws AssertionError {
+ exists();
+ if (Array.getLength(value) == size)
+ throw error("Array did not have the expected size.
Expected={0}, actual={0}.", size, Array.getLength(value));
+ return returns();
+ }
+
+ /**
+ * Returns an object assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the array is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the array.
+ * @return A new assertion.
+ */
+ public FluentObjectAssertion<R> item(int index) {
+ return new FluentObjectAssertion<>(this, getItem(index),
returns());
+ }
+
+ /**
+ * Returns a string assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the array is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the array.
+ * @return A new assertion.
+ */
+ public FluentStringAssertion<R> stringItem(int index) {
+ return new FluentStringAssertion<>(this,
StringUtils.stringify(getItem(index)), returns());
+ }
+
+ /**
+ * Returns a date assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the array is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the array.
+ * @return A new assertion.
+ */
+ public FluentDateAssertion<R> dateItem(int index) {
+ return new FluentDateAssertion<>(this, getItem(Date.class,
index), returns());
+ }
+
+ /**
+ * Returns an integer assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the array is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the array.
+ * @return A new assertion.
+ */
+ public FluentIntegerAssertion<R> integerItem(int index) {
+ return new FluentIntegerAssertion<>(this,
getItem(Integer.class, index), returns());
+ }
+
+ /**
+ * Returns a long assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the array is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the array.
+ * @return A new assertion.
+ */
+ public FluentLongAssertion<R> longItem(int index) {
+ return new FluentLongAssertion<>(this, getItem(Long.class,
index), returns());
+ }
+
+ /**
+ * Returns a list assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the array is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the array.
+ * @return A new assertion.
+ */
+ public FluentListAssertion<R> listItem(int index) {
+ return new FluentListAssertion<>(this, getItem(List.class,
index), returns());
+ }
+
+ /**
+ * Returns a collection assertion on the item specified at the
specified index.
+ *
+ * <p>
+ * If the array is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the array.
+ * @return A new assertion.
+ */
+ public FluentCollectionAssertion<R> collectionItem(int index) {
+ return new FluentCollectionAssertion<>(this,
getItem(Collection.class, index), returns());
+ }
+
+ private Object getItem(int index) {
+ if (value != null && Array.getLength(value) > index)
+ return Array.get(value, index);
+ return null;
+ }
+
+ private <T> T getItem(Class<T> c, int index) {
+ return cast(c, getItem(index));
+ }
+
+ // <FluentSetters>
+
+ @Override /* GENERATED - Assertion */
+ public FluentArrayAssertion<R> msg(String msg, Object...args) {
+ super.msg(msg, args);
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentArrayAssertion<R> stderr() {
+ super.stderr();
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentArrayAssertion<R> stdout() {
+ super.stdout();
+ return this;
+ }
+
+ // </FluentSetters>
+}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentByteArrayAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentByteArrayAssertion.java
index 5481b9b..6e06ecf 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentByteArrayAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentByteArrayAssertion.java
@@ -24,9 +24,9 @@ import org.apache.juneau.internal.*;
* @param <R> The return type.
*/
@FluentSetters(returns="FluentByteArrayAssertion<R>")
-public class FluentByteArrayAssertion<R> extends FluentAssertion<R> {
+public class FluentByteArrayAssertion<R> extends FluentObjectAssertion<R> {
- private byte[] contents;
+ private byte[] value;
/**
* Constructor.
@@ -35,8 +35,8 @@ public class FluentByteArrayAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentByteArrayAssertion(byte[] contents, R returns) {
- super(returns);
- this.contents = contents;
+ super(contents, returns);
+ this.value = contents;
}
/**
@@ -47,8 +47,8 @@ public class FluentByteArrayAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentByteArrayAssertion(Assertion creator, byte[] contents, R
returns) {
- super(creator, returns);
- this.contents = contents;
+ super(creator, contents, returns);
+ this.value = contents;
}
/**
@@ -79,7 +79,7 @@ public class FluentByteArrayAssertion<R> extends
FluentAssertion<R> {
* @return A new fluent string assertion.
*/
public FluentStringAssertion<R> string(Charset cs) {
- return new FluentStringAssertion<>(this, contents == null ?
null : new String(contents, cs), returns());
+ return new FluentStringAssertion<>(this, value == null ? null :
new String(value, cs), returns());
}
/**
@@ -94,7 +94,7 @@ public class FluentByteArrayAssertion<R> extends
FluentAssertion<R> {
* @return A new fluent string assertion.
*/
public FluentStringAssertion<R> base64() {
- return new FluentStringAssertion<>(this, contents == null ?
null : base64Encode(contents), returns());
+ return new FluentStringAssertion<>(this, value == null ? null :
base64Encode(value), returns());
}
/**
@@ -109,7 +109,7 @@ public class FluentByteArrayAssertion<R> extends
FluentAssertion<R> {
* @return A new string consisting of hexadecimal characters.
*/
public FluentStringAssertion<R> hex() {
- return new FluentStringAssertion<>(this, contents == null ?
null : toHex(contents), returns());
+ return new FluentStringAssertion<>(this, value == null ? null :
toHex(value), returns());
}
/**
@@ -124,7 +124,7 @@ public class FluentByteArrayAssertion<R> extends
FluentAssertion<R> {
* @return A new string consisting of hexadecimal characters.
*/
public FluentStringAssertion<R> spacedHex() {
- return new FluentStringAssertion<>(this, contents == null ?
null : toSpacedHex(contents), returns());
+ return new FluentStringAssertion<>(this, value == null ? null :
toSpacedHex(value), returns());
}
// <FluentSetters>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentCollectionAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentCollectionAssertion.java
new file mode 100644
index 0000000..836f8f6
--- /dev/null
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentCollectionAssertion.java
@@ -0,0 +1,114 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import java.util.*;
+
+import org.apache.juneau.internal.*;
+
+/**
+ * Used for fluent assertion calls against collections objects.
+ *
+ * @param <R> The return type.
+ */
+@FluentSetters(returns="FluentCollectionAssertion<R>")
+@SuppressWarnings("rawtypes")
+public class FluentCollectionAssertion<R> extends FluentObjectAssertion<R> {
+
+ private Collection value;
+
+ /**
+ * Constructor.
+ *
+ * @param contents The byte array being tested.
+ * @param returns The object to return after the test.
+ */
+ public FluentCollectionAssertion(Collection contents, R returns) {
+ super(contents, returns);
+ this.value = contents;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param creator The assertion that created this assertion.
+ * @param contents The byte array being tested.
+ * @param returns The object to return after the test.
+ */
+ public FluentCollectionAssertion(Assertion creator, Collection
contents, R returns) {
+ super(creator, contents, returns);
+ this.value = contents;
+ }
+
+ /**
+ * Asserts that the collection exists and is empty.
+ *
+ * @return The object to return after the test.
+ * @throws AssertionError If assertion failed.
+ */
+ public R isEmpty() throws AssertionError {
+ exists();
+ if (! value.isEmpty())
+ throw error("Collection was not empty.");
+ return returns();
+ }
+
+ /**
+ * Asserts that the collection exists and is not empty.
+ *
+ * @return The object to return after the test.
+ * @throws AssertionError If assertion failed.
+ */
+ public R isNotEmpty() throws AssertionError {
+ exists();
+ if (value.isEmpty())
+ throw error("Collection was empty.");
+ return returns();
+ }
+
+ /**
+ * Asserts that the collection exists and is the specified size.
+ *
+ * @param size The expected size.
+ * @return The object to return after the test.
+ * @throws AssertionError If assertion failed.
+ */
+ public R isSize(int size) throws AssertionError {
+ exists();
+ if (value.size() != size)
+ throw error("Collection did not have the expected size.
Expected={0}, actual={0}.", size, value.size());
+ return returns();
+ }
+
+ // <FluentSetters>
+
+ @Override /* GENERATED - Assertion */
+ public FluentCollectionAssertion<R> msg(String msg, Object...args) {
+ super.msg(msg, args);
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentCollectionAssertion<R> stderr() {
+ super.stderr();
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentCollectionAssertion<R> stdout() {
+ super.stdout();
+ return this;
+ }
+
+ // </FluentSetters>
+}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentComparableAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentComparableAssertion.java
new file mode 100644
index 0000000..dc52c0b
--- /dev/null
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentComparableAssertion.java
@@ -0,0 +1,176 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import org.apache.juneau.internal.*;
+
+/**
+ * Used for fluent assertion calls against comparable objects.
+ *
+ * @param <R> The return type.
+ */
+@FluentSetters(returns="FluentComparableAssertion<R>")
+@SuppressWarnings("rawtypes")
+public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
+
+ private final Comparable value;
+
+ /**
+ * Constructor.
+ *
+ * @param value The value being tested.
+ * @param returns The object to return after the test.
+ */
+ public FluentComparableAssertion(Comparable value, R returns) {
+ super(value, returns);
+ this.value = value;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param creator The assertion that created this assertion.
+ * @param value The value being tested.
+ * @param returns The object to return after the test.
+ */
+ public FluentComparableAssertion(Assertion creator, Comparable value, R
returns) {
+ super(creator, value, returns);
+ this.value = value;
+ }
+
+ /**
+ * Asserts that the value is greater than the specified value.
+ *
+ * @param value The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isGreaterThan(Comparable value) throws AssertionError {
+ exists();
+ if (value != null && this.value.compareTo(value) < 0)
+ throw error("Value was not greater than
expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
+ return returns();
+ }
+
+ /**
+ * Asserts that the value is greater than the specified value.
+ *
+ * <p>
+ * Equivalent to {@link #isGreaterThan(Comparable)}
+ *
+ * @param value The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isGt(Comparable value) throws AssertionError {
+ return isGreaterThan(value);
+ }
+
+ /**
+ * Asserts that the value is greater than or equal to the specified
value.
+ *
+ * @param value The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isGreaterThanOrEquals(Comparable value) throws AssertionError {
+ exists();
+ if (value != null && this.value.compareTo(value) > 0)
+ throw error("Value was not greater than or
equals to expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
+ return returns();
+ }
+
+ /**
+ * Asserts that the value is greater than or equal to the specified
value.
+ *
+ * <p>
+ * Equivalent to {@link #isGreaterThanOrEquals(Comparable)}
+ *
+ * @param value The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isGte(Comparable value) throws AssertionError {
+ return isGreaterThanOrEquals(value);
+ }
+
+ /**
+ * Asserts that the value is less than the specified value.
+ *
+ * @param value The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isLessThan(Comparable value) throws AssertionError {
+ exists();
+ if (value != null && this.value.compareTo(value) <= 0)
+ throw error("Value was not less than
expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
+ return returns();
+ }
+
+ /**
+ * Asserts that the value is less than the specified value.
+ *
+ * <p>
+ * Equivalent to {@link #isLessThan(Comparable)}
+ *
+ * @param value The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isLt(Comparable value) throws AssertionError {
+ return isLessThan(value);
+ }
+
+ /**
+ * Asserts that the value is less than or equals to the specified value.
+ *
+ * @param value The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isLessThanOrEquals(Comparable value) throws AssertionError {
+ exists();
+ if (value != null && this.value.compareTo(value) >= 0)
+ throw error("Value was not less than or equals
to expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
+ return returns();
+ }
+
+ /**
+ * Asserts that the value is less than or equals to the specified value.
+ *
+ * <p>
+ * Equivalent to {@link #isLessThanOrEquals(Comparable)}
+ *
+ * @param value The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isLte(Comparable value) throws AssertionError {
+ return isLessThanOrEquals(value);
+ }
+
+ /**
+ * Asserts that the value is between (inclusive) the specified upper
and lower values.
+ *
+ * @param lower The lower value to check against.
+ * @param upper The upper value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isBetween(Comparable lower, Comparable upper) throws
AssertionError {
+ isLessThanOrEquals(upper);
+ isGreaterThanOrEquals(lower);
+ return returns();
+ }
+}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentDateAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentDateAssertion.java
index 40170de..22e1003 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentDateAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentDateAssertion.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.internal.ObjectUtils.*;
import java.time.temporal.*;
import java.util.*;
-import java.util.function.*;
import org.apache.juneau.internal.*;
@@ -26,7 +25,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response expiration is after the current date.</jc>
- * client
+ * <jv>client</jv>
* .get(<jsf>URL</jsf>)
* .run()
* .assertDateHeader(<js>"Expires"</js>).isAfterNow();
@@ -35,7 +34,7 @@ import org.apache.juneau.internal.*;
* @param <R> The return type.
*/
@FluentSetters(returns="FluentDateAssertion<R>")
-public class FluentDateAssertion<R> extends FluentAssertion<R> {
+public class FluentDateAssertion<R> extends FluentComparableAssertion<R> {
private final Date value;
@@ -46,7 +45,7 @@ public class FluentDateAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentDateAssertion(Date value, R returns) {
- super(returns);
+ super(value, returns);
this.value = value;
}
@@ -58,24 +57,11 @@ public class FluentDateAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentDateAssertion(Assertion creator, Date value, R returns) {
- super(creator, returns);
+ super(creator, value, returns);
this.value = value;
}
/**
- * Asserts that the value equals the specified value.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R equals(Date value) throws AssertionError {
- if (ne(this.value, value))
- throw error("Unexpected
value.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
* Asserts that the value equals the specified value at the specified
precision.
*
* @param value The value to check against.
@@ -90,97 +76,6 @@ public class FluentDateAssertion<R> extends
FluentAssertion<R> {
}
/**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #equals(Date)}.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R is(Date value) throws AssertionError {
- return equals(value);
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R doesNotEqual(Date value) throws AssertionError {
- if (eq(this.value, value))
- throw error("Unexpected value.\n\tExpected
not=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #doesNotEqual(Date)}.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNot(Date value) throws AssertionError {
- return doesNotEqual(value);
- }
-
- /**
- * Asserts that the date is not null.
- *
- * <p>
- * Equivalent to {@link #isNotNull()}.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R exists() throws AssertionError {
- return isNotNull();
- }
-
- /**
- * Asserts that the date is not null.
- *
- * <p>
- * Equivalent to {@link #isNull()}.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R doesNotExist() throws AssertionError {
- return isNull();
- }
-
- /**
- * Asserts that the date is not null.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNull() throws AssertionError {
- if (value != null)
- throw error("Value was not null.");
- return returns();
- }
-
- /**
- * Asserts that the date is not null.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNotNull() throws AssertionError {
- if (value == null)
- throw error("Value was null.");
- return returns();
- }
-
- /**
* Asserts that the value is after the specified value.
*
* @param value The values to check against.
@@ -242,19 +137,6 @@ public class FluentDateAssertion<R> extends
FluentAssertion<R> {
return returns();
}
- /**
- * Asserts that the value passes the specified predicate test.
- *
- * @param test The predicate to use to test the value.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R passes(Predicate<Date> test) throws AssertionError {
- if (! test.test(value))
- throw error("Value did not pass predicate
test.\n\tValue=[{0}]", value);
- return returns();
- }
-
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentIntegerAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentIntegerAssertion.java
index 113b7a7..1066e27 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentIntegerAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentIntegerAssertion.java
@@ -13,10 +13,7 @@
package org.apache.juneau.assertions;
-import java.util.function.*;
-
import org.apache.juneau.internal.*;
-import org.apache.juneau.marshall.*;
/**
* Used for fluent assertion calls against integers.
@@ -24,7 +21,7 @@ import org.apache.juneau.marshall.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response status code is 200 or 404.</jc>
- * client
+ * <jv>client</jv>
* .get(<jsf>URL</jsf>)
* .run()
* .assertStatus().isAny(200,404);
@@ -33,9 +30,7 @@ import org.apache.juneau.marshall.*;
* @param <R> The return type.
*/
@FluentSetters(returns="FluentIntegerAssertion<R>")
-public class FluentIntegerAssertion<R> extends FluentAssertion<R> {
-
- private final Integer value;
+public class FluentIntegerAssertion<R> extends FluentComparableAssertion<R> {
/**
* Constructor.
@@ -44,8 +39,7 @@ public class FluentIntegerAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentIntegerAssertion(Integer value, R returns) {
- super(returns);
- this.value = value;
+ super(value, returns);
}
/**
@@ -56,287 +50,7 @@ public class FluentIntegerAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentIntegerAssertion(Assertion creator, Integer value, R
returns) {
- super(creator, returns);
- this.value = value;
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R equals(Integer value) throws AssertionError {
- if (this.value == value)
- return returns();
- exists();
- if (! this.value.equals(value))
- throw error("Unexpected
value.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #equals(Integer)}.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R is(Integer value) throws AssertionError {
- return equals(value);
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R doesNotEqual(Integer value) throws AssertionError {
- if (this.value != value)
- return returns();
- exists();
- if (this.value.equals(value))
- throw error("Unexpected value.\n\tExpected
not=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #doesNotEqual(Integer)}.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNot(Integer value) throws AssertionError {
- return doesNotEqual(value);
- }
-
- /**
- * Asserts that the integer is not null.
- *
- * <p>
- * Equivalent to {@link #isNotNull()}.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R exists() throws AssertionError {
- return isNotNull();
- }
-
- /**
- * Asserts that the integer is not null.
- *
- * <p>
- * Equivalent to {@link #isNull()}.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R doesNotExist() throws AssertionError {
- return isNull();
- }
-
- /**
- * Asserts that the integer is not null.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNull() throws AssertionError {
- if (value != null)
- throw error("Value was not null.");
- return returns();
- }
-
- /**
- * Asserts that the integer is not null.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNotNull() throws AssertionError {
- if (value == null)
- throw error("Value was null.");
- return returns();
- }
-
- /**
- * Asserts that the value is one of the specified values.
- *
- * @param values The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isAny(Integer...values) throws AssertionError {
- exists();
- for (Integer v : values)
- if (this.value.equals(v))
- return returns();
- throw error("Expected value not
found.\n\tExpected=[{0}]\n\tActual=[{1}]", SimpleJson.DEFAULT.toString(values),
value);
- }
-
- /**
- * Asserts that the value is one of the specified values.
- *
- * @param values The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNotAny(Integer...values) throws AssertionError {
- exists();
- for (Integer v : values)
- if (this.value.equals(v))
- throw error("Unexpected value
found.\n\tUnexpected=[{0}]\n\tActual=[{1}]", v, value);
- return returns();
- }
-
- /**
- * Asserts that the value is greater than the specified value.
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isGreaterThan(Integer value) throws AssertionError {
- exists();
- if (! (this.value > value))
- throw error("Value was not greater than
expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value is greater than the specified value.
- *
- * <p>
- * Equivalent to {@link #isGreaterThan(Integer)}
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isGt(Integer value) throws AssertionError {
- return isGreaterThan(value);
- }
-
- /**
- * Asserts that the value is greater than or equal to the specified
value.
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isGreaterThanOrEquals(Integer value) throws AssertionError {
- exists();
- if (! (this.value >= value))
- throw error("Value was not greater than or
equals to expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value is greater than or equal to the specified
value.
- *
- * <p>
- * Equivalent to {@link #isGreaterThanOrEquals(Integer)}
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isGte(Integer value) throws AssertionError {
- return isGreaterThanOrEquals(value);
- }
-
- /**
- * Asserts that the value is less than the specified value.
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isLessThan(Integer value) throws AssertionError {
- exists();
- if (! (this.value < value))
- throw error("Value was not less than
expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value is less than the specified value.
- *
- * <p>
- * Equivalent to {@link #isLessThan(Integer)}
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isLt(Integer value) throws AssertionError {
- return isLessThan(value);
- }
-
- /**
- * Asserts that the value is less than or equals to the specified value.
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isLessThanOrEquals(Integer value) throws AssertionError {
- exists();
- if (! (this.value <= value))
- throw error("Value was not less than or equals
to expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value is less than or equals to the specified value.
- *
- * <p>
- * Equivalent to {@link #isLessThanOrEquals(Integer)}
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isLte(Integer value) throws AssertionError {
- return isLessThanOrEquals(value);
- }
-
- /**
- * Asserts that the value is between (inclusive) the specified upper
and lower values.
- *
- * @param lower The lower value to check against.
- * @param upper The upper value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isBetween(Integer lower, Integer upper) throws AssertionError {
- isLessThanOrEquals(upper);
- isGreaterThanOrEquals(lower);
- return returns();
- }
-
- /**
- * Asserts that the value passes the specified predicate test.
- *
- * @param test The predicate to use to test the value.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R passes(Predicate<Integer> test) throws AssertionError {
- if (! test.test(value))
- throw error("Value did not pass predicate
test.\n\tValue=[{0}]", value);
- return returns();
+ super(creator, value, returns);
}
// <FluentSetters>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentListAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentListAssertion.java
new file mode 100644
index 0000000..cbb0d72
--- /dev/null
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentListAssertion.java
@@ -0,0 +1,182 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import java.util.*;
+
+import org.apache.juneau.internal.*;
+
+/**
+ * Used for fluent assertion calls against lists.
+ *
+ * @param <R> The return type.
+ */
+@FluentSetters(returns="FluentListAssertion<R>")
+@SuppressWarnings("rawtypes")
+public class FluentListAssertion<R> extends FluentCollectionAssertion<R> {
+
+ private List value;
+
+ /**
+ * Constructor.
+ *
+ * @param contents The byte array being tested.
+ * @param returns The object to return after the test.
+ */
+ public FluentListAssertion(List contents, R returns) {
+ super(contents, returns);
+ this.value = contents;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param creator The assertion that created this assertion.
+ * @param contents The byte array being tested.
+ * @param returns The object to return after the test.
+ */
+ public FluentListAssertion(Assertion creator, List contents, R returns)
{
+ super(creator, contents, returns);
+ this.value = contents;
+ }
+
+ /**
+ * Returns an object assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the list is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the list.
+ * @return A new assertion.
+ */
+ public FluentObjectAssertion<R> item(int index) {
+ return new FluentObjectAssertion<>(this, getItem(index),
returns());
+ }
+
+ /**
+ * Returns a string assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the list is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the list.
+ * @return A new assertion.
+ */
+ public FluentStringAssertion<R> stringItem(int index) {
+ return new FluentStringAssertion<>(this,
StringUtils.stringify(getItem(index)), returns());
+ }
+
+ /**
+ * Returns a date assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the list is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the list.
+ * @return A new assertion.
+ */
+ public FluentDateAssertion<R> dateItem(int index) {
+ return new FluentDateAssertion<>(this, getItem(Date.class,
index), returns());
+ }
+
+ /**
+ * Returns an integer assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the list is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the list.
+ * @return A new assertion.
+ */
+ public FluentIntegerAssertion<R> integerItem(int index) {
+ return new FluentIntegerAssertion<>(this,
getItem(Integer.class, index), returns());
+ }
+
+ /**
+ * Returns a long assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the list is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the list.
+ * @return A new assertion.
+ */
+ public FluentLongAssertion<R> longItem(int index) {
+ return new FluentLongAssertion<>(this, getItem(Long.class,
index), returns());
+ }
+
+ /**
+ * Returns a list assertion on the item specified at the specified
index.
+ *
+ * <p>
+ * If the list is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the list.
+ * @return A new assertion.
+ */
+ public FluentListAssertion<R> listItem(int index) {
+ return new FluentListAssertion<>(this, getItem(List.class,
index), returns());
+ }
+
+ /**
+ * Returns a collection assertion on the item specified at the
specified index.
+ *
+ * <p>
+ * If the list is <jk>null</jk> or the index is out-of-bounds, the
returned assertion is a null assertion
+ * (meaning {@link FluentObjectAssertion#exists()} returns
<jk>false</jk>).
+ *
+ * @param index The index of the item to retrieve from the list.
+ * @return A new assertion.
+ */
+ public FluentCollectionAssertion<R> collectionItem(int index) {
+ return new FluentCollectionAssertion<>(this,
getItem(Collection.class, index), returns());
+ }
+
+ private Object getItem(int index) {
+ if (value != null && value.size() > index)
+ return value.get(index);
+ return null;
+ }
+
+ private <T> T getItem(Class<T> c, int index) {
+ return cast(c, getItem(index));
+ }
+
+ // <FluentSetters>
+
+ @Override /* GENERATED - Assertion */
+ public FluentListAssertion<R> msg(String msg, Object...args) {
+ super.msg(msg, args);
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentListAssertion<R> stderr() {
+ super.stderr();
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentListAssertion<R> stdout() {
+ super.stdout();
+ return this;
+ }
+
+ // </FluentSetters>
+}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
index 5903552..643ff83 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
@@ -13,10 +13,7 @@
package org.apache.juneau.assertions;
-import java.util.function.*;
-
import org.apache.juneau.internal.*;
-import org.apache.juneau.marshall.*;
/**
* Used for fluent assertion calls against longs.
@@ -24,7 +21,7 @@ import org.apache.juneau.marshall.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response length isn't too long.</jc>
- * client
+ * <jv>client</jv>
* .get(<jsf>URL</jsf>)
* .run()
* .assertLongHeader(<js>"Length"</js>).isLessThan(100000);
@@ -33,9 +30,7 @@ import org.apache.juneau.marshall.*;
* @param <R> The return type.
*/
@FluentSetters(returns="FluentLongAssertion<R>")
-public class FluentLongAssertion<R> extends FluentAssertion<R> {
-
- private final Long value;
+public class FluentLongAssertion<R> extends FluentComparableAssertion<R> {
/**
* Constructor.
@@ -44,8 +39,7 @@ public class FluentLongAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentLongAssertion(Long value, R returns) {
- super(returns);
- this.value = value;
+ super(value, returns);
}
/**
@@ -56,301 +50,7 @@ public class FluentLongAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentLongAssertion(Assertion creator, Long value, R returns) {
- super(creator, returns);
- this.value = value;
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R equals(Long value) throws AssertionError {
- if (this.value == value)
- return returns();
- exists();
- if (! this.value.equals(value))
- throw error("Unexpected
value.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #equals(Long)}.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R is(Long value) throws AssertionError {
- return equals(value);
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #equals(Long)}.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R is(int value) throws AssertionError {
- return equals((long)value);
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R doesNotEqual(Long value) throws AssertionError {
- if (this.value != value)
- return returns();
- exists();
- if (this.value.equals(value))
- throw error("Unexpected value.\n\tExpected
not=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #doesNotEqual(Long)}.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNot(Long value) throws AssertionError {
- return doesNotEqual(value);
- }
-
- /**
- * Asserts that the long is not null.
- *
- * <p>
- * Equivalent to {@link #isNotNull()}.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R exists() throws AssertionError {
- return isNotNull();
- }
-
- /**
- * Asserts that the long is not null.
- *
- * <p>
- * Equivalent to {@link #isNull()}.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R doesNotExist() throws AssertionError {
- return isNull();
- }
-
- /**
- * Asserts that the long is not null.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNull() throws AssertionError {
- if (value != null)
- throw error("Value was not null.");
- return returns();
- }
-
- /**
- * Asserts that the long is not null.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNotNull() throws AssertionError {
- if (value == null)
- throw error("Value was null.");
- return returns();
- }
-
- /**
- * Asserts that the value is one of the specified values.
- *
- * @param values The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isAny(Long...values) throws AssertionError {
- exists();
- for (Long v : values)
- if (this.value.equals(v))
- return returns();
- throw error("Expected value not
found.\n\tExpected=[{0}]\n\tActual=[{1}]", SimpleJson.DEFAULT.toString(values),
value);
- }
-
- /**
- * Asserts that the value is one of the specified values.
- *
- * @param values The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNotAny(Long...values) throws AssertionError {
- exists();
- for (Long v : values)
- if (this.value.equals(v))
- throw error("Unexpected value
found.\n\tUnexpected=[{0}]\n\tActual=[{1}]", v, value);
- return returns();
- }
-
- /**
- * Asserts that the value is greater than the specified value.
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isGreaterThan(Long value) throws AssertionError {
- exists();
- if (! (this.value > value))
- throw error("Value was not greater than
expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value is greater than the specified value.
- *
- * <p>
- * Equivalent to {@link #isGreaterThan(Long)}
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isGt(Long value) throws AssertionError {
- return isGreaterThan(value);
- }
-
- /**
- * Asserts that the value is greater than or equal to the specified
value.
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isGreaterThanOrEquals(Long value) throws AssertionError {
- exists();
- if (! (this.value >= value))
- throw error("Value was not greater than or
equals to expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value is greater than or equal to the specified
value.
- *
- * <p>
- * Equivalent to {@link #isGreaterThanOrEquals(Long)}
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isGte(Long value) throws AssertionError {
- return isGreaterThanOrEquals(value);
- }
-
- /**
- * Asserts that the value is less than the specified value.
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isLessThan(Long value) throws AssertionError {
- exists();
- if (! (this.value < value))
- throw error("Value was not less than
expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value is less than the specified value.
- *
- * <p>
- * Equivalent to {@link #isLessThan(Long)}
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isLt(Long value) throws AssertionError {
- return isLessThan(value);
- }
-
- /**
- * Asserts that the value is less than or equals to the specified value.
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isLessThanOrEquals(Long value) throws AssertionError {
- exists();
- if (! (this.value <= value))
- throw error("Value was not less than or equals
to expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value is less than or equals to the specified value.
- *
- * <p>
- * Equivalent to {@link #isLessThanOrEquals(Long)}
- *
- * @param value The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isLte(Long value) throws AssertionError {
- return isLessThanOrEquals(value);
- }
-
- /**
- * Asserts that the value is between (inclusive) the specified upper
and lower values.
- *
- * @param lower The lower value to check against.
- * @param upper The upper value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isBetween(Long lower, Long upper) throws AssertionError {
- isLessThanOrEquals(upper);
- isGreaterThanOrEquals(lower);
- return returns();
- }
-
- /**
- * Asserts that the value passes the specified predicate test.
- *
- * @param test The predicate to use to test the value.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R passes(Predicate<Long> test) throws AssertionError {
- if (! test.test(value))
- throw error("Value did not pass predicate
test.\n\tValue=[{0}]", value);
- return returns();
+ super(creator, value, returns);
}
// <FluentSetters>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
index f14b58a..cc304fb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
@@ -16,6 +16,7 @@ import java.util.function.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.marshall.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
@@ -192,6 +193,97 @@ public class FluentObjectAssertion<R> extends
FluentAssertion<R> {
}
/**
+ * Asserts that the value equals the specified value.
+ *
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R equals(Integer value) throws AssertionError {
+ if (this.value == value)
+ return returns();
+ exists();
+ if (! this.value.equals(value))
+ throw error("Unexpected
value.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
+ return returns();
+ }
+
+ /**
+ * Asserts that the value equals the specified value.
+ *
+ * <p>
+ * Equivalent to {@link #equals(Integer)}.
+ *
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R is(Integer value) throws AssertionError {
+ return equals(value);
+ }
+
+ /**
+ * Asserts that the value equals the specified value.
+ *
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R doesNotEqual(Integer value) throws AssertionError {
+ if (this.value != value)
+ return returns();
+ exists();
+ if (this.value.equals(value))
+ throw error("Unexpected value.\n\tExpected
not=[{0}]\n\tActual=[{1}]", value, this.value);
+ return returns();
+ }
+ /**
+ * Asserts that the value equals the specified value.
+ *
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isEquals(Object value) throws AssertionError {
+ if (this.value == value)
+ return returns();
+ exists();
+ if (! this.value.equals(value))
+ throw error("Unexpected
value.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
+ return returns();
+ }
+
+ /**
+ * Asserts that the value equals the specified value.
+ *
+ * <p>
+ * Equivalent to {@link #equals(Integer)}.
+ *
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R is(Object value) throws AssertionError {
+ return isEquals(value);
+ }
+
+ /**
+ * Asserts that the value equals the specified value.
+ *
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R doesNotEqual(Object value) throws AssertionError {
+ if (this.value != value)
+ return returns();
+ exists();
+ if (this.value.equals(value))
+ throw error("Unexpected value.\n\tExpected
not=[{0}]\n\tActual=[{1}]", value, this.value);
+ return returns();
+ }
+
+ /**
* Asserts that the value passes the specified predicate test.
*
* @param test The predicate to use to test the value.
@@ -204,6 +296,122 @@ public class FluentObjectAssertion<R> extends
FluentAssertion<R> {
return returns();
}
+ /**
+ * Asserts that the value passes the specified predicate test.
+ *
+ * @param c The class type of the object being tested.
+ * @param <T> The class type of the object being tested.
+ * @param test The predicate to use to test the value.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ @SuppressWarnings("unchecked")
+ public <T> R passes(Class<T> c, Predicate<T> test) throws
AssertionError {
+ if (! test.test((T)value))
+ throw error("Value did not pass predicate
test.\n\tValue=[{0}]", value);
+ return returns();
+ }
+
+ /**
+ * Asserts that the object is not null.
+ *
+ * <p>
+ * Equivalent to {@link #isNotNull()}.
+ *
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R exists() throws AssertionError {
+ return isNotNull();
+ }
+
+ /**
+ * Asserts that the object is null.
+ *
+ * <p>
+ * Equivalent to {@link #isNotNull()}.
+ *
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R doesNotExist() throws AssertionError {
+ return isNull();
+ }
+
+ /**
+ * Asserts that the object is not null.
+ *
+ * <p>
+ * Equivalent to {@link #isNotNull()}.
+ *
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isNotNull() throws AssertionError {
+ if (value == null)
+ throw error("Value was null.");
+ return returns();
+ }
+
+ /**
+ * Asserts that the object i null.
+ *
+ * <p>
+ * Equivalent to {@link #isNotNull()}.
+ *
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isNull() throws AssertionError {
+ if (value != null)
+ throw error("Value was not null.");
+ return returns();
+ }
+
+ /**
+ * Asserts that the value equals the specified value.
+ *
+ * <p>
+ * Equivalent to {@link #doesNotEqual(Object)}.
+ *
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isNot(Object value) throws AssertionError {
+ return doesNotEqual(value);
+ }
+
+ /**
+ * Asserts that the value is one of the specified values.
+ *
+ * @param values The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isAny(Object...values) throws AssertionError {
+ exists();
+ for (Object v : values)
+ if (this.value.equals(v))
+ return returns();
+ throw error("Expected value not
found.\n\tExpected=[{0}]\n\tActual=[{1}]", SimpleJson.DEFAULT.toString(values),
value);
+ }
+
+ /**
+ * Asserts that the value is one of the specified values.
+ *
+ * @param values The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
+ */
+ public R isNotAny(Object...values) throws AssertionError {
+ exists();
+ for (Object v : values)
+ if (this.value.equals(v))
+ throw error("Unexpected value
found.\n\tUnexpected=[{0}]\n\tActual=[{1}]", v, value);
+ return returns();
+ }
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentStringAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentStringAssertion.java
index 7db0be3..8765046 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentStringAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentStringAssertion.java
@@ -27,7 +27,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response body of an HTTP call is the text
"OK".</jc>
- * client
+ * <jv>client</jv>
* .get(<jsf>URL</jsf>)
* .run()
* .assertBody().is(<js>"OK"</js>);
@@ -36,7 +36,7 @@ import org.apache.juneau.internal.*;
* @param <R> The return type.
*/
@FluentSetters(returns="FluentStringAssertion<R>")
-public class FluentStringAssertion<R> extends FluentAssertion<R> {
+public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
private String text;
private boolean javaStrings;
@@ -48,7 +48,7 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentStringAssertion(String text, R returns) {
- super(returns);
+ super(text, returns);
this.text = text;
}
@@ -60,7 +60,7 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentStringAssertion(Assertion creator, String text, R returns)
{
- super(creator, returns);
+ super(creator, text, returns);
this.text = text;
}
@@ -86,7 +86,6 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
* @param replacement The string to be substituted for each match.
* @return This object (for method chaining).
*/
- @FluentSetter
public FluentStringAssertion<R> replaceAll(String regex, String
replacement) {
return apply(x -> x == null ? null : text.replaceAll(regex,
replacement));
}
@@ -98,7 +97,6 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
* @param replacement The replacement sequence of char values.
* @return This object (for method chaining).
*/
- @FluentSetter
public FluentStringAssertion<R> replace(String target, String
replacement) {
return apply(x -> x == null ? null : text.replace(target,
replacement));
}
@@ -146,8 +144,7 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
* @return The response object (for method chaining).
*/
public FluentStringAssertion<R> apply(Function<String,String> f) {
- text = f.apply(text);
- return this;
+ return new FluentStringAssertion<>(this, f.apply(text),
returns());
}
/**
@@ -185,7 +182,7 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
*/
public R equals(String...value) throws AssertionError {
String v = join(value, '\n');
- if (! isEquals(v, text))
+ if (! StringUtils.isEquals(v, text))
throw error("Text differed at position
{0}.\n\tExpected=[{1}]\n\tActual=[{2}]", diffPosition(v, text), fix(v),
fix(text));
return returns();
}
@@ -302,7 +299,7 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
* @throws AssertionError If assertion failed.
*/
public R doesNotEqual(String value) throws AssertionError {
- if (isEquals(value, text))
+ if (StringUtils.isEquals(value, text))
throw error("Text equaled unexpected.\n\tText=[{1}]",
fix(value), fix(text));
return returns();
}
@@ -363,56 +360,6 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
}
/**
- * Asserts that the text is not null.
- *
- * <p>
- * Equivalent to {@link #isNotNull()}.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R exists() throws AssertionError {
- return isNotNull();
- }
-
- /**
- * Asserts that the text is not null.
- *
- * <p>
- * Equivalent to {@link #isNull()}.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R doesNotExist() throws AssertionError {
- return isNull();
- }
-
- /**
- * Asserts that the text is not null.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNull() throws AssertionError {
- if (text != null)
- throw error("Text was not null. Text=[{0}]",
fix(text));
- return returns();
- }
-
- /**
- * Asserts that the text is not null.
- *
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isNotNull() throws AssertionError {
- if (text == null)
- throw error("Text was null.");
- return returns();
- }
-
- /**
* Asserts that the text is not empty.
*
* @return The response object (for method chaining).
@@ -439,19 +386,6 @@ public class FluentStringAssertion<R> extends
FluentAssertion<R> {
}
/**
- * Asserts that the text passes the specified predicate test.
- *
- * @param test The predicate to use to test the value.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R passes(Predicate<String> test) throws AssertionError {
- if (! test.test(text))
- throw error("Text did not pass predicate
test.\n\tText=[{0}]", fix(text));
- return returns();
- }
-
- /**
* Asserts that the text matches the specified regular expression.
*
* @param regex The pattern to test for.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/IntegerAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/IntegerAssertion.java
index a042b62..76e8b04 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/IntegerAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/IntegerAssertion.java
@@ -20,7 +20,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response status code is 200 or 404.</jc>
- * <jsm>assertInteger</jsm>(httpReponse).isAny(200,404);
+ * <jsm>assertInteger</jsm>(<jv>httpReponse</jv>).isAny(200,404);
* </p>
*/
@FluentSetters(returns="IntegerAssertion")
@@ -29,20 +29,20 @@ public class IntegerAssertion extends
FluentIntegerAssertion<IntegerAssertion> {
/**
* Creator.
*
- * @param integer The object being wrapped.
+ * @param value The object being wrapped.
* @return A new {@link IntegerAssertion} object.
*/
- public static IntegerAssertion create(Integer integer) {
- return new IntegerAssertion(integer);
+ public static IntegerAssertion create(Integer value) {
+ return new IntegerAssertion(value);
}
/**
* Creator.
*
- * @param integer The object being wrapped.
+ * @param value The object being wrapped.
*/
- public IntegerAssertion(Integer integer) {
- super(integer, null);
+ public IntegerAssertion(Integer value) {
+ super(value, null);
}
@Override
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ObjectAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ListAssertion.java
similarity index 75%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ObjectAssertion.java
copy to
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ListAssertion.java
index b598c3c..daf5c8f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ObjectAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ListAssertion.java
@@ -12,60 +12,63 @@
//
***************************************************************************************************************************
package org.apache.juneau.assertions;
+import java.util.*;
+
import org.apache.juneau.internal.*;
/**
- * Used for assertion calls against arbitrary POJOs.
+ * Used for assertion calls against lists.
*
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the specified POJO is the specified type.</jc>
- * <jsm>assertObject</jsm>(myPojo).instanceOf(MyBean.<jk>class</jk>);
+ * <jsm>assertList</jsm>(<jv>myList</jv>).isNotEmpty();
* </p>
*/
-@FluentSetters(returns="ObjectAssertion")
-public class ObjectAssertion extends FluentObjectAssertion<ObjectAssertion> {
+@FluentSetters(returns="ListAssertion")
+@SuppressWarnings("rawtypes")
+public class ListAssertion extends FluentListAssertion<ListAssertion> {
/**
* Creator.
*
- * @param object The object being wrapped.
- * @return A new {@link ObjectAssertion} object.
+ * @param value The object being wrapped.
+ * @return A new {@link ListAssertion} object.
*/
- public static ObjectAssertion create(Object object) {
- return new ObjectAssertion(object);
+ public static ListAssertion create(List value) {
+ return new ListAssertion(value);
}
/**
* Creator.
*
- * @param object The object being wrapped.
+ * @param value The object being wrapped.
*/
- public ObjectAssertion(Object object) {
- super(object, null);
+ public ListAssertion(List value) {
+ super(value, null);
}
@Override
- protected ObjectAssertion returns() {
+ protected ListAssertion returns() {
return this;
}
// <FluentSetters>
@Override /* GENERATED - Assertion */
- public ObjectAssertion msg(String msg, Object...args) {
+ public ListAssertion msg(String msg, Object...args) {
super.msg(msg, args);
return this;
}
@Override /* GENERATED - Assertion */
- public ObjectAssertion stderr() {
+ public ListAssertion stderr() {
super.stderr();
return this;
}
@Override /* GENERATED - Assertion */
- public ObjectAssertion stdout() {
+ public ListAssertion stdout() {
super.stdout();
return this;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
index aeec9a3..65974fd 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/LongAssertion.java
@@ -20,7 +20,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response length isn't too long.</jc>
- * <jsm>assertLong</jsm>(responseLength).isLessThan(100000);
+ * <jsm>assertLong</jsm>(<jv>responseLength</jv>).isLessThan(100000);
* </p>
*/
@FluentSetters(returns="LongAssertion")
@@ -29,20 +29,20 @@ public class LongAssertion extends
FluentLongAssertion<LongAssertion> {
/**
* Creator.
*
- * @param l The object being wrapped.
+ * @param value The object being wrapped.
* @return A new {@link LongAssertion} object.
*/
- public static LongAssertion create(Long l) {
- return new LongAssertion(l);
+ public static LongAssertion create(Long value) {
+ return new LongAssertion(value);
}
/**
* Creator.
*
- * @param l The object being wrapped.
+ * @param value The object being wrapped.
*/
- public LongAssertion(Long l) {
- super(l, null);
+ public LongAssertion(Long value) {
+ super(value, null);
}
@Override
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ObjectAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ObjectAssertion.java
index b598c3c..b100f01 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ObjectAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ObjectAssertion.java
@@ -20,7 +20,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the specified POJO is the specified type.</jc>
- * <jsm>assertObject</jsm>(myPojo).instanceOf(MyBean.<jk>class</jk>);
+ *
<jsm>assertObject</jsm>(<jv>myPojo</jv>).instanceOf(MyBean.<jk>class</jk>);
* </p>
*/
@FluentSetters(returns="ObjectAssertion")
@@ -29,20 +29,20 @@ public class ObjectAssertion extends
FluentObjectAssertion<ObjectAssertion> {
/**
* Creator.
*
- * @param object The object being wrapped.
+ * @param value The object being wrapped.
* @return A new {@link ObjectAssertion} object.
*/
- public static ObjectAssertion create(Object object) {
- return new ObjectAssertion(object);
+ public static ObjectAssertion create(Object value) {
+ return new ObjectAssertion(value);
}
/**
* Creator.
*
- * @param object The object being wrapped.
+ * @param value The object being wrapped.
*/
- public ObjectAssertion(Object object) {
- super(object, null);
+ public ObjectAssertion(Object value) {
+ super(value, null);
}
@Override
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/StringAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/StringAssertion.java
index 877bbf6..a531c10 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/StringAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/StringAssertion.java
@@ -22,7 +22,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the response body of an HTTP call is the text
"OK".</jc>
- * <jsm>assertString</jsm>(httpBody).is(<js>"OK"</js>);
+ * <jsm>assertString</jsm>(<jv>httpBody</jv>).is(<js>"OK"</js>);
* </p>
*/
@FluentSetters(returns="StringAssertion")
@@ -31,11 +31,11 @@ public class StringAssertion extends
FluentStringAssertion<StringAssertion> {
/**
* Creator.
*
- * @param text The string being wrapped.
+ * @param value The string being wrapped.
* @return A new {@link StringAssertion} object.
*/
- public static StringAssertion create(Object text) {
- return new StringAssertion(text);
+ public static StringAssertion create(Object value) {
+ return new StringAssertion(value);
}
/**
@@ -78,17 +78,5 @@ public class StringAssertion extends
FluentStringAssertion<StringAssertion> {
return this;
}
- @Override /* GENERATED - FluentStringAssertion */
- public StringAssertion replace(String target, String replacement) {
- super.replace(target, replacement);
- return this;
- }
-
- @Override /* GENERATED - FluentStringAssertion */
- public StringAssertion replaceAll(String regex, String replacement) {
- super.replaceAll(regex, replacement);
- return this;
- }
-
// </FluentSetters>
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ThrowableAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ThrowableAssertion.java
index 0bff491..951fabd 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ThrowableAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ThrowableAssertion.java
@@ -20,7 +20,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jc>// Validates the throwable message or one of the parent messages
contain 'Foobar'.</jc>
- * <jsm>assertThrowable</jsm>(throwable).contains(<js>"Foobar"</js>);
+ *
<jsm>assertThrowable</jsm>(<jv>throwable</jv>).contains(<js>"Foobar"</js>);
* </p>
*/
@FluentSetters(returns="ThrowableAssertion")
@@ -29,20 +29,20 @@ public class ThrowableAssertion extends
FluentThrowableAssertion<ThrowableAssert
/**
* Creator.
*
- * @param throwable The throwable being wrapped.
+ * @param value The throwable being wrapped.
* @return A new {@link ThrowableAssertion} object.
*/
- public static ThrowableAssertion create(Throwable throwable) {
- return new ThrowableAssertion(throwable);
+ public static ThrowableAssertion create(Throwable value) {
+ return new ThrowableAssertion(value);
}
/**
* Creator.
*
- * @param throwable The throwable being wrapped.
+ * @param value The throwable being wrapped.
*/
- public ThrowableAssertion(Throwable throwable) {
- super(throwable, null);
+ public ThrowableAssertion(Throwable value) {
+ super(value, null);
}
@Override
diff --git
a/juneau-releng/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java
b/juneau-releng/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java
index 2bf2796..7502f62 100644
---
a/juneau-releng/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java
+++
b/juneau-releng/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java
@@ -170,6 +170,10 @@ public class ConfigurablePropertyCodeGenerator {
FluentStringAssertion.class,
FluentThrowableAssertion.class,
FluentObjectAssertion.class,
+ FluentComparableAssertion.class,
+ FluentArrayAssertion.class,
+ FluentCollectionAssertion.class,
+ FluentListAssertion.class,
DateAssertion.class,
IntegerAssertion.class,
@@ -177,6 +181,10 @@ public class ConfigurablePropertyCodeGenerator {
StringAssertion.class,
ThrowableAssertion.class,
ObjectAssertion.class,
+ ComparableAssertion.class,
+ ArrayAssertion.class,
+ CollectionAssertion.class,
+ ListAssertion.class,
BasicHttpResource.class,
StreamResource.class,
diff --git
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Body_Test.java
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Body_Test.java
index 7ad4e4e..56d6ead 100644
---
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Body_Test.java
+++
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Body_Test.java
@@ -363,7 +363,7 @@ public class RestClient_Response_Body_Test {
public void b02_head() throws Exception {
assertFalse(client().build().head("").run().getBody().isRepeatable());
assertFalse(client().build().head("").run().getBody().isChunked());
-
assertLong(client().build().head("").run().getBody().getContentLength()).is(-1);
+
assertLong(client().build().head("").run().getBody().getContentLength()).is(-1l);
client().build().head("").run().getBody().getContentType().assertString().isNull();
client().build().head("").run().getBody().getContentEncoding().assertString().isNull();
client().build().head("").run().getBody().writeTo(new
ByteArrayOutputStream());