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 2d2f41011 REST part improvements.
2d2f41011 is described below
commit 2d2f410117d37f303c79f920e41b051e3fd61cfe
Author: JamesBognar <[email protected]>
AuthorDate: Wed Aug 17 09:43:08 2022 -0400
REST part improvements.
---
.../juneau/rest/httppart/RequestFormParam.java | 94 ----------------------
.../apache/juneau/rest/httppart/RequestHeader.java | 94 ----------------------
.../juneau/rest/httppart/RequestHttpPart.java | 90 +++++++++++++++++++++
.../juneau/rest/httppart/RequestPathParam.java | 94 ----------------------
.../juneau/rest/httppart/RequestPathParams.java | 4 -
.../juneau/rest/httppart/RequestQueryParam.java | 90 ---------------------
6 files changed, 90 insertions(+), 376 deletions(-)
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestFormParam.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestFormParam.java
index b790a71dc..3cc75338f 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestFormParam.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestFormParam.java
@@ -21,7 +21,6 @@ import java.util.regex.*;
import org.apache.http.*;
import org.apache.juneau.*;
-import org.apache.juneau.assertions.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.rest.*;
@@ -148,99 +147,6 @@ public class RequestFormParam extends RequestHttpPart
implements NameValuePair {
return this;
}
-
//------------------------------------------------------------------------------------------------------------------
- // Assertions
-
//------------------------------------------------------------------------------------------------------------------
-
- /**
- * Provides the ability to perform fluent-style assertions on this
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getFormParam(<js>"foo"</js>)
- * .assertString().contains(<js>"bar"</js>);
- * </p>
- *
- * <p>
- * The assertion test returns the original object allowing you to chain
multiple requests like so:
- * <p class='bjava'>
- * String <jv>foo</jv> = <jv>request</jv>
- * .getFormParam(<js>"foo"</js>)
- * .assertString().contains(<js>"bar"</js>)
- * .asString().get();
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentStringAssertion<RequestFormParam> assertString() {
- return new FluentStringAssertion<>(orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on an
integer parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getFormParam(<js>"age"</js>)
- * .assertInteger().isGreaterThan(1);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentIntegerAssertion<RequestFormParam> assertInteger() {
- return new
FluentIntegerAssertion<>(asIntegerPart().asInteger().orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on a long
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getFormParam(<js>"length"</js>)
- * .assertLong().isLessThan(100000);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentLongAssertion<RequestFormParam> assertLong() {
- return new
FluentLongAssertion<>(asLongPart().asLong().orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on a date
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getFormParam(<js>"time"</js>)
- * .assertDate().isAfterNow();
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentZonedDateTimeAssertion<RequestFormParam> assertDate() {
- return new
FluentZonedDateTimeAssertion<>(asDatePart().asZonedDateTime().orElse(null),
this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on
comma-separated string parameters.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getFormParam(<js>"allow"</js>)
- * .assertCsvArray().contains(<js>"GET"</js>);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentListAssertion<String,RequestFormParam> assertCsvArray() {
- return new FluentListAssertion<>(asCsvArrayPart().toList(),
this);
- }
-
// <FluentSetters>
@Override /* GENERATED */
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHeader.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHeader.java
index ad147958c..0547a3f9a 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHeader.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHeader.java
@@ -19,7 +19,6 @@ import java.util.regex.*;
import org.apache.http.*;
import org.apache.juneau.*;
-import org.apache.juneau.assertions.*;
import org.apache.juneau.http.header.*;
import org.apache.juneau.http.response.BasicHttpException;
import org.apache.juneau.httppart.*;
@@ -220,99 +219,6 @@ public class RequestHeader extends RequestHttpPart
implements Header {
return new BasicUriHeader(getName(), getValue());
}
-
//------------------------------------------------------------------------------------------------------------------
- // Assertions
-
//------------------------------------------------------------------------------------------------------------------
-
- /**
- * Provides the ability to perform fluent-style assertions on this
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getHeader(<js>"foo"</js>)
- * .assertString().contains(<js>"bar"</js>);
- * </p>
- *
- * <p>
- * The assertion test returns the original object allowing you to chain
multiple requests like so:
- * <p class='bjava'>
- * String <jv>foo</jv> = <jv>request</jv>
- * .getHeader(<js>"foo"</js>)
- * .assertString().contains(<js>"bar"</js>)
- * .asString().get();
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentStringAssertion<RequestHeader> assertString() {
- return new FluentStringAssertion<>(orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on an
integer parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getHeader(<js>"age"</js>)
- * .assertInteger().isGreaterThan(1);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentIntegerAssertion<RequestHeader> assertInteger() {
- return new
FluentIntegerAssertion<>(asIntegerPart().asInteger().orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on a long
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getHeader(<js>"length"</js>)
- * .assertLong().isLessThan(100000);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentLongAssertion<RequestHeader> assertLong() {
- return new
FluentLongAssertion<>(asLongPart().asLong().orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on a date
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getHeader(<js>"time"</js>)
- * .assertDate().isAfterNow();
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentZonedDateTimeAssertion<RequestHeader> assertDate() {
- return new
FluentZonedDateTimeAssertion<>(asDatePart().asZonedDateTime().orElse(null),
this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on
comma-separated string parameters.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getHeader(<js>"allow"</js>)
- * .assertCsvArray().contains(<js>"GET"</js>);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentListAssertion<String,RequestHeader> assertCsvArray() {
- return new
FluentListAssertion<>(asCsvArrayPart().asList().orElse(null), this);
- }
-
/**
* Parses the value.
*
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHttpPart.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHttpPart.java
index bb6881f74..19dea2af8 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHttpPart.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestHttpPart.java
@@ -22,6 +22,7 @@ import java.util.regex.*;
import org.apache.http.*;
import org.apache.juneau.*;
+import org.apache.juneau.assertions.*;
import org.apache.juneau.http.*;
import org.apache.juneau.http.part.*;
import org.apache.juneau.http.response.*;
@@ -414,6 +415,95 @@ public abstract class RequestHttpPart {
// Assertions
//------------------------------------------------------------------------------------------------------------------
+ /**
+ * Provides the ability to perform fluent-style assertions on this
parameter.
+ *
+ * <h5 class='section'>Examples:</h5>
+ * <p class='bjava'>
+ * <jv>request</jv>
+ * .getQueryParam(<js>"foo"</js>)
+ * .assertString().contains(<js>"bar"</js>);
+ * </p>
+ *
+ * <p>
+ * The assertion test returns the original object allowing you to chain
multiple requests like so:
+ * <p class='bjava'>
+ * String <jv>foo</jv> = <jv>request</jv>
+ * .getQueryParam(<js>"foo"</js>)
+ * .assertString().contains(<js>"bar"</js>)
+ * .asString().get();
+ * </p>
+ *
+ * @return A new fluent assertion object.
+ */
+ public FluentStringAssertion<RequestHttpPart> assertString() {
+ return new FluentStringAssertion<>(orElse(null), this);
+ }
+
+ /**
+ * Provides the ability to perform fluent-style assertions on an
integer parameter.
+ *
+ * <h5 class='section'>Examples:</h5>
+ * <p class='bjava'>
+ * <jv>request</jv>
+ * .getQueryParam(<js>"age"</js>)
+ * .assertInteger().isGreaterThan(1);
+ * </p>
+ *
+ * @return A new fluent assertion object.
+ */
+ public FluentIntegerAssertion<RequestHttpPart> assertInteger() {
+ return new
FluentIntegerAssertion<>(asIntegerPart().asInteger().orElse(null), this);
+ }
+
+ /**
+ * Provides the ability to perform fluent-style assertions on a long
parameter.
+ *
+ * <h5 class='section'>Examples:</h5>
+ * <p class='bjava'>
+ * <jv>request</jv>
+ * .getQueryParam(<js>"length"</js>)
+ * .assertLong().isLessThan(100000);
+ * </p>
+ *
+ * @return A new fluent assertion object.
+ */
+ public FluentLongAssertion<RequestHttpPart> assertLong() {
+ return new
FluentLongAssertion<>(asLongPart().asLong().orElse(null), this);
+ }
+
+ /**
+ * Provides the ability to perform fluent-style assertions on a date
parameter.
+ *
+ * <h5 class='section'>Examples:</h5>
+ * <p class='bjava'>
+ * <jv>request</jv>
+ * .getQueryParam(<js>"time"</js>)
+ * .assertDate().isAfterNow();
+ * </p>
+ *
+ * @return A new fluent assertion object.
+ */
+ public FluentZonedDateTimeAssertion<RequestHttpPart> assertDate() {
+ return new
FluentZonedDateTimeAssertion<>(asDatePart().asZonedDateTime().orElse(null),
this);
+ }
+
+ /**
+ * Provides the ability to perform fluent-style assertions on
comma-separated string parameters.
+ *
+ * <h5 class='section'>Examples:</h5>
+ * <p class='bjava'>
+ * <jv>request</jv>
+ * .getQueryParam(<js>"allow"</js>)
+ * .assertCsvArray().contains(<js>"GET"</js>);
+ * </p>
+ *
+ * @return A new fluent assertion object.
+ */
+ public FluentListAssertion<String,RequestHttpPart> assertCsvArray() {
+ return new
FluentListAssertion<>(asCsvArrayPart().asList().orElse(null), this);
+ }
+
/**
* Returns the request that created this part.
*
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestPathParam.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestPathParam.java
index 74289917c..305212dbd 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestPathParam.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestPathParam.java
@@ -19,7 +19,6 @@ import java.util.regex.*;
import org.apache.http.*;
import org.apache.juneau.*;
-import org.apache.juneau.assertions.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.rest.*;
@@ -125,99 +124,6 @@ public class RequestPathParam extends RequestHttpPart
implements NameValuePair {
return value;
}
-
//------------------------------------------------------------------------------------------------------------------
- // Assertions
-
//------------------------------------------------------------------------------------------------------------------
-
- /**
- * Provides the ability to perform fluent-style assertions on this
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getPathParam(<js>"foo"</js>)
- * .assertString().contains(<js>"bar"</js>);
- * </p>
- *
- * <p>
- * The assertion test returns the original object allowing you to chain
multiple requests like so:
- * <p class='bjava'>
- * String <jv>foo</jv> = <jv>request</jv>
- * .getPathParam(<js>"foo"</js>)
- * .assertString().contains(<js>"bar"</js>)
- * .asString().get();
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentStringAssertion<RequestPathParam> assertString() {
- return new FluentStringAssertion<>(orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on an
integer parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getPathParam(<js>"age"</js>)
- * .assertInteger().isGreaterThan(1);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentIntegerAssertion<RequestPathParam> assertInteger() {
- return new
FluentIntegerAssertion<>(asIntegerPart().asInteger().orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on a long
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getPathParam(<js>"length"</js>)
- * .assertLong().isLessThan(100000);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentLongAssertion<RequestPathParam> assertLong() {
- return new
FluentLongAssertion<>(asLongPart().asLong().orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on a date
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getPathParam(<js>"time"</js>)
- * .assertDate().isAfterNow();
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentZonedDateTimeAssertion<RequestPathParam> assertDate() {
- return new
FluentZonedDateTimeAssertion<>(asDatePart().asZonedDateTime().orElse(null),
this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on
comma-separated string parameters.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getPathParam(<js>"allow"</js>)
- * .assertCsvArray().contains(<js>"GET"</js>);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentListAssertion<String,RequestPathParam> assertCsvArray() {
- return new
FluentListAssertion<>(asCsvArrayPart().asList().orElse(null), this);
- }
-
// <FluentSetters>
@Override /* GENERATED */
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestPathParams.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestPathParams.java
index b152e5d8b..838b92727 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestPathParams.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestPathParams.java
@@ -105,7 +105,6 @@ public class RequestPathParams extends
ArrayList<RequestPathParam> {
private static final long serialVersionUID = 1L;
- private final RestSession session;
private final RestRequest req;
private boolean caseSensitive;
private HttpPartParserSession parser;
@@ -119,7 +118,6 @@ public class RequestPathParams extends
ArrayList<RequestPathParam> {
* @param caseSensitive Whether case-sensitive name matching is enabled.
*/
public RequestPathParams(RestSession session, RestRequest req, boolean
caseSensitive) {
- this.session = session;
this.req = req;
this.caseSensitive = caseSensitive;
this.vs = req.getVarResolverSession();
@@ -146,7 +144,6 @@ public class RequestPathParams extends
ArrayList<RequestPathParam> {
* Copy constructor.
*/
private RequestPathParams(RequestPathParams copyFrom) {
- session = copyFrom.session;
req = copyFrom.req;
caseSensitive = copyFrom.caseSensitive;
parser = copyFrom.parser;
@@ -159,7 +156,6 @@ public class RequestPathParams extends
ArrayList<RequestPathParam> {
*/
private RequestPathParams(RequestPathParams copyFrom, String...names) {
this.req = copyFrom.req;
- this.session = copyFrom.session;
caseSensitive = copyFrom.caseSensitive;
parser = copyFrom.parser;
vs = copyFrom.vs;
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestQueryParam.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestQueryParam.java
index 5c1b8e09c..4f7708957 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestQueryParam.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/httppart/RequestQueryParam.java
@@ -19,7 +19,6 @@ import java.util.regex.*;
import org.apache.http.*;
import org.apache.juneau.*;
-import org.apache.juneau.assertions.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.rest.*;
@@ -129,95 +128,6 @@ public class RequestQueryParam extends RequestHttpPart
implements NameValuePair
// Assertions
//------------------------------------------------------------------------------------------------------------------
- /**
- * Provides the ability to perform fluent-style assertions on this
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getQueryParam(<js>"foo"</js>)
- * .assertString().contains(<js>"bar"</js>);
- * </p>
- *
- * <p>
- * The assertion test returns the original object allowing you to chain
multiple requests like so:
- * <p class='bjava'>
- * String <jv>foo</jv> = <jv>request</jv>
- * .getQueryParam(<js>"foo"</js>)
- * .assertString().contains(<js>"bar"</js>)
- * .asString().get();
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentStringAssertion<RequestQueryParam> assertString() {
- return new FluentStringAssertion<>(orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on an
integer parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getQueryParam(<js>"age"</js>)
- * .assertInteger().isGreaterThan(1);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentIntegerAssertion<RequestQueryParam> assertInteger() {
- return new
FluentIntegerAssertion<>(asIntegerPart().asInteger().orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on a long
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getQueryParam(<js>"length"</js>)
- * .assertLong().isLessThan(100000);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentLongAssertion<RequestQueryParam> assertLong() {
- return new
FluentLongAssertion<>(asLongPart().asLong().orElse(null), this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on a date
parameter.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getQueryParam(<js>"time"</js>)
- * .assertDate().isAfterNow();
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentZonedDateTimeAssertion<RequestQueryParam> assertDate() {
- return new
FluentZonedDateTimeAssertion<>(asDatePart().asZonedDateTime().orElse(null),
this);
- }
-
- /**
- * Provides the ability to perform fluent-style assertions on
comma-separated string parameters.
- *
- * <h5 class='section'>Examples:</h5>
- * <p class='bjava'>
- * <jv>request</jv>
- * .getQueryParam(<js>"allow"</js>)
- * .assertCsvArray().contains(<js>"GET"</js>);
- * </p>
- *
- * @return A new fluent assertion object.
- */
- public FluentListAssertion<String,RequestQueryParam> assertCsvArray() {
- return new
FluentListAssertion<>(asCsvArrayPart().asList().orElse(null), this);
- }
-
// <FluentSetters>
@Override /* GENERATED */