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 b062fdf Assertion API improvements.
b062fdf is described below
commit b062fdf9036d84115ca2586e933b53bd04225c34
Author: JamesBognar <[email protected]>
AuthorDate: Tue Jul 13 18:16:49 2021 -0400
Assertion API improvements.
---
.../apache/juneau/assertions/ArrayAssertion.java | 10 +-
.../org/apache/juneau/assertions/Assertion.java | 32 +-
.../juneau/assertions/AssertionPredicate.java | 46 +-
.../juneau/assertions/AssertionPredicates.java | 3 +-
.../org/apache/juneau/assertions/Assertions.java | 2 +-
.../apache/juneau/assertions/BeanAssertion.java | 8 +
.../juneau/assertions/BeanListAssertion.java | 8 +
.../apache/juneau/assertions/BooleanAssertion.java | 8 +
.../juneau/assertions/ByteArrayAssertion.java | 8 +
.../juneau/assertions/CollectionAssertion.java | 8 +
.../juneau/assertions/ComparableAssertion.java | 8 +
.../apache/juneau/assertions/DateAssertion.java | 8 +
.../juneau/assertions/FluentArrayAssertion.java | 173 ++---
.../apache/juneau/assertions/FluentAssertion.java | 31 +-
.../juneau/assertions/FluentBeanAssertion.java | 22 +-
.../juneau/assertions/FluentBeanListAssertion.java | 22 +-
.../juneau/assertions/FluentBooleanAssertion.java | 14 +-
.../assertions/FluentByteArrayAssertion.java | 12 +
.../assertions/FluentCollectionAssertion.java | 40 +-
.../assertions/FluentComparableAssertion.java | 42 +-
.../juneau/assertions/FluentDateAssertion.java | 14 +-
.../juneau/assertions/FluentIntegerAssertion.java | 34 +-
.../juneau/assertions/FluentListAssertion.java | 46 +-
.../juneau/assertions/FluentLongAssertion.java | 38 +-
.../juneau/assertions/FluentMapAssertion.java | 36 +-
.../juneau/assertions/FluentObjectAssertion.java | 724 +++++++++++----------
.../assertions/FluentPrimitiveArrayAssertion.java | 88 ++-
.../juneau/assertions/FluentStringAssertion.java | 48 +-
.../assertions/FluentThrowableAssertion.java | 173 ++---
.../juneau/assertions/FluentVersionAssertion.java | 12 +
.../assertions/FluentZonedDateTimeAssertion.java | 14 +-
.../apache/juneau/assertions/IntegerAssertion.java | 8 +
.../apache/juneau/assertions/ListAssertion.java | 8 +
.../apache/juneau/assertions/LongAssertion.java | 8 +
.../org/apache/juneau/assertions/MapAssertion.java | 8 +
.../apache/juneau/assertions/ObjectAssertion.java | 8 +
.../juneau/assertions/PrimitiveArrayAssertion.java | 8 +
.../apache/juneau/assertions/StringAssertion.java | 8 +
.../juneau/assertions/ThrowableAssertion.java | 8 +
.../java/org/apache/juneau/assertions/Verify.java | 12 +
.../apache/juneau/assertions/VersionAssertion.java | 8 +
.../juneau/assertions/ZonedDateTimeAssertion.java | 8 +
.../apache/juneau/assertions/Messages.properties | 1 -
43 files changed, 1149 insertions(+), 676 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ArrayAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ArrayAssertion.java
index 2a58fa9..c2a0904 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ArrayAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ArrayAssertion.java
@@ -22,7 +22,7 @@ import org.apache.juneau.internal.*;
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* <jk>import static</jk> org.apache.juneau.assertions.Assertions.*;
- *
+ *
* String[] <jv>array</jv> = {<js>"foo"</js>};
* <jsm>assertArray</jsm>(<jv>array</jv>).exists().isSize(1);
* </p>
@@ -32,6 +32,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="ArrayAssertion<E>")
public class ArrayAssertion<E> extends
FluentArrayAssertion<E,ArrayAssertion<E>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -51,6 +55,10 @@ public class ArrayAssertion<E> extends
FluentArrayAssertion<E,ArrayAssertion<E>>
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 0325bcf..989c4ed 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
@@ -33,10 +33,14 @@ public class Assertion {
MSG_parameterCannotBeNull =
MESSAGES.getString("parameterCannotBeNull"),
MSG_causedBy = MESSAGES.getString("causedBy");
- String msg;
- Object[] msgArgs;
- PrintStream out = System.err;
- Class<? extends RuntimeException> throwable;
+ private String msg;
+ private Object[] msgArgs;
+ private PrintStream out = System.err;
+ private Class<? extends RuntimeException> throwable;
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
/**
* Constructor used when this assertion is being created from within
another assertion.
@@ -51,6 +55,10 @@ public class Assertion {
}
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Config
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Allows to to specify the assertion failure message.
*
@@ -148,6 +156,18 @@ public class Assertion {
return new BasicAssertionError(cause, msg);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
+ // <FluentSetters>
+
+ // </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Convenience method for getting the class name for an object.
*
@@ -168,8 +188,4 @@ public class Assertion {
protected static <E> Class<E[]> arrayClass(Class<E> c) {
return (Class<E[]>)Array.newInstance(c,0).getClass();
}
-
- // <FluentSetters>
-
- // </FluentSetters>
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/AssertionPredicate.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/AssertionPredicate.java
index 05df463..6f22603 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/AssertionPredicate.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/AssertionPredicate.java
@@ -56,18 +56,19 @@ public class AssertionPredicate<T> implements Predicate<T> {
public static final Function<Object,String> VALUE = x -> stringify(x);
private static final Messages MESSAGES =
Messages.of(AssertionPredicate.class, "Messages");
- static final String
+ private static final String
MSG_valueDidNotPassTest =
MESSAGES.getString("valueDidNotPassTest"),
- MSG_valueDidNotPassTestWithValue =
MESSAGES.getString("valueDidNotPassTestWithValue"),
- MSG_predicateTestFailed =
MESSAGES.getString("predicateTestFailed"),
- MSG_noPredicateTestsPassed =
MESSAGES.getString("noPredicateTestsPassed"),
- MSG_predicateTestsUnexpectedlyPassed =
MESSAGES.getString("predicateTestsUnexpectedlyPassed");
-
- final Predicate<T> inner;
- final String message;
- final Object[] args;
+ MSG_valueDidNotPassTestWithValue =
MESSAGES.getString("valueDidNotPassTestWithValue");
+
+ private final Predicate<T> inner;
+ private final String message;
+ private final Object[] args;
final ThreadLocal<String> failedMessage = new ThreadLocal<>();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -100,6 +101,10 @@ public class AssertionPredicate<T> implements Predicate<T>
{
this.args = null;
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
@Override /* Predicate */
@SuppressWarnings({"unchecked","rawtypes"})
public boolean test(T t) {
@@ -123,15 +128,23 @@ public class AssertionPredicate<T> implements
Predicate<T> {
return inner.test(t);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Returns the error message from the last call to this assertion.
*
* @return The error message, or <jk>null</jk> if there was no failure.
*/
- public String getFailureMessage() {
+ protected String getFailureMessage() {
return failedMessage.get();
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Subclasses
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Encapsulates multiple predicates into a single AND operation.
*
@@ -145,6 +158,10 @@ public class AssertionPredicate<T> implements Predicate<T>
{
private final Predicate<T>[] inner;
+ private static final Messages MESSAGES =
Messages.of(AssertionPredicate.class, "Messages");
+ private static final String
+ MSG_predicateTestFailed =
MESSAGES.getString("predicateTestFailed");
+
/**
* Constructor.
*
@@ -186,6 +203,10 @@ public class AssertionPredicate<T> implements Predicate<T>
{
*/
public static class Or<T> extends AssertionPredicate<T> {
+ private static final Messages MESSAGES =
Messages.of(AssertionPredicate.class, "Messages");
+ private static final String
+ MSG_noPredicateTestsPassed =
MESSAGES.getString("noPredicateTestsPassed");
+
private final Predicate<T>[] inner;
/**
@@ -221,6 +242,10 @@ public class AssertionPredicate<T> implements Predicate<T>
{
*/
public static class Not<T> extends AssertionPredicate<T> {
+ private static final Messages MESSAGES =
Messages.of(AssertionPredicate.class, "Messages");
+ private static final String
+ MSG_predicateTestsUnexpectedlyPassed =
MESSAGES.getString("predicateTestsUnexpectedlyPassed");
+
private final Predicate<T> inner;
/**
@@ -246,5 +271,4 @@ public class AssertionPredicate<T> implements Predicate<T> {
return true;
}
}
-
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/AssertionPredicates.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/AssertionPredicates.java
index 97396f8..1247a9f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/AssertionPredicates.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/AssertionPredicates.java
@@ -49,13 +49,12 @@ public class AssertionPredicates {
private static Function<Object,String> TYPENAME = x -> x == null ? null
: x.getClass().getName();
private static final Messages MESSAGES =
Messages.of(AssertionPredicates.class, "Messages");
- static final String
+ private static final String
MSG_valueWasNull = MESSAGES.getString("valueWasNull"),
MSG_valueWasNotNull = MESSAGES.getString("valueWasNotNull"),
MSG_valueDidNotMatchExpected =
MESSAGES.getString("valueDidNotMatchExpected"),
MSG_valueDidNotContainExpected =
MESSAGES.getString("valueDidNotContainExpected"),
MSG_valueUnexpectedlyMatched =
MESSAGES.getString("valueUnexpectedlyMatched"),
- MSG_valueDidNotMatchValue =
MESSAGES.getString("valueDidNotMatchValue"),
MSG_valueWasNotExpectedType =
MESSAGES.getString("valueWasNotExpectedType"),
MSG_valueDidNotMatchPattern =
MESSAGES.getString("valueDidNotMatchPattern");
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 65e1a58..4bf41b2 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,7 +28,7 @@ import org.apache.juneau.cp.*;
public class Assertions {
private static final Messages MESSAGES = Messages.of(Assertions.class,
"Messages");
- static final String
+ private static final String
MSG_argumentCannotBeNull =
MESSAGES.getString("argumentCannotBeNull");
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BeanAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BeanAssertion.java
index b0be0ce..bc7769d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BeanAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BeanAssertion.java
@@ -32,6 +32,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="BeanAssertion<T>")
public class BeanAssertion<T> extends FluentBeanAssertion<T,BeanAssertion<T>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -51,6 +55,10 @@ public class BeanAssertion<T> extends
FluentBeanAssertion<T,BeanAssertion<T>> {
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BeanListAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BeanListAssertion.java
index d2deab4..80630e2 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BeanListAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BeanListAssertion.java
@@ -33,6 +33,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="BeanListAssertion<E>")
public class BeanListAssertion<E> extends
FluentBeanListAssertion<E,BeanListAssertion<E>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -52,6 +56,10 @@ public class BeanListAssertion<E> extends
FluentBeanListAssertion<E,BeanListAsse
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BooleanAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BooleanAssertion.java
index 7e6d71f..e5aec68 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BooleanAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/BooleanAssertion.java
@@ -22,6 +22,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="BooleanAssertion")
public class BooleanAssertion extends FluentBooleanAssertion<BooleanAssertion>
{
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -41,6 +45,10 @@ public class BooleanAssertion extends
FluentBooleanAssertion<BooleanAssertion> {
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 e8db6e9..8b3823e 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
@@ -28,6 +28,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="ByteArrayAssertion")
public class ByteArrayAssertion extends
FluentByteArrayAssertion<ByteArrayAssertion> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -47,6 +51,10 @@ public class ByteArrayAssertion extends
FluentByteArrayAssertion<ByteArrayAssert
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/CollectionAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/CollectionAssertion.java
index 24afcaf..77efdbe 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/CollectionAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/CollectionAssertion.java
@@ -31,6 +31,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="CollectionAssertion<E>")
public class CollectionAssertion<E> extends
FluentCollectionAssertion<E,CollectionAssertion<E>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -50,6 +54,10 @@ public class CollectionAssertion<E> extends
FluentCollectionAssertion<E,Collecti
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ComparableAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ComparableAssertion.java
index 2bc592e..81db8cb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ComparableAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ComparableAssertion.java
@@ -24,6 +24,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="ComparableAssertion<T>")
public class ComparableAssertion<T extends Comparable<T>> extends
FluentComparableAssertion<T,ComparableAssertion<T>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -43,6 +47,10 @@ public class ComparableAssertion<T extends Comparable<T>>
extends FluentComparab
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 55c042e..fde7234 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
@@ -29,6 +29,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="DateAssertion")
public class DateAssertion extends FluentDateAssertion<DateAssertion> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -48,6 +52,10 @@ public class DateAssertion extends
FluentDateAssertion<DateAssertion> {
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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
index fcd5637..779edba 100644
---
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
@@ -34,7 +34,7 @@ import org.apache.juneau.internal.*;
public class FluentArrayAssertion<E,R> extends FluentObjectAssertion<E[],R> {
private static final Messages MESSAGES =
Messages.of(FluentArrayAssertion.class, "Messages");
- static final String
+ private static final String
MSG_arrayWasNotEmpty = MESSAGES.getString("arrayWasNotEmpty"),
MSG_arrayWasEmpty = MESSAGES.getString("arrayWasEmpty"),
MSG_arrayUnexpectedSize =
MESSAGES.getString("arrayUnexpectedSize"),
@@ -42,6 +42,10 @@ public class FluentArrayAssertion<E,R> extends
FluentObjectAssertion<E[],R> {
MSG_arrayContainedUnexpectedValue =
MESSAGES.getString("arrayContainedUnexpectedValue"),
MSG_arrayDidNotContainExpectedValueAt =
MESSAGES.getString("arrayDidNotContainExpectedValueAt");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -63,11 +67,72 @@ public class FluentArrayAssertion<E,R> extends
FluentObjectAssertion<E[],R> {
super(creator, contents, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
@Override /* FluentObjectAssertion */
public FluentArrayAssertion<E,R> apply(Function<E[],E[]> function) {
return new FluentArrayAssertion<>(this,
function.apply(orElse(null)), returns());
}
+ @Override /* FluentBaseAssertion */
+ public FluentStringAssertion<R> asString() {
+ return new FluentStringAssertion<>(this, toString(), returns());
+ }
+
+ /**
+ * Converts this assertion into a {@link FluentBeanListAssertion}.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Extracts the 'foo' property from an array of beans and
validates their values.</jc>.
+ *
<jsm>assertObject<jsm>(myArrayOfBeans).asBeanList().property(<js>"foo"</js>).sorted().equals(<js>"value1"</js>,<js>"value2"</js>,<js>"value3"</js>);
+ * </p>
+ *
+ * @return A new fluent string assertion.
+ */
+ public FluentBeanListAssertion<E,R> asBeanList() {
+ return new FluentBeanListAssertion<>(this, toList(), 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<E,R> item(int index) {
+ return new FluentObjectAssertion<>(this, at(index), returns());
+ }
+
+ /**
+ * Sorts the entries in this list.
+ *
+ * @return A new list assertion. The contents of the original list
remain unchanged.
+ */
+ public FluentListAssertion<E,R> sorted() {
+ return new FluentListAssertion<>(this, toSortedList(null),
returns());
+ }
+
+ /**
+ * Sorts the entries in this list using the specified comparator.
+ *
+ * @param comparator The comparator to use to sort the list.
+ * @return A new list assertion. The contents of the original list
remain unchanged.
+ */
+ public FluentListAssertion<E,R> sorted(Comparator<E> comparator) {
+ return new FluentListAssertion<>(this,
toSortedList(comparator), returns());
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that at least one value in the array passes the specified
test.
*
@@ -176,54 +241,6 @@ public class FluentArrayAssertion<E,R> extends
FluentObjectAssertion<E[],R> {
}
/**
- * 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<E,R> item(int index) {
- return new FluentObjectAssertion<>(this, at(index), returns());
- }
-
- /**
- * Converts this assertion into a {@link FluentBeanListAssertion}.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Extracts the 'foo' property from an array of beans and
validates their values.</jc>.
- *
<jsm>assertObject<jsm>(myArrayOfBeans).asBeanList().property(<js>"foo"</js>).sorted().equals(<js>"value1"</js>,<js>"value2"</js>,<js>"value3"</js>);
- * </p>
- *
- * @return A new fluent string assertion.
- */
- public FluentBeanListAssertion<E,R> asBeanList() {
- return new FluentBeanListAssertion<>(this, toList(), returns());
- }
-
- /**
- * Sorts the entries in this list.
- *
- * @return A new list assertion. The contents of the original list
remain unchanged.
- */
- public FluentListAssertion<E,R> sorted() {
- return new FluentListAssertion<>(this, toSortedList(null),
returns());
- }
-
- /**
- * Sorts the entries in this list using the specified comparator.
- *
- * @param comparator The comparator to use to sort the list.
- * @return A new list assertion. The contents of the original list
remain unchanged.
- */
- public FluentListAssertion<E,R> sorted(Comparator<E> comparator) {
- return new FluentListAssertion<>(this,
toSortedList(comparator), returns());
- }
-
- /**
* Asserts that the contents of this list contain the specified values
when each entry is converted to a string.
*
* @param entries The expected entries in this list.
@@ -256,8 +273,7 @@ public class FluentArrayAssertion<E,R> extends
FluentObjectAssertion<E[],R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- @SuppressWarnings("unchecked")
- public R equals(E...entries) throws AssertionError {
+ public R equals(Object...entries) throws AssertionError {
Predicate<E>[] p =
stream(entries).map(AssertionPredicates::eq).toArray(Predicate[]::new);
return each(p);
}
@@ -272,7 +288,7 @@ public class FluentArrayAssertion<E,R> extends
FluentObjectAssertion<E[],R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- public R is(@SuppressWarnings("unchecked") E...entries) throws
AssertionError {
+ public R is(Object...entries) throws AssertionError {
return equals(entries);
}
@@ -297,36 +313,10 @@ public class FluentArrayAssertion<E,R> extends
FluentObjectAssertion<E[],R> {
return returns();
}
- @Override /* FluentBaseAssertion */
- public FluentStringAssertion<R> asString() {
- return new FluentStringAssertion<>(this, toString(), returns());
- }
-
//-----------------------------------------------------------------------------------------------------------------
- // Helper methods.
+ // Fluent setters
//-----------------------------------------------------------------------------------------------------------------
- private int length() {
- return value().length;
- }
-
- private List<E> toList() {
- return valueIsNull() ? null : AList.of(value());
- }
-
- private List<E> toSortedList(Comparator<E> comparator) {
- return valueIsNull() ? null :
AList.of(value()).sortWith(comparator);
- }
-
- private E at(int index) {
- return valueIsNull() || index >= length() ? null :
value()[index];
- }
-
- @Override
- public String toString() {
- return valueIsNull() ? null : Arrays.toString(value());
- }
-
// <FluentSetters>
@Override /* GENERATED - Assertion */
@@ -360,4 +350,29 @@ public class FluentArrayAssertion<E,R> extends
FluentObjectAssertion<E[],R> {
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ private int length() {
+ return value().length;
+ }
+
+ private List<E> toList() {
+ return valueIsNull() ? null : AList.of(value());
+ }
+
+ private List<E> toSortedList(Comparator<E> comparator) {
+ return valueIsNull() ? null :
AList.of(value()).sortWith(comparator);
+ }
+
+ private E at(int index) {
+ return valueIsNull() || index >= length() ? null :
value()[index];
+ }
+
+ @Override
+ public String toString() {
+ return valueIsNull() ? null : Arrays.toString(value());
+ }
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentAssertion.java
index 2522c58..7cb81eb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentAssertion.java
@@ -26,6 +26,10 @@ public abstract class FluentAssertion<R> extends Assertion {
private final R returns;
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -37,15 +41,9 @@ public abstract class FluentAssertion<R> extends Assertion {
this.returns = returns;
}
- /**
- * Returns the object that the fluent methods on this class should
return.
- *
- * @return The response object.
- */
- @SuppressWarnings("unchecked")
- protected R returns() {
- return returns != null ? returns : (R)this;
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
// <FluentSetters>
@@ -80,4 +78,19 @@ public abstract class FluentAssertion<R> extends Assertion {
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Returns the object that the fluent methods on this class should
return.
+ *
+ * @return The response object.
+ */
+ @SuppressWarnings("unchecked")
+ protected R returns() {
+ return returns != null ? returns : (R)this;
+ }
+
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBeanAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBeanAssertion.java
index 2add9bb..168ffde 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBeanAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBeanAssertion.java
@@ -31,6 +31,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="FluentBeanAssertion<T,R>")
public class FluentBeanAssertion<T,R> extends FluentObjectAssertion<T,R> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -52,6 +56,10 @@ public class FluentBeanAssertion<T,R> extends
FluentObjectAssertion<T,R> {
super(creator, value, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
@Override /* FluentObjectAssertion */
public FluentBeanAssertion<T,R> apply(Function<T,T> function) {
return new FluentBeanAssertion<>(this,
function.apply(orElse(null)), returns());
@@ -90,13 +98,9 @@ public class FluentBeanAssertion<T,R> extends
FluentObjectAssertion<T,R> {
}
//-----------------------------------------------------------------------------------------------------------------
- // Helper methods.
+ // Fluent setters
//-----------------------------------------------------------------------------------------------------------------
- private BeanMap<T> toBeanMap() {
- return BeanMap.of(value());
- }
-
// <FluentSetters>
@Override /* GENERATED - Assertion */
@@ -130,4 +134,12 @@ public class FluentBeanAssertion<T,R> extends
FluentObjectAssertion<T,R> {
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ private BeanMap<T> toBeanMap() {
+ return BeanMap.of(value());
+ }
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBeanListAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBeanListAssertion.java
index 50ddcef..8b034ec 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBeanListAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBeanListAssertion.java
@@ -29,6 +29,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="FluentBeanListAssertion<E,R>")
public class FluentBeanListAssertion<E,R> extends FluentListAssertion<E,R> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -50,6 +54,10 @@ public class FluentBeanListAssertion<E,R> extends
FluentListAssertion<E,R> {
super(creator, contents, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Extracts the specified fields of this bean into a simple map of
key/value pairs and returns it as
* a new {@link FluentListAssertion} containing maps.
@@ -73,13 +81,9 @@ public class FluentBeanListAssertion<E,R> extends
FluentListAssertion<E,R> {
}
//-----------------------------------------------------------------------------------------------------------------
- // Helper methods.
+ // Fluent setters
//-----------------------------------------------------------------------------------------------------------------
- private static BeanMap<?> beanMap(Object o) {
- return BeanMap.of(o);
- }
-
// <FluentSetters>
@Override /* GENERATED - Assertion */
@@ -113,4 +117,12 @@ public class FluentBeanListAssertion<E,R> extends
FluentListAssertion<E,R> {
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ private static BeanMap<?> beanMap(Object o) {
+ return BeanMap.of(o);
+ }
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBooleanAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBooleanAssertion.java
index b463a8d..999d5ae 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBooleanAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentBooleanAssertion.java
@@ -27,10 +27,14 @@ import org.apache.juneau.internal.*;
public class FluentBooleanAssertion<R> extends
FluentComparableAssertion<Boolean,R> {
private static final Messages MESSAGES =
Messages.of(FluentBooleanAssertion.class, "Messages");
- static final String
+ private static final String
MSG_valueWasFalse = MESSAGES.getString("valueWasFalse"),
MSG_valueWasTrue = MESSAGES.getString("valueWasTrue");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -52,6 +56,10 @@ public class FluentBooleanAssertion<R> extends
FluentComparableAssertion<Boolean
super(creator, value, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that the value is true.
*
@@ -76,6 +84,10 @@ public class FluentBooleanAssertion<R> extends
FluentComparableAssertion<Boolean
return returns();
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 e7d8c53..6cc7fb1 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
@@ -27,6 +27,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="FluentByteArrayAssertion<R>")
public class FluentByteArrayAssertion<R> extends
FluentPrimitiveArrayAssertion<byte[],R> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -48,6 +52,10 @@ public class FluentByteArrayAssertion<R> extends
FluentPrimitiveArrayAssertion<b
super(creator, contents, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Converts this byte array to a UTF-8 encoded string and returns it as
a new assertion.
*
@@ -125,6 +133,10 @@ public class FluentByteArrayAssertion<R> extends
FluentPrimitiveArrayAssertion<b
return new FluentStringAssertion<>(this, valueIsNull() ? null :
toSpacedHex(value()), returns());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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
index 0cb9c1d..544b684 100644
---
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
@@ -31,7 +31,7 @@ import org.apache.juneau.internal.*;
public class FluentCollectionAssertion<E,R> extends
FluentObjectAssertion<Collection<E>,R> {
private static final Messages MESSAGES =
Messages.of(FluentCollectionAssertion.class, "Messages");
- static final String
+ private static final String
MSG_collectionWasNotEmpty =
MESSAGES.getString("collectionWasNotEmpty"),
MSG_collectionDidNotContainExpectedValue =
MESSAGES.getString("collectionDidNotContainExpectedValue"),
MSG_collectionDidNotContainTestedValue =
MESSAGES.getString("collectionDidNotContainTestedValue"),
@@ -39,6 +39,10 @@ public class FluentCollectionAssertion<E,R> extends
FluentObjectAssertion<Collec
MSG_collectionWasEmpty =
MESSAGES.getString("collectionWasEmpty"),
MSG_collectionDidNotHaveExpectedSize =
MESSAGES.getString("collectionDidNotHaveExpectedSize");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -60,11 +64,19 @@ public class FluentCollectionAssertion<E,R> extends
FluentObjectAssertion<Collec
super(creator, contents, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
@Override /* FluentObjectAssertion */
public FluentCollectionAssertion<E,R>
apply(Function<Collection<E>,Collection<E>> function) {
return new FluentCollectionAssertion<>(this,
function.apply(orElse(null)), returns());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that the collection exists and is empty.
*
@@ -158,15 +170,9 @@ public class FluentCollectionAssertion<E,R> extends
FluentObjectAssertion<Collec
return returns();
}
- /**
- * Returns the size of this collection if it is not <jk>null</jk>.
- *
- * @return the size of this collection if it is not <jk>null</jk>.
- * @throws AssertionError If value was <jk>null</jk>.
- */
- protected int size() throws AssertionError {
- return value().size();
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
// <FluentSetters>
@@ -201,4 +207,18 @@ public class FluentCollectionAssertion<E,R> extends
FluentObjectAssertion<Collec
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Returns the size of this collection if it is not <jk>null</jk>.
+ *
+ * @return the size of this collection if it is not <jk>null</jk>.
+ * @throws AssertionError If value was <jk>null</jk>.
+ */
+ protected int size() throws AssertionError {
+ return value().size();
+ }
}
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
index 3a7c1bd..31454af 100644
---
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
@@ -31,12 +31,16 @@ import org.apache.juneau.internal.*;
public class FluentComparableAssertion<T extends Comparable,R> extends
FluentObjectAssertion<T,R> {
private static final Messages MESSAGES =
Messages.of(FluentComparableAssertion.class, "Messages");
- static final String
+ private static final String
MSG_valueWasNotGreaterThanExpected =
MESSAGES.getString("valueWasNotGreaterThanExpected"),
MSG_valueWasNotGreaterOrEqualsToExpected =
MESSAGES.getString("valueWasNotGreaterOrEqualsToExpected"),
MSG_valueWasNotLessThanExpected =
MESSAGES.getString("valueWasNotLessThanExpected"),
MSG_valueWasNotLessOrEqualsToExpected =
MESSAGES.getString("valueWasNotLessOrEqualsToExpected");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -58,11 +62,19 @@ public class FluentComparableAssertion<T extends
Comparable,R> extends FluentObj
super(creator, value, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
@Override /* FluentObjectAssertion */
public FluentComparableAssertion<T,R> apply(Function<T,T> function) {
return new FluentComparableAssertion<>(this,
function.apply(orElse(null)), returns());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that the value is greater than the specified value.
*
@@ -192,16 +204,9 @@ public class FluentComparableAssertion<T extends
Comparable,R> extends FluentObj
return returns();
}
- /**
- * Perform a comparison with the specified object.
- *
- * @param value The object to compare against.
- * @return The comparison value.
- * @throws AssertionError If value was <jk>null</jk>.
- */
- protected int compareTo(Object value) throws AssertionError {
- return value().compareTo(equivalent(value));
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
// <FluentSetters>
@@ -236,4 +241,19 @@ public class FluentComparableAssertion<T extends
Comparable,R> extends FluentObj
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Perform a comparison with the specified object.
+ *
+ * @param value The object to compare against.
+ * @return The comparison value.
+ * @throws AssertionError If value was <jk>null</jk>.
+ */
+ protected int compareTo(Object value) throws AssertionError {
+ return value().compareTo(equivalent(value));
+ }
}
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 32867e4..a929937 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
@@ -40,11 +40,15 @@ import org.apache.juneau.internal.*;
public class FluentDateAssertion<R> extends FluentComparableAssertion<Date,R> {
private static final Messages MESSAGES =
Messages.of(FluentDateAssertion.class, "Messages");
- static final String
+ private static final String
MSG_unexpectedValue = MESSAGES.getString("unexpectedValue"),
MSG_valueWasNotAfterExpected =
MESSAGES.getString("valueWasNotAfterExpected"),
MSG_valueWasNotBeforeExpected =
MESSAGES.getString("valueWasNotBeforeExpected");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -66,6 +70,10 @@ public class FluentDateAssertion<R> extends
FluentComparableAssertion<Date,R> {
super(creator, value, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that the value equals the specified value at the specified
precision.
*
@@ -145,6 +153,10 @@ public class FluentDateAssertion<R> extends
FluentComparableAssertion<Date,R> {
return returns();
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <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 86eab26..3e7dff9 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
@@ -34,6 +34,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="FluentIntegerAssertion<R>")
public class FluentIntegerAssertion<R> extends
FluentComparableAssertion<Integer,R> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -55,17 +59,9 @@ public class FluentIntegerAssertion<R> extends
FluentComparableAssertion<Integer
super(creator, value, returns);
}
- @Override
- protected int compareTo(Object value) {
- return value().compareTo(((Number)value).intValue());
- }
-
- @Override
- protected Object equivalent(Object o) {
- if (o instanceof Number)
- return ((Number)o).intValue();
- return o;
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
// <FluentSetters>
@@ -100,4 +96,20 @@ public class FluentIntegerAssertion<R> extends
FluentComparableAssertion<Integer
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ @Override
+ protected int compareTo(Object value) {
+ return value().compareTo(((Number)value).intValue());
+ }
+
+ @Override
+ protected Object equivalent(Object o) {
+ if (o instanceof Number)
+ return ((Number)o).intValue();
+ return o;
+ }
}
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
index dd84ed3..ecf7f5a 100644
---
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
@@ -32,9 +32,13 @@ import org.apache.juneau.internal.*;
public class FluentListAssertion<E,R> extends FluentCollectionAssertion<E,R> {
private static final Messages MESSAGES =
Messages.of(FluentListAssertion.class, "Messages");
- static final String
+ private static final String
MSG_listDidNotContainExpectedValueAt =
MESSAGES.getString("listDidNotContainExpectedValueAt");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -56,6 +60,10 @@ public class FluentListAssertion<E,R> extends
FluentCollectionAssertion<E,R> {
super(creator, contents, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Applies a transform on the inner object and returns a new inner
object.
*
@@ -99,6 +107,10 @@ public class FluentListAssertion<E,R> extends
FluentCollectionAssertion<E,R> {
return new FluentListAssertion<>(this,
toSortedList(comparator), returns());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that the contents of this list contain the specified values
when each entry is converted to a string.
*
@@ -175,23 +187,10 @@ public class FluentListAssertion<E,R> extends
FluentCollectionAssertion<E,R> {
return returns();
}
- @Override
- protected List<E> value() throws AssertionError {
- return (List<E>)super.value();
- }
-
//-----------------------------------------------------------------------------------------------------------------
- // Helper methods.
+ // Fluent setters
//-----------------------------------------------------------------------------------------------------------------
- private E at(int index) throws AssertionError {
- return valueIsNull() || index >= size() ? null :
value().get(index);
- }
-
- private List<E> toSortedList(Comparator<E> comparator) {
- return valueIsNull() ? null :
AList.of(value()).sortWith(comparator);
- }
-
// <FluentSetters>
@Override /* GENERATED - Assertion */
@@ -225,4 +224,21 @@ public class FluentListAssertion<E,R> extends
FluentCollectionAssertion<E,R> {
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ @Override
+ protected List<E> value() throws AssertionError {
+ return (List<E>)super.value();
+ }
+
+ private E at(int index) throws AssertionError {
+ return valueIsNull() || index >= size() ? null :
value().get(index);
+ }
+
+ private List<E> toSortedList(Comparator<E> comparator) {
+ return valueIsNull() ? null :
AList.of(value()).sortWith(comparator);
+ }
}
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 fce2175..c6f67cb 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
@@ -34,6 +34,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="FluentLongAssertion<R>")
public class FluentLongAssertion<R> extends FluentComparableAssertion<Long,R> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -55,6 +59,10 @@ public class FluentLongAssertion<R> extends
FluentComparableAssertion<Long,R> {
super(creator, value, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Converts this long into an integer and then returns it as an integer
assertion.
*
@@ -65,17 +73,9 @@ public class FluentLongAssertion<R> extends
FluentComparableAssertion<Long,R> {
return new FluentIntegerAssertion<>(this,
map(Long::intValue).orElse(null), returns());
}
- @Override
- protected int compareTo(Object value) {
- return value().compareTo(((Number)value).longValue());
- }
-
- @Override
- protected Object equivalent(Object o) {
- if (o instanceof Number)
- return ((Number)o).longValue();
- return o;
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
// <FluentSetters>
@@ -110,4 +110,20 @@ public class FluentLongAssertion<R> extends
FluentComparableAssertion<Long,R> {
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ @Override
+ protected int compareTo(Object value) {
+ return value().compareTo(((Number)value).longValue());
+ }
+
+ @Override
+ protected Object equivalent(Object o) {
+ if (o instanceof Number)
+ return ((Number)o).longValue();
+ return o;
+ }
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentMapAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentMapAssertion.java
index 3a97024..42ae70e 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentMapAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentMapAssertion.java
@@ -35,13 +35,17 @@ import org.apache.juneau.internal.*;
public class FluentMapAssertion<K,V,R> extends
FluentObjectAssertion<Map<K,V>,R> {
private static final Messages MESSAGES =
Messages.of(FluentMapAssertion.class, "Messages");
- static final String
+ private static final String
MSG_mapWasNotEmpty = MESSAGES.getString("mapWasNotEmpty"),
MSG_mapDidNotContainExpectedKey =
MESSAGES.getString("mapDidNotContainExpectedKey"),
MSG_mapContainedUnexpectedKey =
MESSAGES.getString("mapContainedUnexpectedKey"),
MSG_mapWasEmpty = MESSAGES.getString("mapWasEmpty"),
MSG_mapDidNotHaveTheExpectedSize =
MESSAGES.getString("mapDidNotHaveTheExpectedSize");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -63,6 +67,10 @@ public class FluentMapAssertion<K,V,R> extends
FluentObjectAssertion<Map<K,V>,R>
super(creator, contents, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
@Override /* FluentObjectAssertion */
public FluentMapAssertion<K,V,R> apply(Function<Map<K,V>,Map<K,V>>
function) {
return new FluentMapAssertion<>(this,
function.apply(orElse(null)), returns());
@@ -110,6 +118,10 @@ public class FluentMapAssertion<K,V,R> extends
FluentObjectAssertion<Map<K,V>,R>
return new FluentMapAssertion<>(this, m2, returns());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that the map exists and is empty.
*
@@ -174,17 +186,9 @@ public class FluentMapAssertion<K,V,R> extends
FluentObjectAssertion<Map<K,V>,R>
}
//-----------------------------------------------------------------------------------------------------------------
- // Helper methods.
+ // Fluent setters
//-----------------------------------------------------------------------------------------------------------------
- private V get(K key) {
- return orElse(emptyMap()).get(key);
- }
-
- private int size() {
- return value().size();
- }
-
// <FluentSetters>
@Override /* GENERATED - Assertion */
@@ -218,4 +222,16 @@ public class FluentMapAssertion<K,V,R> extends
FluentObjectAssertion<Map<K,V>,R>
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ private V get(K key) {
+ return orElse(emptyMap()).get(key);
+ }
+
+ private int size() {
+ return value().size();
+ }
}
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 e1b9ccf..6cc0546 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
@@ -38,7 +38,7 @@ import org.apache.juneau.serializer.*;
public class FluentObjectAssertion<T,R> extends FluentAssertion<R> {
private static final Messages MESSAGES =
Messages.of(FluentObjectAssertion.class, "Messages");
- static final String
+ private static final String
MSG_unexpectedType = MESSAGES.getString("unexpectedType"),
MSG_unexpectedComparison =
MESSAGES.getString("unexpectedComparison"),
MSG_unexpectedValue = MESSAGES.getString("unexpectedValue"),
@@ -64,6 +64,10 @@ public class FluentObjectAssertion<T,R> extends
FluentAssertion<R> {
private final T value;
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -86,25 +90,9 @@ public class FluentObjectAssertion<T,R> extends
FluentAssertion<R> {
this.value = value;
}
- /**
- * Asserts that the object is an instance of the specified class.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Validates that the specified object is an instance of
MyBean.</jc>
- * <jsm>assertObject<jsm>(myPojo).isType(MyBean.<jk>class</jk>);
- * </p>
- *
- * @param parent The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isType(Class<?> parent) throws AssertionError {
- assertArgNotNull("parent", parent);
- if (! ClassInfo.of(value()).isChildOf(parent))
- throw error(MSG_unexpectedType, className(parent),
className(value));
- return returns();
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
/**
* Converts this object to text using the specified serializer and
returns it as a new assertion.
@@ -198,526 +186,588 @@ public class FluentObjectAssertion<T,R> extends
FluentAssertion<R> {
}
/**
- * Verifies that two objects are equivalent after converting them both
to JSON.
+ * Converts this object assertion into an array assertion.
*
- * @param o The object to compare against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @param elementType The element type of the array.
+ * @return A new assertion.
+ * @throws AssertionError If object is not an array.
*/
- public R isSameJsonAs(Object o) throws AssertionError {
- return isSameSerializedAs(o, JSON);
+ public <E> FluentArrayAssertion<E,R> asArray(Class<E> elementType)
throws AssertionError {
+ return new FluentArrayAssertion<>(this,
cast(arrayClass(elementType)), returns());
}
/**
- * Verifies that two objects are equivalent after converting them both
to sorted JSON.
- *
- * <p>
- * Properties, maps, and collections are all sorted on both objects
before comparison.
+ * Converts this object assertion into a primitive array assertion.
*
- * @param o The object to compare against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @param arrayType The array type.
+ * @return A new assertion.
+ * @throws AssertionError If object is not an array.
*/
- public R isSameSortedAs(Object o) {
- return isSameSerializedAs(o, JSON_SORTED);
+ public <E> FluentPrimitiveArrayAssertion<E,R> asPrimitiveArray(Class<E>
arrayType) throws AssertionError {
+ return new FluentPrimitiveArrayAssertion<>(this,
cast(arrayType), returns());
}
/**
- * Asserts that the specified object is the same as this object after
converting both to strings using the specified serializer.
+ * Converts this object assertion into a boolean assertion.
*
- * @param o The object to compare against.
- * @param serializer The serializer to use to serialize this object.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a boolean.
*/
- public R isSameSerializedAs(Object o, WriterSerializer serializer) {
- try {
- String s1 = serializer.serialize(value);
- String s2 = serializer.serialize(o);
- if (ne(s1, s2))
- throw error(MSG_unexpectedComparison, s2, s1);
- } catch (SerializeException e) {
- throw runtimeException(e);
- }
- return returns();
+ public FluentBooleanAssertion<R> asBoolean() {
+ return new FluentBooleanAssertion<>(this, cast(Boolean.class),
returns());
}
/**
- * Asserts that the value equals the specified value.
+ * Converts this object assertion into a byte array assertion.
*
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a byte array.
*/
- public R isEqual(Object value) throws AssertionError {
- if (this.value == value)
- return returns();
- if (! value().equals(equivalent(value)))
- throw error(MSG_unexpectedValue, value, this.value);
- return returns();
+ public FluentByteArrayAssertion<R> asByteArray() {
+ return new FluentByteArrayAssertion<>(this, cast(byte[].class),
returns());
}
/**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #isEqual(Object)}.
+ * Converts this object assertion into a primitive short array
assertion.
*
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a primitive short array.
*/
- public R is(Object value) throws AssertionError {
- return isEqual(equivalent(value));
+ public FluentPrimitiveArrayAssertion<short[],R> asShortArray() {
+ return asPrimitiveArray(short[].class);
}
/**
- * Asserts that the value equals the specified value.
+ * Converts this object assertion into a primitive int array assertion.
*
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a primitive int array.
*/
- public R doesNotEqual(Object value) throws AssertionError {
- if (this.value == null && value != null || this.value != null
&& value == null)
- return returns();
- if (this.value == null || this.value.equals(equivalent(value)))
- throw error(MSG_unexpectedValueDidNotExpect, value,
orElse(null));
- return returns();
+ public FluentPrimitiveArrayAssertion<int[],R> asIntArray() {
+ return asPrimitiveArray(int[].class);
}
/**
- * Asserts that the specified object is the same object as this object.
+ * Converts this object assertion into a primitive long array assertion.
*
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a primitive long array.
*/
- public R isSameObjectAs(Object value) throws AssertionError {
- if (this.value == value)
- return returns();
- throw error(MSG_notTheSameValue, value, this.value);
+ public FluentPrimitiveArrayAssertion<long[],R> asLongArray() {
+ return asPrimitiveArray(long[].class);
}
/**
- * Asserts that the value passes the specified predicate test.
+ * Converts this object assertion into a primitive float array
assertion.
*
- * @param test The predicate to use to test the value.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a primitive float array.
*/
- public R passes(Predicate<T> test) throws AssertionError {
- if (test != null && ! test.test(value))
- throw error(getFailureMessage(test, value));
- return returns();
+ public FluentPrimitiveArrayAssertion<float[],R> asFloatArray() {
+ return asPrimitiveArray(float[].class);
}
/**
- * Asserts that the object is not null.
- *
- * <p>
- * Equivalent to {@link #isNotNull()}.
+ * Converts this object assertion into a primitive double array
assertion.
*
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a primitive double array.
*/
- public R exists() throws AssertionError {
- return isNotNull();
+ public FluentPrimitiveArrayAssertion<double[],R> asDoubleArray() {
+ return asPrimitiveArray(double[].class);
}
/**
- * Asserts that the object is null.
- *
- * <p>
- * Equivalent to {@link #isNotNull()}.
+ * Converts this object assertion into a primitive boolean array
assertion.
*
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a primitive boolean array.
*/
- public R doesNotExist() throws AssertionError {
- return isNull();
+ public FluentPrimitiveArrayAssertion<boolean[],R> asBooleanArray() {
+ return asPrimitiveArray(boolean[].class);
}
/**
- * Asserts that the object is not null.
- *
- * <p>
- * Equivalent to {@link #isNotNull()}.
+ * Converts this object assertion into a primitive char array assertion.
*
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a primitive char array.
*/
- public R isNotNull() throws AssertionError {
- if (value == null)
- throw error(MSG_valueWasNull);
- return returns();
+ public FluentPrimitiveArrayAssertion<char[],R> asCharArray() {
+ return asPrimitiveArray(char[].class);
}
/**
- * Asserts that the object i null.
- *
- * <p>
- * Equivalent to {@link #isNotNull()}.
+ * Converts this object assertion into a collection assertion.
*
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a collection.
*/
- public R isNull() throws AssertionError {
- if (value != null)
- throw error(MSG_valueWasNotNull);
- return returns();
+ public FluentCollectionAssertion<Object,R> asCollection() {
+ return asCollection(Object.class);
}
/**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #doesNotEqual(Object)}.
+ * Converts this object assertion into a collection assertion.
*
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @param elementType The element type of the collection.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a collection.
*/
- public R isNot(Object value) throws AssertionError {
- return doesNotEqual(equivalent(value));
+ @SuppressWarnings("unchecked")
+ public <E> FluentCollectionAssertion<E,R> asCollection(Class<E>
elementType) {
+ return new FluentCollectionAssertion<>(this,
cast(Collection.class), returns());
}
/**
- * Asserts that the value is one of the specified values.
+ * Converts this object assertion into a comparable object assertion.
*
- * @param values The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not an instance of {@link
Comparable}.
*/
- public R isAny(Object...values) throws AssertionError {
- for (Object v : values)
- if (value().equals(equivalent(v)))
- return returns();
- throw error(MSG_expectedValueNotFound, values, value);
+ @SuppressWarnings("unchecked")
+ public <T2 extends Comparable<T2>> FluentComparableAssertion<T2,R>
asComparable() {
+ return new FluentComparableAssertion<>(this,
(T2)cast(Comparable.class), returns());
}
/**
- * Asserts that the value is one of the specified values.
+ * Converts this object assertion into a date assertion.
*
- * @param values The values to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a date.
*/
- public R isNotAny(Object...values) throws AssertionError {
- for (Object v : values)
- if (value().equals(equivalent(v)))
- throw error(MSG_unexpectedValueFound, v, value);
- return returns();
+ public FluentDateAssertion<R> asDate() {
+ return new FluentDateAssertion<>(this, cast(Date.class),
returns());
}
/**
- * Subclasses can override this method to provide special conversions
on objects being compared.
+ * Converts this object assertion into an integer assertion.
*
- * @param o The object to cast.
- * @return The cast object.
+ * @return A new assertion.
+ * @throws AssertionError If object is not an integer.
*/
- protected Object equivalent(Object o) {
- return o;
+ public FluentIntegerAssertion<R> asInteger() {
+ return new FluentIntegerAssertion<>(this, cast(Integer.class),
returns());
}
/**
- * Converts this object to a string using {@link Object#toString} and
runs the {@link FluentStringAssertion#is(String)} on the result.
+ * Converts this object assertion into a list assertion.
*
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Validates that the specified object is "foobar" after
converting to a string.</jc>
- * <jsm>assertObject<jsm>(myPojo).is(<js>"foobar"</js>);
- * </p>
- *
- * @param value The expected string value.
- * @return This object (for method chaining).
+ * @return A new assertion.
+ * @throws AssertionError If object is not a list.
*/
- public R isString(String value) {
- return asString().is(value);
+ public FluentListAssertion<Object,R> asList() {
+ return asList(Object.class);
}
/**
- * Converts this object to simplified JSON and runs the {@link
FluentStringAssertion#is(String)} on the result.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Validates that the specified object is an instance of
MyBean.</jc>
- *
<jsm>assertObject<jsm>(myPojo).asJson().is(<js>"{foo:'bar',baz:'qux'}"</js>);
- * </p>
+ * Converts this object assertion into a list assertion.
*
- * @param value The expected string value.
- * @return This object (for method chaining).
+ * @param elementType The element type.
+ * @return A new assertion.
+ * @throws AssertionError If object is not a list.
*/
- public R isJson(String value) {
- return asJson().is(value);
- }
-
@SuppressWarnings("unchecked")
- private <T2> T2 cast(Class<T2> c) throws AssertionError {
- Object o = value;
- if (o == null || c.isInstance(o))
- return (T2)o;
- throw new BasicAssertionError(MSG_objectWasNotType,
ClassInfo.of(c).getFullName(), o.getClass());
+ public <E> FluentListAssertion<E,R> asList(Class<E> elementType) {
+ return new FluentListAssertion<>(this, cast(List.class),
returns());
}
/**
- * Converts this object assertion into an array assertion.
+ * Converts this object assertion into a long assertion.
*
- * @param elementType The element type of the array.
* @return A new assertion.
- * @throws AssertionError If object is not an array.
+ * @throws AssertionError If object is not a long.
*/
- public <E> FluentArrayAssertion<E,R> asArray(Class<E> elementType)
throws AssertionError {
- return new FluentArrayAssertion<>(this,
cast(arrayClass(elementType)), returns());
+ public FluentLongAssertion<R> asLong() {
+ return new FluentLongAssertion<>(this, cast(Long.class),
returns());
}
/**
- * Converts this object assertion into a primitive array assertion.
+ * Converts this object assertion into a map assertion.
*
- * @param arrayType The array type.
* @return A new assertion.
- * @throws AssertionError If object is not an array.
+ * @throws AssertionError If object is not a map.
*/
- public <E> FluentPrimitiveArrayAssertion<E,R> asPrimitiveArray(Class<E>
arrayType) throws AssertionError {
- return new FluentPrimitiveArrayAssertion<>(this,
cast(arrayType), returns());
+ public FluentMapAssertion<String,Object,R> asMap() {
+ return asMap(String.class,Object.class);
}
/**
- * Converts this object assertion into a boolean assertion.
+ * Converts this object assertion into a map assertion with the
specified key and value types.
*
+ * @param keyType The key type.
+ * @param valueType The value type.
* @return A new assertion.
- * @throws AssertionError If object is not a boolean.
+ * @throws AssertionError If object is not a map.
*/
- public FluentBooleanAssertion<R> asBoolean() {
- return new FluentBooleanAssertion<>(this, cast(Boolean.class),
returns());
+ @SuppressWarnings("unchecked")
+ public <K,V> FluentMapAssertion<K,V,R> asMap(Class<K> keyType, Class<V>
valueType) {
+ return new FluentMapAssertion<>(this, cast(Map.class),
returns());
}
/**
- * Converts this object assertion into a byte array assertion.
+ * Converts this object assertion into a bean assertion.
*
+ * @param beanType The bean type.
* @return A new assertion.
- * @throws AssertionError If object is not a byte array.
+ * @throws AssertionError If object is not a bean.
*/
- public FluentByteArrayAssertion<R> asByteArray() {
- return new FluentByteArrayAssertion<>(this, cast(byte[].class),
returns());
+ public <T2> FluentBeanAssertion<T2,R> asBean(Class<T2> beanType) {
+ return new FluentBeanAssertion<>(this, cast(beanType),
returns());
}
/**
- * Converts this object assertion into a primitive short array
assertion.
+ * Converts this object assertion into a list-of-beans assertion.
*
+ * @param beanType The bean type.
* @return A new assertion.
- * @throws AssertionError If object is not a primitive short array.
+ * @throws AssertionError If object is not a bean.
*/
- public FluentPrimitiveArrayAssertion<short[],R> asShortArray() {
- return asPrimitiveArray(short[].class);
+ @SuppressWarnings("unchecked")
+ public <T2> FluentBeanListAssertion<T2,R> asBeanList(Class<T2>
beanType) {
+ return new FluentBeanListAssertion<>(this, cast(List.class),
returns());
}
/**
- * Converts this object assertion into a primitive int array assertion.
+ * Converts this object assertion into a zoned-datetime assertion.
*
* @return A new assertion.
- * @throws AssertionError If object is not a primitive int array.
+ * @throws AssertionError If object is not a zoned-datetime.
*/
- public FluentPrimitiveArrayAssertion<int[],R> asIntArray() {
- return asPrimitiveArray(int[].class);
+ public FluentZonedDateTimeAssertion<R> asZonedDateTime() {
+ return new FluentZonedDateTimeAssertion<>(this,
cast(ZonedDateTime.class), returns());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
- * Converts this object assertion into a primitive long array assertion.
+ * Asserts that the object is an instance of the specified class.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a primitive long array.
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Validates that the specified object is an instance of
MyBean.</jc>
+ * <jsm>assertObject<jsm>(myPojo).isType(MyBean.<jk>class</jk>);
+ * </p>
+ *
+ * @param parent The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentPrimitiveArrayAssertion<long[],R> asLongArray() {
- return asPrimitiveArray(long[].class);
+ public R isType(Class<?> parent) throws AssertionError {
+ assertArgNotNull("parent", parent);
+ if (! ClassInfo.of(value()).isChildOf(parent))
+ throw error(MSG_unexpectedType, className(parent),
className(value));
+ return returns();
}
/**
- * Converts this object assertion into a primitive float array
assertion.
+ * Verifies that two objects are equivalent after converting them both
to JSON.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a primitive float array.
+ * @param o The object to compare against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentPrimitiveArrayAssertion<float[],R> asFloatArray() {
- return asPrimitiveArray(float[].class);
+ public R isSameJsonAs(Object o) throws AssertionError {
+ return isSameSerializedAs(o, JSON);
}
/**
- * Converts this object assertion into a primitive double array
assertion.
+ * Verifies that two objects are equivalent after converting them both
to sorted JSON.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a primitive double array.
+ * <p>
+ * Properties, maps, and collections are all sorted on both objects
before comparison.
+ *
+ * @param o The object to compare against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentPrimitiveArrayAssertion<double[],R> asDoubleArray() {
- return asPrimitiveArray(double[].class);
+ public R isSameSortedAs(Object o) {
+ return isSameSerializedAs(o, JSON_SORTED);
}
/**
- * Converts this object assertion into a primitive boolean array
assertion.
+ * Asserts that the specified object is the same as this object after
converting both to strings using the specified serializer.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a primitive boolean array.
+ * @param o The object to compare against.
+ * @param serializer The serializer to use to serialize this object.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentPrimitiveArrayAssertion<boolean[],R> asBooleanArray() {
- return asPrimitiveArray(boolean[].class);
+ public R isSameSerializedAs(Object o, WriterSerializer serializer) {
+ try {
+ String s1 = serializer.serialize(value);
+ String s2 = serializer.serialize(o);
+ if (ne(s1, s2))
+ throw error(MSG_unexpectedComparison, s2, s1);
+ } catch (SerializeException e) {
+ throw runtimeException(e);
+ }
+ return returns();
}
/**
- * Converts this object assertion into a primitive char array assertion.
+ * Asserts that the value equals the specified value.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a primitive char array.
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentPrimitiveArrayAssertion<char[],R> asCharArray() {
- return asPrimitiveArray(char[].class);
+ public R isEqual(Object value) throws AssertionError {
+ if (this.value == value)
+ return returns();
+ if (! value().equals(equivalent(value)))
+ throw error(MSG_unexpectedValue, value, this.value);
+ return returns();
}
/**
- * Converts this object assertion into a collection assertion.
+ * Asserts that the value equals the specified value.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a collection.
+ * <p>
+ * Equivalent to {@link #isEqual(Object)}.
+ *
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentCollectionAssertion<Object,R> asCollection() {
- return asCollection(Object.class);
+ public R is(Object value) throws AssertionError {
+ return isEqual(equivalent(value));
}
/**
- * Converts this object assertion into a collection assertion.
+ * Asserts that the value equals the specified value.
*
- * @param elementType The element type of the collection.
- * @return A new assertion.
- * @throws AssertionError If object is not a collection.
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- @SuppressWarnings("unchecked")
- public <E> FluentCollectionAssertion<E,R> asCollection(Class<E>
elementType) {
- return new FluentCollectionAssertion<>(this,
cast(Collection.class), returns());
+ public R doesNotEqual(Object value) throws AssertionError {
+ if (this.value == null && value != null || this.value != null
&& value == null)
+ return returns();
+ if (this.value == null || this.value.equals(equivalent(value)))
+ throw error(MSG_unexpectedValueDidNotExpect, value,
orElse(null));
+ return returns();
}
/**
- * Converts this object assertion into a comparable object assertion.
+ * Asserts that the specified object is the same object as this object.
*
- * @return A new assertion.
- * @throws AssertionError If object is not an instance of {@link
Comparable}.
+ * @param value The value to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- @SuppressWarnings("unchecked")
- public <T2 extends Comparable<T2>> FluentComparableAssertion<T2,R>
asComparable() {
- return new FluentComparableAssertion<>(this,
(T2)cast(Comparable.class), returns());
+ public R isSameObjectAs(Object value) throws AssertionError {
+ if (this.value == value)
+ return returns();
+ throw error(MSG_notTheSameValue, value, this.value);
}
/**
- * Converts this object assertion into a date assertion.
+ * Asserts that the value passes the specified predicate test.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a date.
+ * @param test The predicate to use to test the value.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentDateAssertion<R> asDate() {
- return new FluentDateAssertion<>(this, cast(Date.class),
returns());
+ public R passes(Predicate<T> test) throws AssertionError {
+ if (test != null && ! test.test(value))
+ throw error(getFailureMessage(test, value));
+ return returns();
}
/**
- * Converts this object assertion into an integer assertion.
+ * Asserts that the object is not null.
*
- * @return A new assertion.
- * @throws AssertionError If object is not an integer.
+ * <p>
+ * Equivalent to {@link #isNotNull()}.
+ *
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentIntegerAssertion<R> asInteger() {
- return new FluentIntegerAssertion<>(this, cast(Integer.class),
returns());
+ public R exists() throws AssertionError {
+ return isNotNull();
}
/**
- * Converts this object assertion into a list assertion.
+ * Asserts that the object is null.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a list.
+ * <p>
+ * Equivalent to {@link #isNotNull()}.
+ *
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentListAssertion<Object,R> asList() {
- return asList(Object.class);
+ public R doesNotExist() throws AssertionError {
+ return isNull();
}
/**
- * Converts this object assertion into a list assertion.
+ * Asserts that the object is not null.
*
- * @param elementType The element type.
- * @return A new assertion.
- * @throws AssertionError If object is not a list.
+ * <p>
+ * Equivalent to {@link #isNotNull()}.
+ *
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- @SuppressWarnings("unchecked")
- public <E> FluentListAssertion<E,R> asList(Class<E> elementType) {
- return new FluentListAssertion<>(this, cast(List.class),
returns());
+ public R isNotNull() throws AssertionError {
+ if (value == null)
+ throw error(MSG_valueWasNull);
+ return returns();
}
/**
- * Converts this object assertion into a long assertion.
+ * Asserts that the object i null.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a long.
+ * <p>
+ * Equivalent to {@link #isNotNull()}.
+ *
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public FluentLongAssertion<R> asLong() {
- return new FluentLongAssertion<>(this, cast(Long.class),
returns());
+ public R isNull() throws AssertionError {
+ if (value != null)
+ throw error(MSG_valueWasNotNull);
+ return returns();
}
/**
- * Converts this object assertion into a map assertion.
+ * Asserts that the value equals the specified value.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a map.
+ * <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 FluentMapAssertion<String,Object,R> asMap() {
- return asMap(String.class,Object.class);
+ public R isNot(Object value) throws AssertionError {
+ return doesNotEqual(equivalent(value));
}
/**
- * Converts this object assertion into a map assertion with the
specified key and value types.
+ * Asserts that the value is one of the specified values.
*
- * @param keyType The key type.
- * @param valueType The value type.
- * @return A new assertion.
- * @throws AssertionError If object is not a map.
+ * @param values The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- @SuppressWarnings("unchecked")
- public <K,V> FluentMapAssertion<K,V,R> asMap(Class<K> keyType, Class<V>
valueType) {
- return new FluentMapAssertion<>(this, cast(Map.class),
returns());
+ public R isAny(Object...values) throws AssertionError {
+ for (Object v : values)
+ if (value().equals(equivalent(v)))
+ return returns();
+ throw error(MSG_expectedValueNotFound, values, value);
}
/**
- * Converts this object assertion into a bean assertion.
+ * Asserts that the value is one of the specified values.
*
- * @param beanType The bean type.
- * @return A new assertion.
- * @throws AssertionError If object is not a bean.
+ * @param values The values to check against.
+ * @return The response object (for method chaining).
+ * @throws AssertionError If assertion failed.
*/
- public <T2> FluentBeanAssertion<T2,R> asBean(Class<T2> beanType) {
- return new FluentBeanAssertion<>(this, cast(beanType),
returns());
+ public R isNotAny(Object...values) throws AssertionError {
+ for (Object v : values)
+ if (value().equals(equivalent(v)))
+ throw error(MSG_unexpectedValueFound, v, value);
+ return returns();
}
/**
- * Converts this object assertion into a list-of-beans assertion.
+ * Converts this object to a string using {@link Object#toString} and
runs the {@link FluentStringAssertion#is(String)} on the result.
*
- * @param beanType The bean type.
- * @return A new assertion.
- * @throws AssertionError If object is not a bean.
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Validates that the specified object is "foobar" after
converting to a string.</jc>
+ * <jsm>assertObject<jsm>(myPojo).is(<js>"foobar"</js>);
+ * </p>
+ *
+ * @param value The expected string value.
+ * @return This object (for method chaining).
*/
- @SuppressWarnings("unchecked")
- public <T2> FluentBeanListAssertion<T2,R> asBeanList(Class<T2>
beanType) {
- return new FluentBeanListAssertion<>(this, cast(List.class),
returns());
+ public R isString(String value) {
+ return asString().is(value);
}
/**
- * Converts this object assertion into a zoned-datetime assertion.
+ * Converts this object to simplified JSON and runs the {@link
FluentStringAssertion#is(String)} on the result.
*
- * @return A new assertion.
- * @throws AssertionError If object is not a zoned-datetime.
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Validates that the specified object is an instance of
MyBean.</jc>
+ *
<jsm>assertObject<jsm>(myPojo).asJson().is(<js>"{foo:'bar',baz:'qux'}"</js>);
+ * </p>
+ *
+ * @param value The expected string value.
+ * @return This object (for method chaining).
*/
- public FluentZonedDateTimeAssertion<R> asZonedDateTime() {
- return new FluentZonedDateTimeAssertion<>(this,
cast(ZonedDateTime.class), returns());
+ public R isJson(String value) {
+ return asJson().is(value);
}
//-----------------------------------------------------------------------------------------------------------------
- // Helper methods.
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
+ // <FluentSetters>
+
+ @Override /* GENERATED - Assertion */
+ public FluentObjectAssertion<T,R> msg(String msg, Object...args) {
+ super.msg(msg, args);
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentObjectAssertion<T,R> out(PrintStream value) {
+ super.out(value);
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentObjectAssertion<T,R> silent() {
+ super.silent();
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentObjectAssertion<T,R> stdout() {
+ super.stdout();
+ return this;
+ }
+
+ @Override /* GENERATED - Assertion */
+ public FluentObjectAssertion<T,R> throwable(Class<? extends
java.lang.RuntimeException> value) {
+ super.throwable(value);
+ return this;
+ }
+
+ // </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
//-----------------------------------------------------------------------------------------------------------------
/**
+ * Subclasses can override this method to provide special conversions
on objects being compared.
+ *
+ * @param o The object to cast.
+ * @return The cast object.
+ */
+ protected Object equivalent(Object o) {
+ return o;
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T2> T2 cast(Class<T2> c) throws AssertionError {
+ Object o = value;
+ if (o == null || c.isInstance(o))
+ return (T2)o;
+ throw new BasicAssertionError(MSG_objectWasNotType,
ClassInfo.of(c).getFullName(), o.getClass());
+ }
+
+ /**
* Returns the inner value after asserting it is not <jk>null</jk>.
*
* @return The inner value.
@@ -800,38 +850,4 @@ public class FluentObjectAssertion<T,R> extends
FluentAssertion<R> {
public String toString() {
return value == null ? null : value.toString();
}
-
- // <FluentSetters>
-
- @Override /* GENERATED - Assertion */
- public FluentObjectAssertion<T,R> msg(String msg, Object...args) {
- super.msg(msg, args);
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public FluentObjectAssertion<T,R> out(PrintStream value) {
- super.out(value);
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public FluentObjectAssertion<T,R> silent() {
- super.silent();
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public FluentObjectAssertion<T,R> stdout() {
- super.stdout();
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public FluentObjectAssertion<T,R> throwable(Class<? extends
java.lang.RuntimeException> value) {
- super.throwable(value);
- return this;
- }
-
- // </FluentSetters>
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentPrimitiveArrayAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentPrimitiveArrayAssertion.java
index b3a8503..b2708c1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentPrimitiveArrayAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentPrimitiveArrayAssertion.java
@@ -55,6 +55,10 @@ public class FluentPrimitiveArrayAssertion<T,R> extends
FluentObjectAssertion<T,
MSG_arrayDidNotContainExpectedValueAt =
MESSAGES.getString("arrayDidNotContainExpectedValueAt"),
MSG_arrayContainedUnexpectedValue =
MESSAGES.getString("arrayContainedUnexpectedValue");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -78,11 +82,38 @@ public class FluentPrimitiveArrayAssertion<T,R> extends
FluentObjectAssertion<T,
throw new BasicAssertionError(MSG_objectWasNotAnArray,
contents.getClass());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
@Override /* FluentObjectAssertion */
public FluentPrimitiveArrayAssertion<T,R> apply(Function<T,T> function)
{
return new FluentPrimitiveArrayAssertion<>(this,
function.apply(orElse(null)), returns());
}
+ @Override /* FluentBaseAssertion */
+ public FluentStringAssertion<R> asString() {
+ return new FluentStringAssertion<>(this, toString(), 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<T,R> item(int index) {
+ return new FluentObjectAssertion<>(this, at(index), returns());
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that at least one value in the array passes the specified
test.
*
@@ -111,11 +142,6 @@ public class FluentPrimitiveArrayAssertion<T,R> extends
FluentObjectAssertion<T,
return returns();
}
- @Override /* FluentBaseAssertion */
- public FluentStringAssertion<R> asString() {
- return new FluentStringAssertion<>(this, toString(), returns());
- }
-
/**
* Asserts that the collection exists and is empty.
*
@@ -253,40 +279,10 @@ public class FluentPrimitiveArrayAssertion<T,R> extends
FluentObjectAssertion<T,
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<T,R> item(int index) {
- return new FluentObjectAssertion<>(this, at(index), returns());
- }
-
//-----------------------------------------------------------------------------------------------------------------
- // Helper methods.
+ // Fluent setters
//-----------------------------------------------------------------------------------------------------------------
- @SuppressWarnings("unchecked")
- private T at(int index) {
- return valueIsNull() || index >= length() ? null :
(T)Array.get(value(), index);
- }
-
- private int length() {
- return Array.getLength(value());
- }
-
- @Override
- public String toString() {
- if (valueIsNull())
- return null;
- return
STRINGIFIERS.getOrDefault(value().getClass().getComponentType(), (x) ->
x.toString()).apply(value());
- }
-
// <FluentSetters>
@Override /* GENERATED - Assertion */
@@ -320,4 +316,24 @@ public class FluentPrimitiveArrayAssertion<T,R> extends
FluentObjectAssertion<T,
}
// </FluentSetters>
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ @SuppressWarnings("unchecked")
+ private T at(int index) {
+ return valueIsNull() || index >= length() ? null :
(T)Array.get(value(), index);
+ }
+
+ private int length() {
+ return Array.getLength(value());
+ }
+
+ @Override
+ public String toString() {
+ if (valueIsNull())
+ return null;
+ return
STRINGIFIERS.getOrDefault(value().getClass().getComponentType(), (x) ->
x.toString()).apply(value());
+ }
}
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 779be69..a4f2c0d 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
@@ -43,7 +43,7 @@ import org.apache.juneau.internal.*;
public class FluentStringAssertion<R> extends FluentObjectAssertion<String,R> {
private static final Messages MESSAGES =
Messages.of(FluentStringAssertion.class, "Messages");
- static final String
+ private static final String
MSG_stringDifferedAtPosition =
MESSAGES.getString("stringDifferedAtPosition"),
MSG_expectedStringHadDifferentNumbersOfLines =
MESSAGES.getString("expectedStringHadDifferentNumbersOfLines"),
MSG_expectedStringHadDifferentValuesAtLine =
MESSAGES.getString("expectedStringHadDifferentValuesAtLine"),
@@ -61,6 +61,10 @@ public class FluentStringAssertion<R> extends
FluentObjectAssertion<String,R> {
private boolean javaStrings;
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -82,10 +86,9 @@ public class FluentStringAssertion<R> extends
FluentObjectAssertion<String,R> {
super(creator, text, returns);
}
- @Override /* FluentObjectAssertion */
- public FluentStringAssertion<R> apply(Function<String,String> function)
{
- return new FluentStringAssertion<>(this,
function.apply(orElse(null)), returns());
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Config methods
+
//-----------------------------------------------------------------------------------------------------------------
/**
* When enabled, text in the message is converted to valid Java strings.
@@ -102,6 +105,15 @@ public class FluentStringAssertion<R> extends
FluentObjectAssertion<String,R> {
return this;
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ @Override /* FluentObjectAssertion */
+ public FluentStringAssertion<R> apply(Function<String,String> function)
{
+ return new FluentStringAssertion<>(this,
function.apply(orElse(null)), returns());
+ }
+
/**
* Performs the specified regular expression replacement on the
underlying string.
*
@@ -164,6 +176,10 @@ public class FluentStringAssertion<R> extends
FluentObjectAssertion<String,R> {
return apply(x->x == null ? null : x.toUpperCase());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that the text equals the specified value.
*
@@ -536,15 +552,9 @@ public class FluentStringAssertion<R> extends
FluentObjectAssertion<String,R> {
return returns();
}
-
//------------------------------------------------------------------------------------------------------------------
- // Utility methods
-
//------------------------------------------------------------------------------------------------------------------
-
- private String fix(String text) {
- if (javaStrings)
- text = text.replaceAll("\\\\",
"\\\\\\\\").replaceAll("\n", "\\\\n").replaceAll("\t", "\\\\t");
- return text;
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
// <FluentSetters>
@@ -579,4 +589,14 @@ public class FluentStringAssertion<R> extends
FluentObjectAssertion<String,R> {
}
// </FluentSetters>
+
+
//------------------------------------------------------------------------------------------------------------------
+ // Utility methods
+
//------------------------------------------------------------------------------------------------------------------
+
+ private String fix(String text) {
+ if (javaStrings)
+ text = text.replaceAll("\\\\",
"\\\\\\\\").replaceAll("\n", "\\\\n").replaceAll("\t", "\\\\t");
+ return text;
+ }
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentThrowableAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentThrowableAssertion.java
index 55dcef2..619101f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentThrowableAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentThrowableAssertion.java
@@ -32,13 +32,16 @@ import org.apache.juneau.internal.*;
public class FluentThrowableAssertion<T extends Throwable,R> extends
FluentObjectAssertion<T,R> {
private static final Messages MESSAGES =
Messages.of(FluentThrowableAssertion.class, "Messages");
- static final String
+ private static final String
MSG_exceptionWasNotExpectedType =
MESSAGES.getString("exceptionWasNotExpectedType"),
- MSG_exceptionMessageDidNotContainExpectedSubstring =
MESSAGES.getString("exceptionMessageDidNotContainExpectedSubstring"),
MSG_exceptionWasNotThrown =
MESSAGES.getString("exceptionWasNotThrown"),
MSG_exceptionWasThrown =
MESSAGES.getString("exceptionWasThrown"),
MSG_causedByExceptionNotExpectedType =
MESSAGES.getString("causedByExceptionNotExpectedType");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -60,89 +63,16 @@ public class FluentThrowableAssertion<T extends
Throwable,R> extends FluentObjec
super(creator, value, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
@Override /* FluentObjectAssertion */
public FluentThrowableAssertion<T,R> apply(Function<T,T> function) {
return new FluentThrowableAssertion<>(this,
function.apply(orElse(null)), returns());
}
/**
- * Asserts that this throwable is of the specified type.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Asserts that the specified method throws a
RuntimeException. </jc>
- * ThrowableAssertion.<jsm>assertThrown</jsm>(() ->
{<jv>foo</jv>.getBar();})
- * .isType(RuntimeException.<jk>class</jk>);
- * </p>
- *
- * @param type The type.
- * @return This object (for method chaining).
- */
- @Override
- public R isType(Class<?> type) {
- assertArgNotNull("type", type);
- if (! type.isInstance(value()))
- throw error(MSG_exceptionWasNotExpectedType,
className(type), className(value()));
- return returns();
- }
-
- /**
- * Asserts that this throwable is exactly the specified type.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Asserts that the specified method throws a
RuntimeException. </jc>
- * ThrowableAssertion.<jsm>assertThrown</jsm>(() ->
{<jv>foo</jv>.getBar();})
- * .isExactType(RuntimeException.<jk>class</jk>);
- * </p>
- *
- * @param type The type.
- * @return This object (for method chaining).
- */
- public R isExactType(Class<?> type) {
- assertArgNotNull("type", type);
- if (type != value().getClass())
- throw error(MSG_exceptionWasNotExpectedType,
className(type), className(value()));
- return returns();
- }
-
- /**
- * Asserts that this throwable exists.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Asserts that the specified method throws any
exception.</jc>
- * ThrowableAssertion.<jsm>assertThrown</jsm>(() ->
{<jv>foo</jv>.getBar();}).exists();
- * </p>
- *
- * @return This object (for method chaining).
- */
- @Override
- public R exists() {
- if (valueIsNull())
- throw error(MSG_exceptionWasNotThrown);
- return returns();
- }
-
- /**
- * Asserts that this throwable doesn't exist.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Asserts that the specified method doesn't throw any
exception.</jc>
- * ThrowableAssertion.<jsm>assertThrown</jsm>(() ->
{<jv>foo</jv>.getBar();}).notExists();
- * </p>
- *
- * @return This object (for method chaining).
- */
- @Override
- public R doesNotExist() {
- if (valueIsNotNull())
- throw error(MSG_exceptionWasThrown);
- return returns();
- }
-
- /**
* Returns an assertion against the throwable message.
*
* <h5 class='section'>Example:</h5>
@@ -301,6 +231,91 @@ public class FluentThrowableAssertion<T extends
Throwable,R> extends FluentObjec
return new FluentThrowableAssertion<>(this, (E)null, returns());
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Asserts that this throwable is of the specified type.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Asserts that the specified method throws a
RuntimeException. </jc>
+ * ThrowableAssertion.<jsm>assertThrown</jsm>(() ->
{<jv>foo</jv>.getBar();})
+ * .isType(RuntimeException.<jk>class</jk>);
+ * </p>
+ *
+ * @param type The type.
+ * @return This object (for method chaining).
+ */
+ @Override
+ public R isType(Class<?> type) {
+ assertArgNotNull("type", type);
+ if (! type.isInstance(value()))
+ throw error(MSG_exceptionWasNotExpectedType,
className(type), className(value()));
+ return returns();
+ }
+
+ /**
+ * Asserts that this throwable is exactly the specified type.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Asserts that the specified method throws a
RuntimeException. </jc>
+ * ThrowableAssertion.<jsm>assertThrown</jsm>(() ->
{<jv>foo</jv>.getBar();})
+ * .isExactType(RuntimeException.<jk>class</jk>);
+ * </p>
+ *
+ * @param type The type.
+ * @return This object (for method chaining).
+ */
+ public R isExactType(Class<?> type) {
+ assertArgNotNull("type", type);
+ if (type != value().getClass())
+ throw error(MSG_exceptionWasNotExpectedType,
className(type), className(value()));
+ return returns();
+ }
+
+ /**
+ * Asserts that this throwable exists.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Asserts that the specified method throws any
exception.</jc>
+ * ThrowableAssertion.<jsm>assertThrown</jsm>(() ->
{<jv>foo</jv>.getBar();}).exists();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ @Override
+ public R exists() {
+ if (valueIsNull())
+ throw error(MSG_exceptionWasNotThrown);
+ return returns();
+ }
+
+ /**
+ * Asserts that this throwable doesn't exist.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Asserts that the specified method doesn't throw any
exception.</jc>
+ * ThrowableAssertion.<jsm>assertThrown</jsm>(() ->
{<jv>foo</jv>.getBar();}).notExists();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ @Override
+ public R doesNotExist() {
+ if (valueIsNotNull())
+ throw error(MSG_exceptionWasThrown);
+ return returns();
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentVersionAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentVersionAssertion.java
index 57d6dde..e5331af 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentVersionAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentVersionAssertion.java
@@ -34,6 +34,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="FluentVersionAssertion<R>")
public class FluentVersionAssertion<R> extends
FluentComparableAssertion<Version,R> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -55,6 +59,10 @@ public class FluentVersionAssertion<R> extends
FluentComparableAssertion<Version
super(creator, value, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Transform methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Extracts the specified version part (zero-indexed position).
*
@@ -92,6 +100,10 @@ public class FluentVersionAssertion<R> extends
FluentComparableAssertion<Version
return part(2);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentZonedDateTimeAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentZonedDateTimeAssertion.java
index 67597c4..8ba6a73 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentZonedDateTimeAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentZonedDateTimeAssertion.java
@@ -40,11 +40,15 @@ import org.apache.juneau.internal.*;
public class FluentZonedDateTimeAssertion<R> extends
FluentComparableAssertion<ZonedDateTime,R> {
private static final Messages MESSAGES =
Messages.of(FluentZonedDateTimeAssertion.class, "Messages");
- static final String
+ private static final String
MSG_unexpectedValue = MESSAGES.getString("unexpectedValue"),
MSG_valueWasNotAfterExpected =
MESSAGES.getString("valueWasNotAfterExpected"),
MSG_valueWasNotBeforeExpected =
MESSAGES.getString("valueWasNotBeforeExpected");
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
@@ -66,6 +70,10 @@ public class FluentZonedDateTimeAssertion<R> extends
FluentComparableAssertion<Z
super(creator, value, returns);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Asserts that the value equals the specified value at the specified
precision.
*
@@ -146,6 +154,10 @@ public class FluentZonedDateTimeAssertion<R> extends
FluentComparableAssertion<Z
return returns();
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 c5c753b..928df60 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
@@ -28,6 +28,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="IntegerAssertion")
public class IntegerAssertion extends FluentIntegerAssertion<IntegerAssertion>
{
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -47,6 +51,10 @@ public class IntegerAssertion extends
FluentIntegerAssertion<IntegerAssertion> {
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ListAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ListAssertion.java
index 6e1bca0..060cec5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ListAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ListAssertion.java
@@ -31,6 +31,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="ListAssertion<E>")
public class ListAssertion<E> extends FluentListAssertion<E,ListAssertion<E>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -50,6 +54,10 @@ public class ListAssertion<E> extends
FluentListAssertion<E,ListAssertion<E>> {
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 aad13dd..1155819 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
@@ -28,6 +28,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="LongAssertion")
public class LongAssertion extends FluentLongAssertion<LongAssertion> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -47,6 +51,10 @@ public class LongAssertion extends
FluentLongAssertion<LongAssertion> {
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/MapAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/MapAssertion.java
index b554eed..3f9055c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/MapAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/MapAssertion.java
@@ -32,6 +32,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="MapAssertion<K,V>")
public class MapAssertion<K,V> extends
FluentMapAssertion<K,V,MapAssertion<K,V>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -51,6 +55,10 @@ public class MapAssertion<K,V> extends
FluentMapAssertion<K,V,MapAssertion<K,V>>
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 4d4ae0f..765bab4 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
@@ -30,6 +30,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="ObjectAssertion<T>")
public class ObjectAssertion<T> extends
FluentObjectAssertion<T,ObjectAssertion<T>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -49,6 +53,10 @@ public class ObjectAssertion<T> extends
FluentObjectAssertion<T,ObjectAssertion<
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/PrimitiveArrayAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/PrimitiveArrayAssertion.java
index 1dd8f2c..3fa96df 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/PrimitiveArrayAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/PrimitiveArrayAssertion.java
@@ -32,6 +32,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="PrimitiveArrayAssertion<T>")
public class PrimitiveArrayAssertion<T> extends
FluentPrimitiveArrayAssertion<T,PrimitiveArrayAssertion<T>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -53,6 +57,10 @@ public class PrimitiveArrayAssertion<T> extends
FluentPrimitiveArrayAssertion<T,
assertArg(c == null || c.isArray() &&
c.getComponentType().isPrimitive(), "Value wasn't a primitive array.");
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 3a4d246..50b32c4 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
@@ -30,6 +30,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="StringAssertion")
public class StringAssertion extends FluentStringAssertion<StringAssertion> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -49,6 +53,10 @@ public class StringAssertion extends
FluentStringAssertion<StringAssertion> {
super(stringify(text), null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
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 9c9891e..5395ace 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
@@ -30,6 +30,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="ThrowableAssertion<T>")
public class ThrowableAssertion<T extends Throwable> extends
FluentThrowableAssertion<T,ThrowableAssertion<T>> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -49,6 +53,10 @@ public class ThrowableAssertion<T extends Throwable> extends
FluentThrowableAsse
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Verify.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Verify.java
index aa50a08..20cdac4 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Verify.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Verify.java
@@ -42,6 +42,10 @@ public class Verify {
private final Object o;
private Supplier<String> msg;
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Create a new verifier object.
*
@@ -61,6 +65,10 @@ public class Verify {
this.o = o;
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Config setters
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Overrides the default error message produced by the verification.
*
@@ -73,6 +81,10 @@ public class Verify {
return this;
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Test methods
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Verifies that this object is of the specified type.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/VersionAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/VersionAssertion.java
index 9896e5f..ed62942 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/VersionAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/VersionAssertion.java
@@ -29,6 +29,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="VersionAssertion")
public class VersionAssertion extends FluentVersionAssertion<VersionAssertion>
{
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -48,6 +52,10 @@ public class VersionAssertion extends
FluentVersionAssertion<VersionAssertion> {
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ZonedDateTimeAssertion.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ZonedDateTimeAssertion.java
index c069274..152e42d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ZonedDateTimeAssertion.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/ZonedDateTimeAssertion.java
@@ -29,6 +29,10 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="ZonedDateTimeAssertion")
public class ZonedDateTimeAssertion extends
FluentZonedDateTimeAssertion<ZonedDateTimeAssertion> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Constructors
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Creator.
*
@@ -48,6 +52,10 @@ public class ZonedDateTimeAssertion extends
FluentZonedDateTimeAssertion<ZonedDa
super(value, null);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Fluent setters
+
//-----------------------------------------------------------------------------------------------------------------
+
// <FluentSetters>
@Override /* GENERATED - Assertion */
diff --git
a/juneau-core/juneau-marshall/src/main/resources/org/apache/juneau/assertions/Messages.properties
b/juneau-core/juneau-marshall/src/main/resources/org/apache/juneau/assertions/Messages.properties
index 0ed672b..16595c5 100644
---
a/juneau-core/juneau-marshall/src/main/resources/org/apache/juneau/assertions/Messages.properties
+++
b/juneau-core/juneau-marshall/src/main/resources/org/apache/juneau/assertions/Messages.properties
@@ -100,7 +100,6 @@ FluentStringAssertion.stringDidNotStartWithExpected =
String did not start with
FluentStringAssertion.stringDidNotEndWithExpected = String did not end with
expected substring.\n\tSubstring=''{0}''.\n\tValue=''{1}''.
FluentThrowableAssertion.exceptionWasNotExpectedType = Exception was not
expected type.\n\tExpect=''{0}''.\n\tActual=''{1}''.
-FluentThrowableAssertion.exceptionMessageDidNotContainExpectedSubstring =
Exception message did not contain expected
substring.\n\tSubstring=''{0}''.\n\tValue=''{1}''.
FluentThrowableAssertion.exceptionWasNotThrown = Exception was not thrown.
FluentThrowableAssertion.exceptionWasThrown = Exception was thrown.
FluentThrowableAssertion.causedByExceptionNotExpectedType = Caused-by
exception not of expected type.\n\tExpected=''{0}''.\n\tActual=''{1}''.