001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.bct.assertions;
018
019import java.io.*;
020import java.util.function.*;
021
022
023/**
024 * Used for fluent assertion calls against integers.
025 *
026 * <h5 class='section'>Example:</h5>
027 * <p class='bjava'>
028 *    <jc>// Validates the response status code is 200 or 404.</jc>
029 *    <jv>client</jv>
030 *       .get(<jsf>URL</jsf>)
031 *       .run()
032 *       .assertStatus().isAny(200,404);
033 * </p>
034 *
035 *
036 * <h5 class='section'>Test Methods:</h5>
037 * <p>
038 * <ul class='javatree'>
039 *    <li class='jc'>{@link FluentComparableAssertion}
040 *    <ul class='javatreec'>
041 *       <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)}
042 *       <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)}
043 *       <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)}
044 *       <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)}
045 *       <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)}
046  *   </ul>
047 *    <li class='jc'>{@link FluentObjectAssertion}
048 *    <ul class='javatreec'>
049 *       <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()}
050 *       <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)}
051 *       <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)}
052 *       <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)}
053 *       <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)}
054 *       <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)}
055 *       <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()}
056 *       <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()}
057 *       <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)}
058 *       <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)}
059 *       <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)}
060 *       <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)}
061 *    </ul>
062 * </ul>
063 *
064 * <h5 class='section'>Transform Methods:</h5>
065 * <p>
066 * <ul class='javatree'>
067 *    <li class='jc'>{@link FluentObjectAssertion}
068 *    <ul class='javatreec'>
069 *       <li class='jm'>{@link FluentObjectAssertion#asString() asString()}
070 *       <li class='jm'>{@link FluentObjectAssertion#asString(ThrowingFunction) asString(ThrowingFunction)}
071 *       <li class='jm'>{@link FluentObjectAssertion#asTransformed(UnaryOperator) asTransformed(UnaryOperator)}
072 *       <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()}
073 * </ul>
074 * </ul>
075 *
076 * <h5 class='section'>Configuration Methods:</h5>
077 * <p>
078 * <ul class='javatree'>
079 *    <li class='jc'>{@link Assertion}
080 *    <ul class='javatreec'>
081 *       <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)}
082 *       <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)}
083 *       <li class='jm'>{@link Assertion#setSilent() setSilent()}
084 *       <li class='jm'>{@link Assertion#setStdOut() setStdOut()}
085 *       <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)}
086 *    </ul>
087 * </ul>
088 *
089 * <h5 class='section'>See Also:</h5><ul>
090 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem</a>
091 * </ul>
092 *
093 * @param <R> The return type.
094 */
095public class FluentIntegerAssertion<R> extends FluentComparableAssertion<Integer,R> {
096
097   /**
098    * Chained constructor.
099    *
100    * <p>
101    * Used when transforming one assertion into another so that the assertion config can be used by the new assertion.
102    *
103    * @param creator
104    *    The assertion that created this assertion.
105    *    <br>Should be <jk>null</jk> if this is the top-level assertion.
106    * @param value
107    *    The object being tested.
108    *    <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value).
109    * @param returns
110    *    The object to return after a test method is called.
111    *    <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be
112    * used on the same assertion.
113    */
114   public FluentIntegerAssertion(Assertion creator, Integer value, R returns) {
115      super(creator, value, returns);
116   }
117
118   /**
119    * Constructor.
120    *
121    * @param value
122    *    The object being tested.
123    *    <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value).
124    * @param returns
125    *    The object to return after a test method is called.
126    *    <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be
127    * used on the same assertion.
128    */
129   public FluentIntegerAssertion(Integer value, R returns) {
130      this(null, value, returns);
131   }
132
133   @Override /* Overridden from Assertion */
134   public FluentIntegerAssertion<R> setMsg(String msg, Object...args) {
135      super.setMsg(msg, args);
136      return this;
137   }
138
139   @Override /* Overridden from Assertion */
140   public FluentIntegerAssertion<R> setOut(PrintStream value) {
141      super.setOut(value);
142      return this;
143   }
144
145   @Override /* Overridden from Assertion */
146   public FluentIntegerAssertion<R> setSilent() {
147      super.setSilent();
148      return this;
149   }
150
151   @Override /* Overridden from Assertion */
152   public FluentIntegerAssertion<R> setStdOut() {
153      super.setStdOut();
154      return this;
155   }
156
157   @Override /* Overridden from Assertion */
158   public FluentIntegerAssertion<R> setThrowable(Class<? extends RuntimeException> value) {
159      super.setThrowable(value);
160      return this;
161   }
162}