001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.assertions;
014
015import java.io.*;
016import java.util.function.*;
017
018import org.apache.http.*;
019import org.apache.juneau.assertions.*;
020import org.apache.juneau.http.response.*;
021import org.apache.juneau.internal.*;
022import org.apache.juneau.serializer.*;
023
024/**
025 * Used for fluent assertion calls against {@link RequestLine} objects.
026 *
027 * <h5 class='topic'>Test Methods</h5>
028 * <p>
029 * <ul class='javatree'>
030 *    <li class='jc'>{@link FluentObjectAssertion}
031 *    <ul class='javatreec'>
032 *       <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()}
033 *       <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)}
034 *       <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)}
035 *       <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)}
036 *       <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)}
037 *       <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)}
038 *       <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()}
039 *       <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()}
040 *       <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)}
041 *       <li class='jm'>{@link FluentObjectAssertion#isJson(String) isJson(String)}
042 *       <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)}
043 *       <li class='jm'>{@link FluentObjectAssertion#isSameJsonAs(Object) isSameJsonAs(Object)}
044 *       <li class='jm'>{@link FluentObjectAssertion#isSameSortedJsonAs(Object) isSameSortedJsonAs(Object)}
045 *       <li class='jm'>{@link FluentObjectAssertion#isSameSerializedAs(Object, WriterSerializer) isSameSerializedAs(Object, WriterSerializer)}
046 *       <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)}
047 *       <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)}
048 *    </ul>
049 * </ul>
050 *
051 * <h5 class='topic'>Transform Methods</h5>
052 * <p>
053 * <ul class='javatree'>
054 *    <li class='jc'>{@link FluentRequestLineAssertion}
055 *    <ul class='javatreec'>
056 *       <li class='jm'>{@link FluentRequestLineAssertion#asMethod() asMethod()}
057 *       <li class='jm'>{@link FluentRequestLineAssertion#asUri() asUri()}
058 *       <li class='jm'>{@link FluentRequestLineAssertion#asProtocolVersion() asProtocolVersion()}
059 *    </ul>
060 *    <li class='jc'>{@link FluentObjectAssertion}
061 *    <ul class='javatreec'>
062 *       <li class='jm'>{@link FluentObjectAssertion#asString() asString()}
063 *       <li class='jm'>{@link FluentObjectAssertion#asString(WriterSerializer) asString(WriterSerializer)}
064 *       <li class='jm'>{@link FluentObjectAssertion#asString(Function) asString(Function)}
065 *       <li class='jm'>{@link FluentObjectAssertion#asJson() asJson()}
066 *       <li class='jm'>{@link FluentObjectAssertion#asJsonSorted() asJsonSorted()}
067 *       <li class='jm'>{@link FluentObjectAssertion#asTransformed(Function) asApplied(Function)}
068 *       <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()}
069 * </ul>
070 * </ul>
071 *
072 * <h5 class='topic'>Configuration Methods</h5>
073 * <p>
074 * <ul class='javatree'>
075 *    <li class='jc'>{@link Assertion}
076 *    <ul class='javatreec'>
077 *       <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)}
078 *       <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)}
079 *       <li class='jm'>{@link Assertion#setSilent() setSilent()}
080 *       <li class='jm'>{@link Assertion#setStdOut() setStdOut()}
081 *       <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)}
082 *    </ul>
083 * </ul>
084 *
085 * <h5 class='section'>See Also:</h5><ul>
086 *    <li class='link'><a class="doclink" href="../../../../../index.html#ja.Overview">juneau-assertions</a>
087 * </ul>
088 *
089 * @param <R> The return type.
090 */
091@FluentSetters(returns="FluentRequestLineAssertion<R>")
092public class FluentRequestLineAssertion<R> extends FluentObjectAssertion<RequestLine,R> {
093
094   //-----------------------------------------------------------------------------------------------------------------
095   // Constructors
096   //-----------------------------------------------------------------------------------------------------------------
097
098   /**
099    * Constructor.
100    *
101    * @param value
102    *    The object being tested.
103    *    <br>Can be <jk>null</jk>.
104    * @param returns
105    *    The object to return after a test method is called.
106    *    <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be
107    * used on the same assertion.
108    */
109   public FluentRequestLineAssertion(RequestLine value, R returns) {
110      this(null, value, returns);
111   }
112
113   /**
114    * Chained constructor.
115    *
116    * <p>
117    * Used when transforming one assertion into another so that the assertion config can be used by the new assertion.
118    *
119    * @param creator
120    *    The assertion that created this assertion.
121    *    <br>Should be <jk>null</jk> if this is the top-level assertion.
122    * @param value
123    *    The object being tested.
124    *    <br>Can be <jk>null</jk>.
125    * @param returns
126    *    The object to return after a test method is called.
127    *    <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be
128    * used on the same assertion.
129    */
130   public FluentRequestLineAssertion(Assertion creator, RequestLine value, R returns) {
131      super(creator, value, returns);
132      setThrowable(BadRequest.class);
133   }
134
135   //-----------------------------------------------------------------------------------------------------------------
136   // Transform methods
137   //-----------------------------------------------------------------------------------------------------------------
138
139   /**
140    * Returns the request line method string as a new assertion.
141    *
142    * @return A new assertion.
143    */
144   public FluentStringAssertion<R> asMethod() {
145      return new FluentStringAssertion<>(value().getMethod(), returns());
146   }
147
148   /**
149    * Returns the request line uri string as a new assertion.
150    *
151    * @return A new assertion.
152    */
153   public FluentStringAssertion<R> asUri() {
154      return new FluentStringAssertion<>(value().getUri(), returns());
155   }
156
157   /**
158    * Returns the request line protocol version as a new assertion.
159    *
160    * @return A new assertion.
161    */
162   public FluentProtocolVersionAssertion<R> asProtocolVersion() {
163      return new FluentProtocolVersionAssertion<>(value().getProtocolVersion(), returns());
164   }
165
166   //-----------------------------------------------------------------------------------------------------------------
167   // Fluent setters
168   //-----------------------------------------------------------------------------------------------------------------
169
170   // <FluentSetters>
171
172   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
173   public FluentRequestLineAssertion<R> setMsg(String msg, Object...args) {
174      super.setMsg(msg, args);
175      return this;
176   }
177
178   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
179   public FluentRequestLineAssertion<R> setOut(PrintStream value) {
180      super.setOut(value);
181      return this;
182   }
183
184   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
185   public FluentRequestLineAssertion<R> setSilent() {
186      super.setSilent();
187      return this;
188   }
189
190   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
191   public FluentRequestLineAssertion<R> setStdOut() {
192      super.setStdOut();
193      return this;
194   }
195
196   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
197   public FluentRequestLineAssertion<R> setThrowable(Class<? extends java.lang.RuntimeException> value) {
198      super.setThrowable(value);
199      return this;
200   }
201
202   // </FluentSetters>
203}