You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2020/07/09 20:06:03 UTC
[juneau] branch master updated: Assertions tests.
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 777a806 Assertions tests.
777a806 is described below
commit 777a80674cbbf00326a8f913ed9b90b7caf0b119
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Thu Jul 9 16:05:56 2020 -0400
Assertions tests.
---
.../java/org/apache/juneau/ComboRoundTripTest.java | 4 +-
.../java/org/apache/juneau/ComboSerializeTest.java | 2 +-
.../juneau/a/rttests/RoundTripBeanMapsTest.java | 2 +-
.../juneau/assertions/ArrayAssertion_Test.java | 69 ++++++++++++++
.../apache/juneau/assertions/Assertions_Test.java} | 93 +++++++-----------
.../juneau/assertions/ByteArrayAssertion_Test.java | 77 +++++++++++++++
.../assertions/CollectionAssertion_Test.java | 57 +++++++++++
.../assertions/ComparableAssertion_Test.java} | 69 +++-----------
.../juneau/assertions/DateAssertion_Test.java | 77 +++++++++++++++
.../assertions/FluentIntegerAssertion_Test.java | 101 ++++++++++++++++++++
.../assertions/FluentLongAssertion_Test.java | 104 +++++++++++++++++++++
.../juneau/assertions/ListAssertion_Test.java | 70 ++++++++++++++
.../juneau/assertions/ObjectAssertion_Test.java | 67 +++++++++++++
.../apache/juneau/config/ConfigInterfaceTest.java | 18 ++--
.../juneau/serializer/UriResolutionTest.java | 2 +-
.../org/apache/juneau/assertions/Assertion.java | 25 ++++-
.../org/apache/juneau/assertions/Assertions.java | 24 ++++-
.../juneau/assertions/FluentArrayAssertion.java | 11 +--
.../assertions/FluentByteArrayAssertion.java | 5 +-
.../assertions/FluentCollectionAssertion.java | 2 +-
.../assertions/FluentComparableAssertion.java | 44 ++++++---
.../juneau/assertions/FluentDateAssertion.java | 22 +++--
.../juneau/assertions/FluentIntegerAssertion.java | 10 +-
.../juneau/assertions/FluentLongAssertion.java | 19 +++-
.../juneau/assertions/FluentObjectAssertion.java | 61 ++----------
.../juneau/assertions/FluentStringAssertion.java | 20 ++--
.../assertions/FluentThrowableAssertion.java | 2 +-
.../juneau/serializer/SerializerSession.java | 2 +-
.../rest/test/client/ThirdPartyProxyResource.java | 64 ++++++-------
.../rest/test/client/ThirdPartyProxyTest.java | 16 ++--
.../rest/client2/RestClient_Response_Test.java | 2 +-
.../juneau/rest/client2/RrpcInterfaceTest.java | 32 +++----
32 files changed, 874 insertions(+), 299 deletions(-)
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboRoundTripTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboRoundTripTest.java
index 478f575..af1eb88 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboRoundTripTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboRoundTripTest.java
@@ -116,7 +116,7 @@ public abstract class ComboRoundTripTest {
if (isRdf) {
Object[] args = { comboInput.label, testName };
- assertString(r).msg("{0}/{1} parse-normal failed", args).equalsAfterSort(expected);
+ assertString(r).msg("{0}/{1} parse-normal failed", args).isEqualAfterSort(expected);
} else
assertString(r).msg("{0}/{1} parse-normal failed", comboInput.label, testName).is(expected);
@@ -160,7 +160,7 @@ public abstract class ComboRoundTripTest {
if (isRdf) {
Object[] args = { comboInput.label, testName };
- assertString(r).msg("{0}/{1} parse-normal failed", args).equalsAfterSort(expected);
+ assertString(r).msg("{0}/{1} parse-normal failed", args).isEqualAfterSort(expected);
} else
assertString(r).msg("{0}/{1} parse-normal failed", comboInput.label, testName).is(expected);
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboSerializeTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboSerializeTest.java
index 212f19c..fefc6e7 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboSerializeTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/ComboSerializeTest.java
@@ -96,7 +96,7 @@ public abstract class ComboSerializeTest {
if (isRdf) {
Object[] args = { comboInput.label, testName };
- assertString(r).msg("{0}/{1} serialize-normal failed", args).equalsAfterSort(expected);
+ assertString(r).msg("{0}/{1} serialize-normal failed", args).isEqualAfterSort(expected);
} else
assertString(r).msg("{0}/{1} parse-normal failed", comboInput.label, testName).is(expected);
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripBeanMapsTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripBeanMapsTest.java
index 30791ec..a648463 100755
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripBeanMapsTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/a/rttests/RoundTripBeanMapsTest.java
@@ -379,7 +379,7 @@ public class RoundTripBeanMapsTest extends RoundTripTest {
Object r = s.serialize(ba1);
BA b = p.parse(r, BA.class);
assertTrue(b instanceof BA1);
- assertObject(b).json().is("{_type:'BA1',f0a:'f0a',f0b:'f0b',f1:'f1'}");
+ assertObject(b).json().is("{f0a:'f0a',f0b:'f0b',f1:'f1'}");
}
@Bean(dictionary={BA1.class,BA2.class})
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ArrayAssertion_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ArrayAssertion_Test.java
new file mode 100644
index 0000000..9d00e3a
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ArrayAssertion_Test.java
@@ -0,0 +1,69 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.util.*;
+
+import org.apache.juneau.collections.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class ArrayAssertion_Test {
+
+ @Test
+ public void a01_basic() throws Exception {
+ String[] x1={}, x2={"foo"};
+
+ assertThrown(()->assertArray(null).exists()).is("Value was null.");
+ assertArray(x1).exists();
+
+ assertArray(null).doesNotExist();
+ assertThrown(()->assertArray(x1).doesNotExist()).is("Value was not null.");
+
+ assertThrown(()->assertArray(null).isSize(0)).is("Value was null.");
+ assertArray(x1).isSize(0);
+ assertThrown(()->assertArray(x1).isSize(1)).is("Array did not have the expected size. Expected=1, Actual=0.");
+ assertArray(x2).isSize(1);
+ assertThrown(()->assertArray(x2).isSize(0)).is("Array did not have the expected size. Expected=0, Actual=1.");
+
+ assertThrown(()->assertArray(null).isEmpty()).is("Value was null.");
+ assertArray(x1).isEmpty();
+ assertThrown(()->assertArray(x2).isEmpty()).is("Array was not empty.");
+
+ assertThrown(()->assertArray(null).isNotEmpty()).is("Value was null.");
+ assertThrown(()->assertArray(x1).isNotEmpty()).is("Array was empty.");
+ assertArray(x2).isNotEmpty();
+
+ assertArray(null).item(0).doesNotExist();
+ assertArray(x1).item(0).doesNotExist();
+ assertArray(x2).item(0).exists();
+
+ assertArray(new String[]{"foo"}).stringItem(0).is("foo");
+ assertArray(new Date[]{new Date(0)}).dateItem(0).isBeforeNow();
+ assertArray(new Integer[]{1}).integerItem(0).is(1);
+ assertArray(new Long[]{1l}).longItem(0).is(1l);
+ assertArray(new List[]{AList.of("foo")}).listItem(0).stringItem(0).is("foo");
+ assertArray(new List[]{AList.of("foo")}).collectionItem(0).isSize(1);
+
+ assertThrown(()->assertArray(new Integer[]{1}).listItem(0)).is("Object was not expected type. Expected=java.util.List, Actual=java.lang.Integer.");
+ }
+
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->ArrayAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ ArrayAssertion.create(null).stdout().stderr();
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/Assertions_Test.java
similarity index 52%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
copy to juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/Assertions_Test.java
index 643ff83..165760b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/Assertions_Test.java
@@ -12,66 +12,39 @@
// ***************************************************************************************************************************
package org.apache.juneau.assertions;
-
-import org.apache.juneau.internal.*;
-
-/**
- * Used for fluent assertion calls against longs.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Validates the response length isn't too long.</jc>
- * <jv>client</jv>
- * .get(<jsf>URL</jsf>)
- * .run()
- * .assertLongHeader(<js>"Length"</js>).isLessThan(100000);
- * </p>
- *
- * @param <R> The return type.
- */
-@FluentSetters(returns="FluentLongAssertion<R>")
-public class FluentLongAssertion<R> extends FluentComparableAssertion<R> {
-
- /**
- * Constructor.
- *
- * @param value The value being tested.
- * @param returns The object to return after the test.
- */
- public FluentLongAssertion(Long value, R returns) {
- super(value, returns);
- }
-
- /**
- * Constructor.
- *
- * @param creator The assertion that created this assertion.
- * @param value The value being tested.
- * @param returns The object to return after the test.
- */
- public FluentLongAssertion(Assertion creator, Long value, R returns) {
- super(creator, value, returns);
- }
-
- // <FluentSetters>
-
- @Override /* GENERATED - Assertion */
- public FluentLongAssertion<R> msg(String msg, Object...args) {
- super.msg(msg, args);
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public FluentLongAssertion<R> stderr() {
- super.stderr();
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public FluentLongAssertion<R> stdout() {
- super.stdout();
- return this;
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.juneau.collections.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class Assertions_Test {
+
+ @Test
+ public void a01_basic() throws Exception {
+ assertDate(new Date()).isAfter(new Date(0));
+ assertInteger(2).isGt(1);
+ assertLong(2l).isGt(1l);
+ assertObject("foo").json().is("'foo'");
+ assertString("foo").is("foo");
+ assertThrowable(null).doesNotExist();
+ assertArray(new String[0]).isEmpty();
+ assertCollection(AList.of()).isEmpty();
+ assertList(AList.of()).isEmpty();
+ assertStream(new ByteArrayInputStream("foo".getBytes())).string().is("foo");
+ assertStream(null).string().doesNotExist();
+ assertBytes("foo".getBytes()).string().is("foo");
+ assertBytes(null).string().doesNotExist();
+ assertReader(new StringReader("foo")).is("foo");
+ assertReader(null).doesNotExist();
+ assertThrown(()->{throw new RuntimeException("foo");}).is("foo");
+ assertThrown(()->{}).doesNotExist();
+
+ new Assertions();
}
- // </FluentSetters>
}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ByteArrayAssertion_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ByteArrayAssertion_Test.java
new file mode 100644
index 0000000..c2fa11b
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ByteArrayAssertion_Test.java
@@ -0,0 +1,77 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class ByteArrayAssertion_Test {
+
+ @Test
+ public void a01_basic() throws Exception {
+ byte[] x1={}, x2={'a','b'};
+
+ assertThrown(()->assertBytes(null).exists()).is("Value was null.");
+ assertBytes(x1).exists();
+
+ assertBytes(null).doesNotExist();
+ assertThrown(()->assertBytes(x1).doesNotExist()).is("Value was not null.");
+
+ assertThrown(()->assertBytes(null).isSize(0)).is("Value was null.");
+ assertBytes(x1).isSize(0);
+ assertThrown(()->assertBytes(x1).isSize(1)).is("Array did not have the expected size. Expected=1, Actual=0.");
+ assertBytes(x2).isSize(2);
+ assertThrown(()->assertBytes(x2).isSize(0)).is("Array did not have the expected size. Expected=0, Actual=2.");
+
+ assertThrown(()->assertBytes(null).isEmpty()).is("Value was null.");
+ assertBytes(x1).isEmpty();
+ assertThrown(()->assertBytes(x2).isEmpty()).is("Array was not empty.");
+
+ assertThrown(()->assertBytes(null).isNotEmpty()).is("Value was null.");
+ assertThrown(()->assertBytes(x1).isNotEmpty()).is("Array was empty.");
+ assertBytes(x2).isNotEmpty();
+
+ assertBytes(null).item(0).doesNotExist();
+ assertBytes(x1).item(0).doesNotExist();
+ assertBytes(x2).item(0).exists();
+
+ assertBytes(null).string().isNull();
+ assertBytes(x1).string().is("");
+ assertBytes(x2).string().is("ab");
+ assertThrown(()->assertBytes(x2).string().is("xx")).is("Unexpected value.\n\tExpected=[xx]\n\tActual=[ab]");
+
+ assertBytes(null).base64().isNull();
+ assertBytes(x1).base64().is("");
+ assertBytes(x2).base64().is("YWI=");
+ assertThrown(()->assertBytes(x2).base64().is("xx")).is("Unexpected value.\n\tExpected=[xx]\n\tActual=[YWI=]");
+
+ assertBytes(null).hex().isNull();
+ assertBytes(x1).hex().is("");
+ assertBytes(x2).hex().is("6162");
+ assertThrown(()->assertBytes(x2).hex().is("xx")).is("Unexpected value.\n\tExpected=[xx]\n\tActual=[6162]");
+
+ assertBytes(null).spacedHex().isNull();
+ assertBytes(x1).spacedHex().is("");
+ assertBytes(x2).spacedHex().is("61 62");
+ assertThrown(()->assertBytes(x2).spacedHex().is("xx")).is("Unexpected value.\n\tExpected=[xx]\n\tActual=[61 62]");
+ }
+
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->ByteArrayAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ ByteArrayAssertion.create(null).stdout().stderr();
+ }
+}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/CollectionAssertion_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/CollectionAssertion_Test.java
new file mode 100644
index 0000000..431ff6e
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/CollectionAssertion_Test.java
@@ -0,0 +1,57 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.util.*;
+
+import org.apache.juneau.collections.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class CollectionAssertion_Test {
+
+ @Test
+ public void a01_basic() throws Exception {
+ List<String> x1 = AList.of(), x2 = AList.of("a","b");
+
+ assertThrown(()->assertCollection(null).exists()).is("Value was null.");
+ assertCollection(x1).exists();
+
+ assertCollection(null).doesNotExist();
+ assertThrown(()->assertCollection(x1).doesNotExist()).is("Value was not null.");
+
+ assertThrown(()->assertCollection(null).isSize(0)).is("Value was null.");
+ assertCollection(x1).isSize(0);
+ assertThrown(()->assertCollection(x1).isSize(1)).is("Collection did not have the expected size. Expected=1, Actual=0.");
+ assertCollection(x2).isSize(2);
+ assertThrown(()->assertCollection(x2).isSize(0)).is("Collection did not have the expected size. Expected=0, Actual=2.");
+
+ assertThrown(()->assertCollection(null).isEmpty()).is("Value was null.");
+ assertCollection(x1).isEmpty();
+ assertThrown(()->assertCollection(x2).isEmpty()).is("Collection was not empty.");
+
+ assertThrown(()->assertCollection(null).isNotEmpty()).is("Value was null.");
+ assertThrown(()->assertCollection(x1).isNotEmpty()).is("Collection was empty.");
+ assertCollection(x2).isNotEmpty();
+
+ }
+
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->CollectionAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ CollectionAssertion.create(null).stdout().stderr();
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ComparableAssertion_Test.java
similarity index 52%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
copy to juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ComparableAssertion_Test.java
index 643ff83..a6fb5f3 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ComparableAssertion_Test.java
@@ -12,66 +12,23 @@
// ***************************************************************************************************************************
package org.apache.juneau.assertions;
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
-import org.apache.juneau.internal.*;
+import org.junit.*;
-/**
- * Used for fluent assertion calls against longs.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Validates the response length isn't too long.</jc>
- * <jv>client</jv>
- * .get(<jsf>URL</jsf>)
- * .run()
- * .assertLongHeader(<js>"Length"</js>).isLessThan(100000);
- * </p>
- *
- * @param <R> The return type.
- */
-@FluentSetters(returns="FluentLongAssertion<R>")
-public class FluentLongAssertion<R> extends FluentComparableAssertion<R> {
+@FixMethodOrder(NAME_ASCENDING)
+public class ComparableAssertion_Test {
- /**
- * Constructor.
- *
- * @param value The value being tested.
- * @param returns The object to return after the test.
- */
- public FluentLongAssertion(Long value, R returns) {
- super(value, returns);
+ @Test
+ public void a01_basic() throws Exception {
+ assertComparable(null).doesNotExist();
+ assertComparable(1).isGte(1);
}
- /**
- * Constructor.
- *
- * @param creator The assertion that created this assertion.
- * @param value The value being tested.
- * @param returns The object to return after the test.
- */
- public FluentLongAssertion(Assertion creator, Long value, R returns) {
- super(creator, value, returns);
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->ComparableAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ ComparableAssertion.create(null).stdout().stderr();
}
-
- // <FluentSetters>
-
- @Override /* GENERATED - Assertion */
- public FluentLongAssertion<R> msg(String msg, Object...args) {
- super.msg(msg, args);
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public FluentLongAssertion<R> stderr() {
- super.stderr();
- return this;
- }
-
- @Override /* GENERATED - Assertion */
- public FluentLongAssertion<R> stdout() {
- super.stdout();
- return this;
- }
-
- // </FluentSetters>
}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/DateAssertion_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/DateAssertion_Test.java
new file mode 100644
index 0000000..a23fd26
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/DateAssertion_Test.java
@@ -0,0 +1,77 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.time.temporal.*;
+import java.util.*;
+
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class DateAssertion_Test {
+
+ @Test
+ public void a01_basic() throws Exception {
+ Date x1 = new Date(0), x2 = new Date(Long.MAX_VALUE), now = new Date();
+
+ assertThrown(()->assertDate(null).exists()).is("Value was null.");
+ assertDate(x1).exists();
+
+ assertDate(null).doesNotExist();
+ assertThrown(()->assertDate(x1).doesNotExist()).is("Value was not null.");
+
+ assertDate(null).isEqual(null);
+ assertDate(x1).isEqual(x1);
+ assertDate(x1).isEqual(x1, ChronoUnit.DAYS);
+ assertThrown(()->assertDate(x2).isEqual(x1, ChronoUnit.DAYS)).contains("Unexpected value.");
+
+ assertDate(null).isEqual(null);
+ assertDate(x1).isEqual(x1);
+ assertDate(x1).isEqual(x1, ChronoUnit.DAYS);
+ assertThrown(()->assertDate(x2).isEqual(x1, ChronoUnit.DAYS)).contains("Unexpected value.");
+
+ assertThrown(()->assertDate(null).isBefore(x1)).is("Value was null.");
+ assertThrown(()->assertDate(x1).isBefore(null)).is("Parameter cannot be null.");
+ assertDate(x1).isBefore(x2);
+ assertThrown(()->assertDate(x2).isBefore(x1)).contains("Value was not before expected.");
+
+ assertThrown(()->assertDate(null).isAfter(x1)).is("Value was null.");
+ assertThrown(()->assertDate(x1).isAfter(null)).is("Parameter cannot be null.");
+ assertDate(x2).isAfter(x1);
+ assertThrown(()->assertDate(x1).isAfter(x2)).contains("Value was not after expected.");
+
+ assertThrown(()->assertDate(null).isBeforeNow()).is("Value was null.");
+ assertDate(x1).isBeforeNow();
+ assertThrown(()->assertDate(x2).isBeforeNow()).contains("Value was not before expected.");
+
+ assertThrown(()->assertDate(null).isAfterNow()).is("Value was null.");
+ assertDate(x2).isAfterNow();
+ assertThrown(()->assertDate(x1).isAfterNow()).contains("Value was not after expected.");
+
+ assertThrown(()->assertDate(null).isBetween(x1,x2)).is("Value was null.");
+ assertThrown(()->assertDate(now).isBetween(null,x2)).is("Parameter 'lower' cannot be null.");
+ assertThrown(()->assertDate(now).isBetween(x1,null)).is("Parameter 'upper' cannot be null.");
+ assertDate(now).isBetween(x1, x2);
+ assertThrown(()->assertDate(x1).isBetween(now,x2)).contains("Value was not after expected.");
+ assertThrown(()->assertDate(x2).isBetween(x1,now)).contains("Value was not before expected.");
+ }
+
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->DateAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ DateAssertion.create(null).stdout().stderr();
+ }
+}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/FluentIntegerAssertion_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/FluentIntegerAssertion_Test.java
new file mode 100644
index 0000000..be56358
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/FluentIntegerAssertion_Test.java
@@ -0,0 +1,101 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class FluentIntegerAssertion_Test {
+
+ @Test
+ public void a01_basic() throws Exception {
+
+ assertThrown(()->assertInteger(null).exists()).is("Value was null.");
+ assertInteger(1).exists();
+
+ assertInteger(null).doesNotExist();
+ assertThrown(()->assertInteger(1).doesNotExist()).is("Value was not null.");
+
+ assertInteger(null).isEqual(null);
+ assertInteger(1).isEqual(1);
+
+ assertThrown(()->assertInteger(1).isEqual(2)).contains("Unexpected value.");
+ assertInteger(null).isEqual(null);
+
+ assertThrown(()->assertInteger(null).isGreaterThan(1)).is("Value was null.");
+ assertThrown(()->assertInteger(1).isGreaterThan(null)).is("Parameter cannot be null.");
+ assertInteger(2).isGreaterThan(1);
+ assertThrown(()->assertInteger(1).isGreaterThan(2)).is("Value was not greater than expected.\n\tExpected=[2]\n\tActual=[1]");
+ assertThrown(()->assertInteger(1).isGreaterThan(1)).is("Value was not greater than expected.\n\tExpected=[1]\n\tActual=[1]");
+
+ assertThrown(()->assertInteger(null).isGt(1)).is("Value was null.");
+ assertThrown(()->assertInteger(1).isGt(null)).is("Parameter cannot be null.");
+ assertInteger(2).isGt(1);
+ assertThrown(()->assertInteger(1).isGt(2)).is("Value was not greater than expected.\n\tExpected=[2]\n\tActual=[1]");
+ assertThrown(()->assertInteger(1).isGt(1)).is("Value was not greater than expected.\n\tExpected=[1]\n\tActual=[1]");
+
+ assertThrown(()->assertInteger(null).isGreaterThanOrEqual(1)).is("Value was null.");
+ assertThrown(()->assertInteger(1).isGreaterThanOrEqual(null)).is("Parameter cannot be null.");
+ assertInteger(2).isGreaterThanOrEqual(1);
+ assertThrown(()->assertInteger(1).isGreaterThanOrEqual(2)).is("Value was not greater than or equals to expected.\n\tExpected=[2]\n\tActual=[1]");
+ assertInteger(1).isGreaterThanOrEqual(1);
+
+ assertThrown(()->assertInteger(null).isGte(1)).is("Value was null.");
+ assertThrown(()->assertInteger(1).isGte(null)).is("Parameter cannot be null.");
+ assertInteger(2).isGte(1);
+ assertThrown(()->assertInteger(1).isGte(2)).is("Value was not greater than or equals to expected.\n\tExpected=[2]\n\tActual=[1]");
+ assertInteger(1).isGte(1);
+
+ assertThrown(()->assertInteger(null).isLessThan(1)).is("Value was null.");
+ assertThrown(()->assertInteger(1).isLessThan(null)).is("Parameter cannot be null.");
+ assertInteger(1).isLessThan(2);
+ assertThrown(()->assertInteger(2).isLessThan(1)).is("Value was not less than expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertThrown(()->assertInteger(1).isLessThan(1)).is("Value was not less than expected.\n\tExpected=[1]\n\tActual=[1]");
+
+ assertThrown(()->assertInteger(null).isLt(1)).is("Value was null.");
+ assertThrown(()->assertInteger(1).isLt(null)).is("Parameter cannot be null.");
+ assertInteger(1).isLt(2);
+ assertThrown(()->assertInteger(2).isLt(1)).is("Value was not less than expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertThrown(()->assertInteger(1).isLt(1)).is("Value was not less than expected.\n\tExpected=[1]\n\tActual=[1]");
+
+ assertThrown(()->assertInteger(null).isLessThanOrEqual(1)).is("Value was null.");
+ assertThrown(()->assertInteger(1).isLessThanOrEqual(null)).is("Parameter cannot be null.");
+ assertInteger(1).isLessThanOrEqual(2);
+ assertThrown(()->assertInteger(2).isLessThanOrEqual(1)).is("Value was not less than or equals to expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertInteger(1).isLessThanOrEqual(1);
+
+ assertThrown(()->assertInteger(null).isLte(1)).is("Value was null.");
+ assertThrown(()->assertInteger(1).isLte(null)).is("Parameter cannot be null.");
+ assertInteger(1).isLte(2);
+ assertThrown(()->assertInteger(2).isLte(1)).is("Value was not less than or equals to expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertInteger(1).isLte(1);
+
+ assertThrown(()->assertInteger(null).isBetween(1,3)).is("Value was null.");
+ assertThrown(()->assertInteger(2).isBetween(null,3)).is("Parameter 'lower' cannot be null.");
+ assertThrown(()->assertInteger(2).isBetween(1,null)).is("Parameter 'upper' cannot be null.");
+ assertInteger(2).isBetween(1,3);
+ assertInteger(1).isBetween(1,3);
+ assertInteger(3).isBetween(1,3);
+ assertThrown(()->assertInteger(2).isBetween(1,1)).is("Value was not less than or equals to expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertThrown(()->assertInteger(2).isBetween(3,3)).is("Value was not greater than or equals to expected.\n\tExpected=[3]\n\tActual=[2]");
+ }
+
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->IntegerAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ IntegerAssertion.create(null).stdout().stderr();
+ }
+}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/FluentLongAssertion_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/FluentLongAssertion_Test.java
new file mode 100644
index 0000000..6ac4fb6
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/FluentLongAssertion_Test.java
@@ -0,0 +1,104 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class FluentLongAssertion_Test {
+
+ @Test
+ public void a01_basic() throws Exception {
+
+ assertThrown(()->assertLong(null).exists()).is("Value was null.");
+ assertLong(1l).exists();
+
+ assertLong(null).doesNotExist();
+ assertThrown(()->assertLong(1l).doesNotExist()).is("Value was not null.");
+
+ assertLong(null).isEqual(null);
+ assertLong(1l).isEqual(1l);
+
+ assertThrown(()->assertLong(1l).isEqual(2)).contains("Unexpected value.");
+ assertLong(null).isEqual(null);
+
+ assertThrown(()->assertLong(null).isGreaterThan(1)).is("Value was null.");
+ assertThrown(()->assertLong(1l).isGreaterThan(null)).is("Parameter cannot be null.");
+ assertLong(2l).isGreaterThan(1);
+ assertThrown(()->assertLong(1l).isGreaterThan(2l)).is("Value was not greater than expected.\n\tExpected=[2]\n\tActual=[1]");
+ assertThrown(()->assertLong(1l).isGreaterThan(1l)).is("Value was not greater than expected.\n\tExpected=[1]\n\tActual=[1]");
+
+ assertLong(2l).integer().isGreaterThan(1);
+ assertLong(null).integer().isNull();
+
+ assertThrown(()->assertLong(null).isGt(1l)).is("Value was null.");
+ assertThrown(()->assertLong(1l).isGt(null)).is("Parameter cannot be null.");
+ assertLong(2l).isGt(1);
+ assertThrown(()->assertLong(1l).isGt(2)).is("Value was not greater than expected.\n\tExpected=[2]\n\tActual=[1]");
+ assertThrown(()->assertLong(1l).isGt(1)).is("Value was not greater than expected.\n\tExpected=[1]\n\tActual=[1]");
+
+ assertThrown(()->assertLong(null).isGreaterThanOrEqual(1)).is("Value was null.");
+ assertThrown(()->assertLong(1l).isGreaterThanOrEqual(null)).is("Parameter cannot be null.");
+ assertLong(2l).isGreaterThanOrEqual(1);
+ assertThrown(()->assertLong(1l).isGreaterThanOrEqual(2)).is("Value was not greater than or equals to expected.\n\tExpected=[2]\n\tActual=[1]");
+ assertLong(1l).isGreaterThanOrEqual(1);
+
+ assertThrown(()->assertLong(null).isGte(1)).is("Value was null.");
+ assertThrown(()->assertLong(1l).isGte(null)).is("Parameter cannot be null.");
+ assertLong(2l).isGte(1);
+ assertThrown(()->assertLong(1l).isGte(2l)).is("Value was not greater than or equals to expected.\n\tExpected=[2]\n\tActual=[1]");
+ assertLong(1l).isGte(1l);
+
+ assertThrown(()->assertLong(null).isLessThan(1)).is("Value was null.");
+ assertThrown(()->assertLong(1l).isLessThan(null)).is("Parameter cannot be null.");
+ assertLong(1l).isLessThan(2l);
+ assertThrown(()->assertLong(2l).isLessThan(1)).is("Value was not less than expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertThrown(()->assertLong(1l).isLessThan(1)).is("Value was not less than expected.\n\tExpected=[1]\n\tActual=[1]");
+
+ assertThrown(()->assertLong(null).isLt(1)).is("Value was null.");
+ assertThrown(()->assertLong(1l).isLt(null)).is("Parameter cannot be null.");
+ assertLong(1l).isLt(2);
+ assertThrown(()->assertLong(2l).isLt(1)).is("Value was not less than expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertThrown(()->assertLong(1l).isLt(1)).is("Value was not less than expected.\n\tExpected=[1]\n\tActual=[1]");
+
+ assertThrown(()->assertLong(null).isLessThanOrEqual(1)).is("Value was null.");
+ assertThrown(()->assertLong(1l).isLessThanOrEqual(null)).is("Parameter cannot be null.");
+ assertLong(1l).isLessThanOrEqual(2);
+ assertThrown(()->assertLong(2l).isLessThanOrEqual(1)).is("Value was not less than or equals to expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertLong(1l).isLessThanOrEqual(1);
+
+ assertThrown(()->assertLong(null).isLte(1)).is("Value was null.");
+ assertThrown(()->assertLong(1l).isLte(null)).is("Parameter cannot be null.");
+ assertLong(1l).isLte(2);
+ assertThrown(()->assertLong(2l).isLte(1)).is("Value was not less than or equals to expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertLong(1l).isLte(1);
+
+ assertThrown(()->assertLong(null).isBetween(1,3)).is("Value was null.");
+ assertThrown(()->assertLong(2l).isBetween(null,3)).is("Parameter 'lower' cannot be null.");
+ assertThrown(()->assertLong(2l).isBetween(1,null)).is("Parameter 'upper' cannot be null.");
+ assertLong(2l).isBetween(1,3);
+ assertLong(1l).isBetween(1,3);
+ assertLong(3l).isBetween(1,3);
+ assertThrown(()->assertLong(2l).isBetween(1,1)).is("Value was not less than or equals to expected.\n\tExpected=[1]\n\tActual=[2]");
+ assertThrown(()->assertLong(2l).isBetween(3,3)).is("Value was not greater than or equals to expected.\n\tExpected=[3]\n\tActual=[2]");
+ }
+
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->LongAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ LongAssertion.create(null).stdout().stderr();
+ }
+}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ListAssertion_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ListAssertion_Test.java
new file mode 100644
index 0000000..e70cb13
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ListAssertion_Test.java
@@ -0,0 +1,70 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.util.*;
+
+import org.apache.juneau.collections.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class ListAssertion_Test {
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void a01_basic() throws Exception {
+ List<String> x1 = AList.of(), x2 = AList.of("a","b");
+
+ assertThrown(()->assertList(null).exists()).is("Value was null.");
+ assertList(x1).exists();
+
+ assertList(null).doesNotExist();
+ assertThrown(()->assertList(x1).doesNotExist()).is("Value was not null.");
+
+ assertThrown(()->assertList(null).isSize(0)).is("Value was null.");
+ assertList(x1).isSize(0);
+ assertThrown(()->assertList(x1).isSize(1)).is("Collection did not have the expected size. Expected=1, Actual=0.");
+ assertList(x2).isSize(2);
+ assertThrown(()->assertList(x2).isSize(0)).is("Collection did not have the expected size. Expected=0, Actual=2.");
+
+ assertThrown(()->assertList(null).isEmpty()).is("Value was null.");
+ assertList(x1).isEmpty();
+ assertThrown(()->assertList(x2).isEmpty()).is("Collection was not empty.");
+
+ assertThrown(()->assertList(null).isNotEmpty()).is("Value was null.");
+ assertThrown(()->assertList(x1).isNotEmpty()).is("Collection was empty.");
+ assertList(x2).isNotEmpty();
+
+ assertList(null).item(0).doesNotExist();
+ assertList(x1).item(0).doesNotExist();
+ assertList(x2).item(0).exists();
+
+ assertList(AList.of("foo")).stringItem(0).is("foo");
+ assertList(AList.of(new Date(0))).dateItem(0).isBeforeNow();
+ assertList(AList.of(1)).integerItem(0).is(1);
+ assertList(AList.of(1l)).longItem(0).is(1l);
+ assertList(AList.ofa(AList.of("foo"))).listItem(0).stringItem(0).is("foo");
+ assertList(AList.ofa(AList.of("foo"))).collectionItem(0).isSize(1);
+
+ assertThrown(()->assertList(AList.of(1)).listItem(0)).is("Object was not expected type. Expected=java.util.List, Actual=java.lang.Integer.");
+ }
+
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->ListAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ ListAssertion.create(null).stdout().stderr();
+ }
+}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ObjectAssertion_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ObjectAssertion_Test.java
new file mode 100644
index 0000000..2423ae3
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/assertions/ObjectAssertion_Test.java
@@ -0,0 +1,67 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.assertions;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class ObjectAssertion_Test {
+
+ public static class A1 {
+ public int getFoo() {
+ throw new RuntimeException("foo");
+ }
+ }
+
+ public static class A2 {
+ public int getFoo() {
+ return 1;
+ }
+ public int getBar() {
+ return 2;
+ }
+ }
+
+ @Test
+ public void a01_basic() throws Exception {
+ assertObject(null).doesNotExist();
+ assertObject(1).exists();
+
+ assertThrown(()->assertObject(null).isType(null)).is("Value was null.");
+ assertThrown(()->assertObject("foo").isType(null)).is("Parameter cannot be null.");
+ assertObject("foo").isType(String.class);
+ assertObject("foo").isType(CharSequence.class);
+ assertObject("foo").isType(Comparable.class);
+ assertThrown(()->assertObject(1).isType(String.class)).is("Unexpected class.\n\tExpected=[java.lang.String]\n\tActual=[java.lang.Integer]");
+
+ assertObject("foo").serialized(JsonSerializer.DEFAULT).is("\"foo\"");
+ assertObject(null).serialized(JsonSerializer.DEFAULT).is("null");
+
+ assertThrown(()->assertObject(new A1()).json()).contains("Could not call getValue() on property 'foo'");
+
+ assertObject("foo").json().is("'foo'");
+ assertObject(null).serialized(JsonSerializer.DEFAULT).is("null");
+
+ assertObject(new A2()).jsonSorted().is("{bar:2,foo:1}");
+ }
+
+ @Test
+ public void a02_other() throws Exception {
+ assertThrown(()->ObjectAssertion.create(null).msg("Foo {0}", 1).exists()).is("Foo 1");
+ ObjectAssertion.create(null).stdout().stderr();
+ }
+}
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/config/ConfigInterfaceTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/config/ConfigInterfaceTest.java
index 2b8a1a0..b237151 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/config/ConfigInterfaceTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/config/ConfigInterfaceTest.java
@@ -224,7 +224,7 @@ public class ConfigInterfaceTest {
@Test
public void testTypedBean() throws Exception {
proxy.setTypedBean(TypedBeanImpl.get());
- assertObject(proxy.getTypedBean()).json().is("{_type:'TypedBeanImpl',a:1,b:'foo'}");
+ assertObject(proxy.getTypedBean()).json().is("{a:1,b:'foo'}");
assertEquals("{_type:'TypedBeanImpl',a:1,b:'foo'}", cf.get("A/typedBean"));
assertObject(proxy.getTypedBean()).isType(TypedBeanImpl.class);
}
@@ -232,7 +232,7 @@ public class ConfigInterfaceTest {
@Test
public void testTypedBean3dArray() throws Exception {
proxy.setTypedBean3dArray(new TypedBean[][][]{{{TypedBeanImpl.get(),null},null},null});
- assertObject(proxy.getTypedBean3dArray()).json().is("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]");
+ assertObject(proxy.getTypedBean3dArray()).json().is("[[[{a:1,b:'foo'},null],null],null]");
assertEquals("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]", cf.get("A/typedBean3dArray"));
assertObject(proxy.getTypedBean3dArray()[0][0][0]).isType(TypedBeanImpl.class);
}
@@ -240,7 +240,7 @@ public class ConfigInterfaceTest {
@Test
public void testTypedBeanList() throws Exception {
proxy.setTypedBeanList(Arrays.asList((TypedBean)TypedBeanImpl.get()));
- assertObject(proxy.getTypedBeanList()).json().is("[{_type:'TypedBeanImpl',a:1,b:'foo'}]");
+ assertObject(proxy.getTypedBeanList()).json().is("[{a:1,b:'foo'}]");
assertEquals("[{_type:'TypedBeanImpl',a:1,b:'foo'}]", cf.get("A/typedBeanList"));
assertObject(proxy.getTypedBeanList().get(0)).isType(TypedBeanImpl.class);
}
@@ -248,7 +248,7 @@ public class ConfigInterfaceTest {
@Test
public void testTypedBean1d3dList() throws Exception {
proxy.setTypedBean1d3dList(AList.of(new TypedBean[][][]{{{TypedBeanImpl.get(),null},null},null},null));
- assertObject(proxy.getTypedBean1d3dList()).json().is("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]");
+ assertObject(proxy.getTypedBean1d3dList()).json().is("[[[[{a:1,b:'foo'},null],null],null],null]");
assertEquals("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]", cf.get("A/typedBean1d3dList"));
assertObject(proxy.getTypedBean1d3dList().get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@@ -256,7 +256,7 @@ public class ConfigInterfaceTest {
@Test
public void testTypedBeanMap() throws Exception {
proxy.setTypedBeanMap(AMap.of("foo",TypedBeanImpl.get()));
- assertObject(proxy.getTypedBeanMap()).json().is("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}");
+ assertObject(proxy.getTypedBeanMap()).json().is("{foo:{a:1,b:'foo'}}");
assertEquals("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}", cf.get("A/typedBeanMap"));
assertObject(proxy.getTypedBeanMap().get("foo")).isType(TypedBeanImpl.class);
}
@@ -264,7 +264,7 @@ public class ConfigInterfaceTest {
@Test
public void testTypedBeanListMap() throws Exception {
proxy.setTypedBeanListMap(AMap.of("foo",Arrays.asList((TypedBean)TypedBeanImpl.get())));
- assertObject(proxy.getTypedBeanListMap()).json().is("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(proxy.getTypedBeanListMap()).json().is("{foo:[{a:1,b:'foo'}]}");
assertEquals("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}", cf.get("A/typedBeanListMap"));
assertObject(proxy.getTypedBeanListMap().get("foo").get(0)).isType(TypedBeanImpl.class);
}
@@ -272,7 +272,7 @@ public class ConfigInterfaceTest {
@Test
public void testTypedBean1d3dListMap() throws Exception {
proxy.setTypedBean1d3dListMap(AMap.of("foo",AList.of(new TypedBean[][][]{{{TypedBeanImpl.get(),null},null},null},null)));
- assertObject(proxy.getTypedBean1d3dListMap()).json().is("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}");
+ assertObject(proxy.getTypedBean1d3dListMap()).json().is("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}");
assertEquals("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}", cf.get("A/typedBean1d3dListMap"));
assertObject(proxy.getTypedBean1d3dListMap().get("foo").get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@@ -280,7 +280,7 @@ public class ConfigInterfaceTest {
@Test
public void testTypedBeanListMapIntegerKeys() throws Exception {
proxy.setTypedBeanListMapIntegerKeys(AMap.of(1,Arrays.asList((TypedBean)TypedBeanImpl.get())));
- assertObject(proxy.getTypedBeanListMapIntegerKeys()).json().is("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(proxy.getTypedBeanListMapIntegerKeys()).json().is("{'1':[{a:1,b:'foo'}]}");
assertEquals("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}", cf.get("A/typedBeanListMapIntegerKeys"));
assertObject(proxy.getTypedBeanListMapIntegerKeys().get(1).get(0)).isType(TypedBeanImpl.class);
}
@@ -315,7 +315,7 @@ public class ConfigInterfaceTest {
@Test
public void testSwappedPojo3dMap() throws Exception {
proxy.setSwappedPojo3dMap(AMap.of(new SwappedPojo(), new SwappedPojo[][][]{{{new SwappedPojo(),null},null},null}));
- assertObject(proxy.getSwappedPojo3dMap()).json().is("{'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/':[[['swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/',null],null],null]}");
+ assertObject(proxy.getSwappedPojo3dMap()).stderr().json().is("{'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/':[[['swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/',null],null],null]}");
assertEquals("{'swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/':[[['swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/',null],null],null]}", cf.get("A/swappedPojo3dMap"));
assertObject(proxy.getSwappedPojo3dMap().keySet().iterator().next()).isType(SwappedPojo.class);
assertObject(proxy.getSwappedPojo3dMap().values().iterator().next()[0][0][0]).isType(SwappedPojo.class);
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java
index f4424c5..ed5b40f 100644
--- a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java
@@ -566,7 +566,7 @@ public class UriResolutionTest {
if (isRdf) {
Object[] args = { label, s.getClass().getSimpleName() };
- assertString(r).msg("{0}/{1} serialize-normal failed", args).equalsAfterSort(expected);
+ assertString(r).msg("{0}/{1} serialize-normal failed", args).isEqualAfterSort(expected);
} else
assertString(r).msg("{0}/{1} serialize-normal failed", label, s.getClass().getSimpleName()).is(expected);
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 f4746e3..28a588f 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
@@ -36,10 +36,12 @@ public class Assertion {
* @param creator The creator of this assertion.
*/
protected Assertion(Assertion creator) {
- this.msg = creator.msg;
- this.msgArgs = creator.msgArgs;
- this.stdout = creator.stdout;
- this.stderr = creator.stderr;
+ if (creator != null) {
+ this.msg = creator.msg;
+ this.msgArgs = creator.msgArgs;
+ this.stdout = creator.stdout;
+ this.stderr = creator.stderr;
+ }
}
/**
@@ -110,6 +112,19 @@ public class Assertion {
}
/**
+ * Asserts the specified value is not null.
+ *
+ * @param value The value to check.
+ * @param msg The message.
+ * @param args The message arguments.
+ */
+ protected void assertNotNull(Object value, String msg, Object...args) {
+ if (value == null)
+ throw new BasicAssertionError(format(msg, args));
+ }
+
+
+ /**
* Casts the specified object to the specified type.
*
* @param <T> The type to cast the object to.
@@ -123,7 +138,7 @@ public class Assertion {
return null;
if (c.isInstance(o))
return (T)o;
- throw new BasicAssertionError("Object was not expected type. Expected={0}, actual={1}.", c.getClass().getName(), o.getClass().getName());
+ throw new BasicAssertionError("Object was not expected type. Expected={0}, Actual={1}.", c.getName(), className(o));
}
// <FluentSetters>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertions.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/Assertions.java
index f5921b7..4506cd4 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
@@ -71,6 +71,22 @@ public class Assertions {
}
/**
+ * Used for assertion calls against longs.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Validates the response length isn't too long.</jc>
+ * <jsm>assertLong</jsm>(<jv>responseLength</jv>).isLessThan(100000);
+ * </p>
+ *
+ * @param value The object being wrapped.
+ * @return A new {@link LongAssertion} object. Never <jk>null</jk>.
+ */
+ public static ComparableAssertion assertComparable(Comparable<?> value) {
+ return new ComparableAssertion(value);
+ }
+
+ /**
* Used for assertion calls against arbitrary POJOs.
*
* <h5 class='section'>Example:</h5>
@@ -146,8 +162,7 @@ public class Assertions {
* @param value The object being wrapped.
* @return A new {@link CollectionAssertion} object. Never <jk>null</jk>.
*/
- @SuppressWarnings("rawtypes")
- public static CollectionAssertion assertCollection(Collection value) {
+ public static CollectionAssertion assertCollection(Collection<?> value) {
return new CollectionAssertion(value);
}
@@ -157,14 +172,13 @@ public class Assertions {
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
* List=<String> <jv>list</jv> = AList.<jsm>of</jsm>(<js>"foo"</js>);
- * <jsm>assertList</jsm>(<jv>list</jv>).item(0).isEquals(<js>"foo"</js>);
+ * <jsm>assertList</jsm>(<jv>list</jv>).item(0).isEqual(<js>"foo"</js>);
* </p>
*
* @param value The object being wrapped.
* @return A new {@link ListAssertion} object. Never <jk>null</jk>.
*/
- @SuppressWarnings("rawtypes")
- public static ListAssertion assertList(List value) {
+ public static ListAssertion assertList(List<?> value) {
return new ListAssertion(value);
}
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 903ef49..aff9e92 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,8 +34,7 @@ public class FluentArrayAssertion<R> extends FluentObjectAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentArrayAssertion(Object contents, R returns) {
- super(contents, returns);
- this.value = contents;
+ this((Assertion)null, contents, returns);
}
/**
@@ -59,7 +58,7 @@ public class FluentArrayAssertion<R> extends FluentObjectAssertion<R> {
public R isEmpty() throws AssertionError {
exists();
if (Array.getLength(value) != 0)
- throw error("Collection was not empty.");
+ throw error("Array was not empty.");
return returns();
}
@@ -72,7 +71,7 @@ public class FluentArrayAssertion<R> extends FluentObjectAssertion<R> {
public R isNotEmpty() throws AssertionError {
exists();
if (Array.getLength(value) == 0)
- throw error("Collection was empty.");
+ throw error("Array was empty.");
return returns();
}
@@ -85,8 +84,8 @@ public class FluentArrayAssertion<R> extends FluentObjectAssertion<R> {
*/
public R isSize(int size) throws AssertionError {
exists();
- if (Array.getLength(value) == size)
- throw error("Array did not have the expected size. Expected={0}, actual={0}.", size, Array.getLength(value));
+ if (Array.getLength(value) != size)
+ throw error("Array did not have the expected size. Expected={0}, Actual={1}.", size, Array.getLength(value));
return returns();
}
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 6e06ecf..820cd8a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentByteArrayAssertion.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentByteArrayAssertion.java
@@ -24,7 +24,7 @@ import org.apache.juneau.internal.*;
* @param <R> The return type.
*/
@FluentSetters(returns="FluentByteArrayAssertion<R>")
-public class FluentByteArrayAssertion<R> extends FluentObjectAssertion<R> {
+public class FluentByteArrayAssertion<R> extends FluentArrayAssertion<R> {
private byte[] value;
@@ -35,8 +35,7 @@ public class FluentByteArrayAssertion<R> extends FluentObjectAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentByteArrayAssertion(byte[] contents, R returns) {
- super(contents, returns);
- this.value = contents;
+ this(null, contents, returns);
}
/**
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 836f8f6..474c28d 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
@@ -86,7 +86,7 @@ public class FluentCollectionAssertion<R> extends FluentObjectAssertion<R> {
public R isSize(int size) throws AssertionError {
exists();
if (value.size() != size)
- throw error("Collection did not have the expected size. Expected={0}, actual={0}.", size, value.size());
+ throw error("Collection did not have the expected size. Expected={0}, Actual={1}.", size, value.size());
return returns();
}
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 dc52c0b..f911dee 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
@@ -32,8 +32,7 @@ public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentComparableAssertion(Comparable value, R returns) {
- super(value, returns);
- this.value = value;
+ this(null, value, returns);
}
/**
@@ -57,7 +56,8 @@ public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
*/
public R isGreaterThan(Comparable value) throws AssertionError {
exists();
- if (value != null && this.value.compareTo(value) < 0)
+ assertNotNull(value, "Parameter cannot be null.");
+ if (compareTo(value) <= 0)
throw error("Value was not greater than expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
return returns();
}
@@ -83,9 +83,10 @@ public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- public R isGreaterThanOrEquals(Comparable value) throws AssertionError {
+ public R isGreaterThanOrEqual(Comparable value) throws AssertionError {
exists();
- if (value != null && this.value.compareTo(value) > 0)
+ assertNotNull(value, "Parameter cannot be null.");
+ if (compareTo(value) < 0)
throw error("Value was not greater than or equals to expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
return returns();
}
@@ -94,14 +95,14 @@ public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
* Asserts that the value is greater than or equal to the specified value.
*
* <p>
- * Equivalent to {@link #isGreaterThanOrEquals(Comparable)}
+ * Equivalent to {@link #isGreaterThanOrEqual(Comparable)}
*
* @param value The values to check against.
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
public R isGte(Comparable value) throws AssertionError {
- return isGreaterThanOrEquals(value);
+ return isGreaterThanOrEqual(value);
}
/**
@@ -113,7 +114,8 @@ public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
*/
public R isLessThan(Comparable value) throws AssertionError {
exists();
- if (value != null && this.value.compareTo(value) <= 0)
+ assertNotNull(value, "Parameter cannot be null.");
+ if (compareTo(value) >= 0)
throw error("Value was not less than expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
return returns();
}
@@ -139,9 +141,10 @@ public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- public R isLessThanOrEquals(Comparable value) throws AssertionError {
+ public R isLessThanOrEqual(Comparable value) throws AssertionError {
exists();
- if (value != null && this.value.compareTo(value) >= 0)
+ assertNotNull(value, "Parameter cannot be null.");
+ if (compareTo(value) > 0)
throw error("Value was not less than or equals to expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
return returns();
}
@@ -150,14 +153,14 @@ public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
* Asserts that the value is less than or equals to the specified value.
*
* <p>
- * Equivalent to {@link #isLessThanOrEquals(Comparable)}
+ * Equivalent to {@link #isLessThanOrEqual(Comparable)}
*
* @param value The values to check against.
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
public R isLte(Comparable value) throws AssertionError {
- return isLessThanOrEquals(value);
+ return isLessThanOrEqual(value);
}
/**
@@ -169,8 +172,21 @@ public class FluentComparableAssertion<R> extends FluentObjectAssertion<R> {
* @throws AssertionError If assertion failed.
*/
public R isBetween(Comparable lower, Comparable upper) throws AssertionError {
- isLessThanOrEquals(upper);
- isGreaterThanOrEquals(lower);
+ exists();
+ assertNotNull(lower, "Parameter 'lower' cannot be null.");
+ assertNotNull(upper, "Parameter 'upper' cannot be null.");
+ isLessThanOrEqual(upper);
+ isGreaterThanOrEqual(lower);
return returns();
}
+
+ /**
+ * Perform a comparison with the specified object.
+ *
+ * @param value The object to compare against.
+ * @return The comparison value.
+ */
+ protected int compareTo(Object value) {
+ return this.value.compareTo(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 22e1003..06aa5d5 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
@@ -45,8 +45,7 @@ public class FluentDateAssertion<R> extends FluentComparableAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentDateAssertion(Date value, R returns) {
- super(value, returns);
- this.value = value;
+ this(null, value, returns);
}
/**
@@ -69,7 +68,7 @@ public class FluentDateAssertion<R> extends FluentComparableAssertion<R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- public R equals(Date value, ChronoUnit precision) throws AssertionError {
+ public R isEqual(Date value, ChronoUnit precision) throws AssertionError {
if (ne(this.value, value, (x,y)->x.toInstant().truncatedTo(precision).equals(y.toInstant().truncatedTo(precision))))
throw error("Unexpected value.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
return returns();
@@ -83,9 +82,10 @@ public class FluentDateAssertion<R> extends FluentComparableAssertion<R> {
* @throws AssertionError If assertion failed.
*/
public R isAfter(Date value) throws AssertionError {
- if (this.value != null)
- if (! (this.value.after(value)))
- throw error("Value was not greater than expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
+ exists();
+ assertNotNull(value, "Parameter cannot be null.");
+ if (! (this.value.after(value)))
+ throw error("Value was not after expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
return returns();
}
@@ -107,9 +107,10 @@ public class FluentDateAssertion<R> extends FluentComparableAssertion<R> {
* @throws AssertionError If assertion failed.
*/
public R isBefore(Date value) throws AssertionError {
- if (this.value != null)
- if (! (this.value.before(value)))
- throw error("Value was not less than expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
+ exists();
+ assertNotNull(value, "Parameter cannot be null.");
+ if (! (this.value.before(value)))
+ throw error("Value was not before expected.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
return returns();
}
@@ -132,6 +133,9 @@ public class FluentDateAssertion<R> extends FluentComparableAssertion<R> {
* @throws AssertionError If assertion failed.
*/
public R isBetween(Date lower, Date upper) throws AssertionError {
+ exists();
+ assertNotNull(lower, "Parameter 'lower' cannot be null.");
+ assertNotNull(upper, "Parameter 'upper' cannot be null.");
isBefore(upper);
isAfter(lower);
return returns();
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 1066e27..6ee4a1b 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
@@ -32,6 +32,8 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="FluentIntegerAssertion<R>")
public class FluentIntegerAssertion<R> extends FluentComparableAssertion<R> {
+ private final Integer value;
+
/**
* Constructor.
*
@@ -39,7 +41,7 @@ public class FluentIntegerAssertion<R> extends FluentComparableAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentIntegerAssertion(Integer value, R returns) {
- super(value, returns);
+ this(null, value, returns);
}
/**
@@ -51,6 +53,12 @@ public class FluentIntegerAssertion<R> extends FluentComparableAssertion<R> {
*/
public FluentIntegerAssertion(Assertion creator, Integer value, R returns) {
super(creator, value, returns);
+ this.value = value;
+ }
+
+ @Override
+ protected int compareTo(Object value) {
+ return this.value.compareTo(((Number)value).intValue());
}
// <FluentSetters>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentLongAssertion.java
index 643ff83..27d9fa2 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
@@ -32,6 +32,8 @@ import org.apache.juneau.internal.*;
@FluentSetters(returns="FluentLongAssertion<R>")
public class FluentLongAssertion<R> extends FluentComparableAssertion<R> {
+ private final Long value;
+
/**
* Constructor.
*
@@ -39,7 +41,7 @@ public class FluentLongAssertion<R> extends FluentComparableAssertion<R> {
* @param returns The object to return after the test.
*/
public FluentLongAssertion(Long value, R returns) {
- super(value, returns);
+ this(null, value, returns);
}
/**
@@ -51,6 +53,21 @@ public class FluentLongAssertion<R> extends FluentComparableAssertion<R> {
*/
public FluentLongAssertion(Assertion creator, Long value, R returns) {
super(creator, value, returns);
+ this.value = value;
+ }
+
+ /**
+ * Converts this long into an integer and then returns it as an integer assertion.
+ *
+ * @return A new assertion.
+ */
+ public FluentIntegerAssertion<R> integer() {
+ return new FluentIntegerAssertion<>(this, value == null ? null : value.intValue(), returns());
+ }
+
+ @Override
+ protected int compareTo(Object value) {
+ return this.value.compareTo(((Number)value).longValue());
}
// <FluentSetters>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/assertions/FluentObjectAssertion.java
index cc304fb..6c5a3f1 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
@@ -33,7 +33,6 @@ public class FluentObjectAssertion<R> extends FluentAssertion<R> {
private static JsonSerializer JSON_BEANCOMPARE = JsonSerializer.create()
.ssq()
.keepNullProperties()
- .addBeanTypes().addRootType()
.build();
private static JsonSerializer JSON_BEANCOMPARESORTED = JsonSerializer.create()
@@ -41,18 +40,15 @@ public class FluentObjectAssertion<R> extends FluentAssertion<R> {
.sortCollections()
.sortMaps()
.keepNullProperties()
- .addBeanTypes().addRootType()
.build();
private static JsonSerializer JSON = JsonSerializer.create()
.ssq()
- .addBeanTypes().addRootType()
.build();
private static JsonSerializer JSON_SORTED = JsonSerializer.create()
.ssq()
.sortProperties()
- .addBeanTypes().addRootType()
.build();
/**
@@ -92,9 +88,9 @@ public class FluentObjectAssertion<R> extends FluentAssertion<R> {
* @throws AssertionError If assertion failed.
*/
public R isType(Class<?> parent) throws AssertionError {
- if (value == null && parent == null)
- return returns();
- if (value == null && parent != null || value != null && parent == null || ! ClassInfo.of(value).isChildOf(parent))
+ exists();
+ assertNotNull(parent, "Parameter cannot be null.");
+ if (! ClassInfo.of(value).isChildOf(parent))
throw error("Unexpected class.\n\tExpected=[{0}]\n\tActual=[{1}]", className(parent), className(value));
return returns();
}
@@ -199,52 +195,7 @@ public class FluentObjectAssertion<R> extends FluentAssertion<R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- public R equals(Integer value) throws AssertionError {
- if (this.value == value)
- return returns();
- exists();
- if (! this.value.equals(value))
- throw error("Unexpected value.\n\tExpected=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * <p>
- * Equivalent to {@link #equals(Integer)}.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R is(Integer value) throws AssertionError {
- return equals(value);
- }
-
- /**
- * Asserts that the value equals the specified value.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R doesNotEqual(Integer value) throws AssertionError {
- if (this.value != value)
- return returns();
- exists();
- if (this.value.equals(value))
- throw error("Unexpected value.\n\tExpected not=[{0}]\n\tActual=[{1}]", value, this.value);
- return returns();
- }
- /**
- * Asserts that the value equals the specified value.
- *
- * @param value The value to check against.
- * @return The response object (for method chaining).
- * @throws AssertionError If assertion failed.
- */
- public R isEquals(Object value) throws AssertionError {
+ public R isEqual(Object value) throws AssertionError {
if (this.value == value)
return returns();
exists();
@@ -257,14 +208,14 @@ public class FluentObjectAssertion<R> extends FluentAssertion<R> {
* Asserts that the value equals the specified value.
*
* <p>
- * Equivalent to {@link #equals(Integer)}.
+ * 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 R is(Object value) throws AssertionError {
- return isEquals(value);
+ return isEqual(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 8765046..12c6eb9 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
@@ -167,7 +167,7 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* client
* .get(<jsf>URL</jsf>)
* .run()
- * .assertBody().equals(
+ * .assertBody().isEqual(
* <js>"Line 1"</js>,
* <js>"Line 2"</js>,
* <js>"Line 3"</js>
@@ -180,7 +180,7 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- public R equals(String...value) throws AssertionError {
+ public R isEqual(String...value) throws AssertionError {
String v = join(value, '\n');
if (! StringUtils.isEquals(v, text))
throw error("Text differed at position {0}.\n\tExpected=[{1}]\n\tActual=[{2}]", diffPosition(v, text), fix(v), fix(text));
@@ -196,7 +196,7 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* client
* .get(<jsf>URL</jsf>)
* .run()
- * .assertBody().equalsAfterSort(<js>"OK"</js>);
+ * .assertBody().isEqualAfterSort(<js>"OK"</js>);
* </p>
*
* <p>
@@ -207,7 +207,7 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* client
* .get(<jsf>URL</jsf>)
* .run()
- * .assertBody().equalsAfterSort(
+ * .assertBody().isEqualAfterSort(
* <js>"Line 1"</js>,
* <js>"Line 2"</js>,
* <js>"Line 3"</js>
@@ -220,7 +220,7 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- public R equalsAfterSort(String...expected) {
+ public R isEqualAfterSort(String...expected) {
exists();
// Must work for windows too.
String[] e = StringUtils.join(expected, '\n').trim().split("[\r\n]+"), a = this.text.trim().split("[\r\n]+");
@@ -242,7 +242,7 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* Asserts that the text equals the specified value.
*
* <p>
- * Equivalent to {@link #equals(String...)}.
+ * Equivalent to {@link #isEqual(String...)}.
*
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
@@ -275,7 +275,7 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* @throws AssertionError If assertion failed.
*/
public R is(String...value) throws AssertionError {
- return equals(value);
+ return isEqual(value);
}
/**
@@ -285,8 +285,8 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* @return The response object (for method chaining).
* @throws AssertionError If assertion failed.
*/
- public R equalsIc(String value) throws AssertionError {
- if (! isEqualsIc(value, text))
+ public R isEqualsIc(String value) throws AssertionError {
+ if (! StringUtils.isEqualsIc(value, text))
throw error("Text differed at position {0}.\n\tExpected=[{1}]\n\tActual=[{2}]", diffPositionIc(value, text), fix(value), fix(text));
return returns();
}
@@ -326,7 +326,7 @@ public class FluentStringAssertion<R> extends FluentObjectAssertion<R> {
* @throws AssertionError If assertion failed.
*/
public R doesNotEqualIc(String value) throws AssertionError {
- if (isEqualsIc(value, text))
+ if (StringUtils.isEqualsIc(value, text))
throw error("Text equaled unexpected.\n\tText=[{1}]", fix(value));
return returns();
}
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 857c606..c914fc9 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
@@ -140,7 +140,7 @@ public class FluentThrowableAssertion<R> extends FluentAssertion<R> {
*
* @return This object (for method chaining).
*/
- public R notExists() {
+ public R doesNotExist() {
if (value != null)
throw error("Exception was thrown.");
return returns();
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index 599ab26..47a3c59 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -309,7 +309,7 @@ public abstract class SerializerSession extends BeanTraverseSession {
try {
if (o == null)
return null;
- PojoSwap f = (type == null || type.isObject() ? getClassMeta(o.getClass()).getSwap(this) : type.getSwap(this));
+ PojoSwap f = (type == null || type.isObject() || type.isString() ? getClassMeta(o.getClass()).getSwap(this) : type.getSwap(this));
if (f == null)
return o;
return f.swap(this, o);
diff --git a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
index 636df23..a3212b4 100644
--- a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
+++ b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
@@ -200,15 +200,15 @@ public class ThirdPartyProxyResource extends BasicRestServletJena {
@Header(n="h",cf="uon") Map<Integer,List<TypedBean>> h
) throws Exception {
- assertObject(a).json().is("{_type:'TypedBeanImpl',a:1,b:'foo'}");
+ assertObject(a).json().is("{a:1,b:'foo'}");
assertNull(an);
- assertObject(b).json().is("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]");
- assertObject(c).json().is("[{_type:'TypedBeanImpl',a:1,b:'foo'},null]");
- assertObject(d).json().is("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]");
- assertObject(e).json().is("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}");
- assertObject(f).json().is("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
- assertObject(g).json().is("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}");
- assertObject(h).json().is("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(b).json().is("[[[{a:1,b:'foo'},null],null],null]");
+ assertObject(c).json().is("[{a:1,b:'foo'},null]");
+ assertObject(d).json().is("[[[[{a:1,b:'foo'},null],null],null],null]");
+ assertObject(e).json().is("{foo:{a:1,b:'foo'}}");
+ assertObject(f).json().is("{foo:[{a:1,b:'foo'}]}");
+ assertObject(g).json().is("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}");
+ assertObject(h).json().is("{'1':[{a:1,b:'foo'}]}");
assertObject(a).isType(TypedBeanImpl.class);
assertObject(b[0][0][0]).isType(TypedBeanImpl.class);
@@ -512,15 +512,15 @@ public class ThirdPartyProxyResource extends BasicRestServletJena {
@Query(n="h",cf="uon") Map<Integer,List<TypedBean>> h
) throws Exception {
- assertObject(a).json().is("{_type:'TypedBeanImpl',a:1,b:'foo'}");
+ assertObject(a).json().is("{a:1,b:'foo'}");
assertNull(an);
- assertObject(b).json().is("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]");
- assertObject(c).json().is("[{_type:'TypedBeanImpl',a:1,b:'foo'},null]");
- assertObject(d).json().is("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]");
- assertObject(e).json().is("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}");
- assertObject(f).json().is("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
- assertObject(g).json().is("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}");
- assertObject(h).json().is("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(b).json().is("[[[{a:1,b:'foo'},null],null],null]");
+ assertObject(c).json().is("[{a:1,b:'foo'},null]");
+ assertObject(d).json().is("[[[[{a:1,b:'foo'},null],null],null],null]");
+ assertObject(e).json().is("{foo:{a:1,b:'foo'}}");
+ assertObject(f).json().is("{foo:[{a:1,b:'foo'}]}");
+ assertObject(g).json().is("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}");
+ assertObject(h).json().is("{'1':[{a:1,b:'foo'}]}");
assertObject(a).isType(TypedBeanImpl.class);
assertObject(b[0][0][0]).isType(TypedBeanImpl.class);
@@ -846,15 +846,15 @@ public class ThirdPartyProxyResource extends BasicRestServletJena {
@FormData(n="h",cf="uon") Map<Integer,List<TypedBean>> h
) throws Exception {
- assertObject(a).json().is("{_type:'TypedBeanImpl',a:1,b:'foo'}");
+ assertObject(a).json().is("{a:1,b:'foo'}");
assertNull(an);
- assertObject(b).json().is("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]");
- assertObject(c).json().is("[{_type:'TypedBeanImpl',a:1,b:'foo'},null]");
- assertObject(d).json().is("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]");
- assertObject(e).json().is("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}");
- assertObject(f).json().is("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
- assertObject(g).json().is("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}");
- assertObject(h).json().is("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(b).json().is("[[[{a:1,b:'foo'},null],null],null]");
+ assertObject(c).json().is("[{a:1,b:'foo'},null]");
+ assertObject(d).json().is("[[[[{a:1,b:'foo'},null],null],null],null]");
+ assertObject(e).json().is("{foo:{a:1,b:'foo'}}");
+ assertObject(f).json().is("{foo:[{a:1,b:'foo'}]}");
+ assertObject(g).json().is("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}");
+ assertObject(h).json().is("{'1':[{a:1,b:'foo'}]}");
assertObject(a).isType(TypedBeanImpl.class);
assertObject(b[0][0][0]).isType(TypedBeanImpl.class);
@@ -1578,49 +1578,49 @@ public class ThirdPartyProxyResource extends BasicRestServletJena {
@RestMethod(name=POST, path="/setTypedBean")
public void setTypedBean(@Body TypedBean x) {
- assertObject(x).json().is("{_type:'TypedBeanImpl',a:1,b:'foo'}");
+ assertObject(x).json().is("{a:1,b:'foo'}");
assertObject(x).isType(TypedBeanImpl.class);
}
@RestMethod(name=POST, path="/setTypedBean3dArray")
public void setTypedBean3dArray(@Body TypedBean[][][] x) {
- assertObject(x).json().is("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]");
+ assertObject(x).json().is("[[[{a:1,b:'foo'},null],null],null]");
assertObject(x[0][0][0]).isType(TypedBeanImpl.class);
}
@RestMethod(name=POST, path="/setTypedBeanList")
public void setTypedBeanList(@Body List<TypedBean> x) {
- assertObject(x).json().is("[{_type:'TypedBeanImpl',a:1,b:'foo'}]");
+ assertObject(x).json().is("[{a:1,b:'foo'}]");
assertObject(x.get(0)).isType(TypedBeanImpl.class);
}
@RestMethod(name=POST, path="/setTypedBean1d3dList")
public void setTypedBean1d3dList(@Body List<TypedBean[][][]> x) {
- assertObject(x).json().is("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]");
+ assertObject(x).json().is("[[[[{a:1,b:'foo'},null],null],null],null]");
assertObject(x.get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@RestMethod(name=POST, path="/setTypedBeanMap")
public void setTypedBeanMap(@Body Map<String,TypedBean> x) {
- assertObject(x).json().is("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}");
+ assertObject(x).json().is("{foo:{a:1,b:'foo'}}");
assertObject(x.get("foo")).isType(TypedBeanImpl.class);
}
@RestMethod(name=POST, path="/setTypedBeanListMap")
public void setTypedBeanListMap(@Body Map<String,List<TypedBean>> x) {
- assertObject(x).json().is("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(x).json().is("{foo:[{a:1,b:'foo'}]}");
assertObject(x.get("foo").get(0)).isType(TypedBeanImpl.class);
}
@RestMethod(name=POST, path="/setTypedBean1d3dListMap")
public void setTypedBean1d3dListMap(@Body Map<String,List<TypedBean[][][]>> x) {
- assertObject(x).json().is("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}");
+ assertObject(x).json().is("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}");
assertObject(x.get("foo").get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@RestMethod(name=POST, path="/setTypedBeanListMapIntegerKeys")
public void setTypedBeanListMapIntegerKeys(@Body Map<Integer,List<TypedBean>> x) {
- assertObject(x).json().is("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}"); // Note: JsonSerializer serializes key as string.
+ assertObject(x).json().is("{'1':[{a:1,b:'foo'}]}"); // Note: JsonSerializer serializes key as string.
assertObject(x.get(1).get(0)).isType(TypedBeanImpl.class);
}
diff --git a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
index 7011c3e..3f2de02 100644
--- a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
+++ b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
@@ -665,49 +665,49 @@ public class ThirdPartyProxyTest extends RestTestcase {
@Test
public void dc01_returnTypedBean() {
TypedBean x = proxy.returnTypedBean();
- assertObject(x).json().is("{_type:'TypedBeanImpl',a:1,b:'foo'}");
+ assertObject(x).json().is("{a:1,b:'foo'}");
assertObject(x).isType(TypedBeanImpl.class);
}
@Test
public void dc02_returnTypedBean3dArray() {
TypedBean[][][] x = proxy.returnTypedBean3dArray();
- assertObject(x).json().is("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]");
+ assertObject(x).json().is("[[[{a:1,b:'foo'},null],null],null]");
assertObject(x[0][0][0]).isType(TypedBeanImpl.class);
}
@Test
public void dc03_returnTypedBeanList() {
List<TypedBean> x = proxy.returnTypedBeanList();
- assertObject(x).json().is("[{_type:'TypedBeanImpl',a:1,b:'foo'}]");
+ assertObject(x).json().is("[{a:1,b:'foo'}]");
assertObject(x.get(0)).isType(TypedBeanImpl.class);
}
@Test
public void dc04_returnTypedBean1d3dList() {
List<TypedBean[][][]> x = proxy.returnTypedBean1d3dList();
- assertObject(x).json().is("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]");
+ assertObject(x).json().is("[[[[{a:1,b:'foo'},null],null],null],null]");
assertObject(x.get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@Test
public void dc05_returnTypedBeanMap() {
Map<String,TypedBean> x = proxy.returnTypedBeanMap();
- assertObject(x).json().is("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}");
+ assertObject(x).json().is("{foo:{a:1,b:'foo'}}");
assertObject(x.get("foo")).isType(TypedBeanImpl.class);
}
@Test
public void dc06_returnTypedBeanListMap() {
Map<String,List<TypedBean>> x = proxy.returnTypedBeanListMap();
- assertObject(x).json().is("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(x).json().is("{foo:[{a:1,b:'foo'}]}");
assertObject(x.get("foo").get(0)).isType(TypedBeanImpl.class);
}
@Test
public void dc07_returnTypedBean1d3dListMap() {
Map<String,List<TypedBean[][][]>> x = proxy.returnTypedBean1d3dListMap();
- assertObject(x).json().is("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}");
+ assertObject(x).json().is("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}");
assertObject(x.get("foo").get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@@ -715,7 +715,7 @@ public class ThirdPartyProxyTest extends RestTestcase {
public void dc08_returnTypedBeanListMapIntegerKeys() {
// Note: JsonSerializer serializes key as string.
Map<Integer,List<TypedBean>> x = proxy.returnTypedBeanListMapIntegerKeys();
- assertObject(x).json().is("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(x).json().is("{'1':[{a:1,b:'foo'}]}");
assertObject(x.get(1).get(0)).isType(TypedBeanImpl.class);
}
diff --git a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Test.java b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Test.java
index 49cb30d..a283070 100644
--- a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Test.java
+++ b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Test.java
@@ -176,7 +176,7 @@ public class RestClient_Response_Test {
public void c03_response_headerAssertions() throws Exception {
checkFooClient(C.class).build().get().json().header("Foo","123").run().assertIntegerHeader("Foo").is(123);
checkFooClient(C.class).build().get().json().header("Foo","123").run().assertLongHeader("Foo").is(123l);
- checkFooClient(C.class).build().get().json().header(BasicDateHeader.of("Foo",CALENDAR)).run().assertDateHeader("Foo").equals(CALENDAR.getTime(), ChronoUnit.SECONDS);
+ checkFooClient(C.class).build().get().json().header(BasicDateHeader.of("Foo",CALENDAR)).run().assertDateHeader("Foo").isEqual(CALENDAR.getTime(), ChronoUnit.SECONDS);
checkClient(C.class,"Content-Type").build().get().json().header("Content-Type","application/json;charset=iso-8859-1").run().assertCharset().is("iso-8859-1");
checkClient(C.class,"Content-Type").build().get().json().header("Content-Type","application/json;charset=iso-8859-1").run().assertContentType().is("application/json;charset=iso-8859-1");
}
diff --git a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RrpcInterfaceTest.java b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RrpcInterfaceTest.java
index 22ea53e..c1a46c1 100644
--- a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RrpcInterfaceTest.java
+++ b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RrpcInterfaceTest.java
@@ -650,49 +650,49 @@ public class RrpcInterfaceTest {
@Override
public void setTypedBean(TypedBean x) {
- assertObject(x).json().is("{_type:'TypedBeanImpl',a:1,b:'foo'}");
+ assertObject(x).json().is("{a:1,b:'foo'}");
assertObject(x).isType(TypedBeanImpl.class);
}
@Override
public void setTypedBean3dArray(TypedBean[][][] x) {
- assertObject(x).json().is("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]");
+ assertObject(x).json().is("[[[{a:1,b:'foo'},null],null],null]");
assertObject(x[0][0][0]).isType(TypedBeanImpl.class);
}
@Override
public void setTypedBeanList(List<TypedBean> x) {
- assertObject(x).json().is("[{_type:'TypedBeanImpl',a:1,b:'foo'}]");
+ assertObject(x).json().is("[{a:1,b:'foo'}]");
assertObject(x.get(0)).isType(TypedBeanImpl.class);
}
@Override
public void setTypedBean1d3dList(List<TypedBean[][][]> x) {
- assertObject(x).json().is("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]");
+ assertObject(x).json().is("[[[[{a:1,b:'foo'},null],null],null],null]");
assertObject(x.get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@Override
public void setTypedBeanMap(Map<String,TypedBean> x) {
- assertObject(x).json().is("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}");
+ assertObject(x).json().is("{foo:{a:1,b:'foo'}}");
assertObject(x.get("foo")).isType(TypedBeanImpl.class);
}
@Override
public void setTypedBeanListMap(Map<String,List<TypedBean>> x) {
- assertObject(x).json().is("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(x).json().is("{foo:[{a:1,b:'foo'}]}");
assertObject(x.get("foo").get(0)).isType(TypedBeanImpl.class);
}
@Override
public void setTypedBean1d3dListMap(Map<String,List<TypedBean[][][]>> x) {
- assertObject(x).json().is("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}");
+ assertObject(x).json().is("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}");
assertObject(x.get("foo").get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@Override
public void setTypedBeanListMapIntegerKeys(Map<Integer,List<TypedBean>> x) {
- assertObject(x).json().is("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}"); // Note: JsonSerializer serializes key as string.
+ assertObject(x).json().is("{'1':[{a:1,b:'foo'}]}"); // Note: JsonSerializer serializes key as string.
assertObject(x.get(1).get(0)).isType(TypedBeanImpl.class);
}
@@ -1090,49 +1090,49 @@ public class RrpcInterfaceTest {
@Test
public void c01_returnTypedBean() {
TypedBean x = proxy.returnTypedBean();
- assertObject(x).json().is("{_type:'TypedBeanImpl',a:1,b:'foo'}");
+ assertObject(x).json().is("{a:1,b:'foo'}");
assertObject(x).isType(TypedBeanImpl.class);
}
@Test
public void c02_returnTypedBean3dArray() {
TypedBean[][][] x = proxy.returnTypedBean3dArray();
- assertObject(x).json().is("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]");
+ assertObject(x).json().is("[[[{a:1,b:'foo'},null],null],null]");
assertObject(x[0][0][0]).isType(TypedBeanImpl.class);
}
@Test
public void c03_returnTypedBeanList() {
List<TypedBean> x = proxy.returnTypedBeanList();
- assertObject(x).json().is("[{_type:'TypedBeanImpl',a:1,b:'foo'}]");
+ assertObject(x).json().is("[{a:1,b:'foo'}]");
assertObject(x.get(0)).isType(TypedBeanImpl.class);
}
@Test
public void c04_returnTypedBean1d3dList() {
List<TypedBean[][][]> x = proxy.returnTypedBean1d3dList();
- assertObject(x).json().is("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]");
+ assertObject(x).json().is("[[[[{a:1,b:'foo'},null],null],null],null]");
assertObject(x.get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@Test
public void c05_returnTypedBeanMap() {
Map<String,TypedBean> x = proxy.returnTypedBeanMap();
- assertObject(x).json().is("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}");
+ assertObject(x).json().is("{foo:{a:1,b:'foo'}}");
assertObject(x.get("foo")).isType(TypedBeanImpl.class);
}
@Test
public void c06_returnTypedBeanListMap() {
Map<String,List<TypedBean>> x = proxy.returnTypedBeanListMap();
- assertObject(x).json().is("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(x).json().is("{foo:[{a:1,b:'foo'}]}");
assertObject(x.get("foo").get(0)).isType(TypedBeanImpl.class);
}
@Test
public void c07_returnTypedBean1d3dListMap() {
Map<String,List<TypedBean[][][]>> x = proxy.returnTypedBean1d3dListMap();
- assertObject(x).json().is("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}");
+ assertObject(x).json().is("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}");
assertObject(x.get("foo").get(0)[0][0][0]).isType(TypedBeanImpl.class);
}
@@ -1140,7 +1140,7 @@ public class RrpcInterfaceTest {
public void c08_returnTypedBeanListMapIntegerKeys() {
// Note: JsonSerializer serializes key as string.
Map<Integer,List<TypedBean>> x = proxy.returnTypedBeanListMapIntegerKeys();
- assertObject(x).json().is("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}");
+ assertObject(x).json().is("{'1':[{a:1,b:'foo'}]}");
assertObject(x.get(1).get(0)).isType(TypedBeanImpl.class);
}