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.assertions;
018
019
020import java.io.*;
021import java.util.function.*;
022
023import org.apache.juneau.internal.*;
024import org.apache.juneau.serializer.*;
025
026/**
027 * Used for fluent assertion calls against integers.
028 *
029 * <h5 class='section'>Example:</h5>
030 * <p class='bjava'>
031 *    <jc>// Validates the response status code is 200 or 404.</jc>
032 *    <jv>client</jv>
033 *       .get(<jsf>URL</jsf>)
034 *       .run()
035 *       .assertStatus().isAny(200,404);
036 * </p>
037 *
038 *
039 * <h5 class='section'>Test Methods:</h5>
040 * <p>
041 * <ul class='javatree'>
042 *    <li class='jc'>{@link FluentComparableAssertion}
043 *    <ul class='javatreec'>
044 *       <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)}
045 *       <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)}
046 *       <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)}
047 *       <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)}
048 *       <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)}
049  *   </ul>
050 *    <li class='jc'>{@link FluentObjectAssertion}
051 *    <ul class='javatreec'>
052 *       <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()}
053 *       <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)}
054 *       <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)}
055 *       <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)}
056 *       <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)}
057 *       <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)}
058 *       <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()}
059 *       <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()}
060 *       <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)}
061 *       <li class='jm'>{@link FluentObjectAssertion#isJson(String) isJson(String)}
062 *       <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)}
063 *       <li class='jm'>{@link FluentObjectAssertion#isSameJsonAs(Object) isSameJsonAs(Object)}
064 *       <li class='jm'>{@link FluentObjectAssertion#isSameSortedJsonAs(Object) isSameSortedJsonAs(Object)}
065 *       <li class='jm'>{@link FluentObjectAssertion#isSameSerializedAs(Object, WriterSerializer) isSameSerializedAs(Object, WriterSerializer)}
066 *       <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)}
067 *       <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)}
068 *    </ul>
069 * </ul>
070 *
071 * <h5 class='section'>Transform Methods:</h5>
072 * <p>
073 * <ul class='javatree'>
074 *    <li class='jc'>{@link FluentObjectAssertion}
075 *    <ul class='javatreec'>
076 *       <li class='jm'>{@link FluentObjectAssertion#asString() asString()}
077 *       <li class='jm'>{@link FluentObjectAssertion#asString(WriterSerializer) asString(WriterSerializer)}
078 *       <li class='jm'>{@link FluentObjectAssertion#asString(Function) asString(Function)}
079 *       <li class='jm'>{@link FluentObjectAssertion#asJson() asJson()}
080 *       <li class='jm'>{@link FluentObjectAssertion#asJsonSorted() asJsonSorted()}
081 *       <li class='jm'>{@link FluentObjectAssertion#asTransformed(Function) asApplied(Function)}
082 *       <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()}
083 * </ul>
084 * </ul>
085 *
086 * <h5 class='section'>Configuration Methods:</h5>
087 * <p>
088 * <ul class='javatree'>
089 *    <li class='jc'>{@link Assertion}
090 *    <ul class='javatreec'>
091 *       <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)}
092 *       <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)}
093 *       <li class='jm'>{@link Assertion#setSilent() setSilent()}
094 *       <li class='jm'>{@link Assertion#setStdOut() setStdOut()}
095 *       <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)}
096 *    </ul>
097 * </ul>
098 *
099 * <h5 class='section'>See Also:</h5><ul>
100 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem Overview</a>
101 * </ul>
102 *
103 * @param <R> The return type.
104 */
105public class FluentIntegerAssertion<R> extends FluentComparableAssertion<Integer,R> {
106
107   //-----------------------------------------------------------------------------------------------------------------
108   // Instance
109   //-----------------------------------------------------------------------------------------------------------------
110
111   /**
112    * Constructor.
113    *
114    * @param value
115    *    The object being tested.
116    *    <br>Can be <jk>null</jk>.
117    * @param returns
118    *    The object to return after a test method is called.
119    *    <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be
120    * used on the same assertion.
121    */
122   public FluentIntegerAssertion(Integer value, R returns) {
123      this(null, value, returns);
124   }
125
126   /**
127    * Chained constructor.
128    *
129    * <p>
130    * Used when transforming one assertion into another so that the assertion config can be used by the new assertion.
131    *
132    * @param creator
133    *    The assertion that created this assertion.
134    *    <br>Should be <jk>null</jk> if this is the top-level assertion.
135    * @param value
136    *    The object being tested.
137    *    <br>Can be <jk>null</jk>.
138    * @param returns
139    *    The object to return after a test method is called.
140    *    <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be
141    * used on the same assertion.
142    */
143   public FluentIntegerAssertion(Assertion creator, Integer value, R returns) {
144      super(creator, value, returns);
145   }
146
147   //-----------------------------------------------------------------------------------------------------------------
148   // Fluent setters
149   //-----------------------------------------------------------------------------------------------------------------
150   @Override /* Overridden from Assertion */
151   public FluentIntegerAssertion<R> setMsg(String msg, Object...args) {
152      super.setMsg(msg, args);
153      return this;
154   }
155
156   @Override /* Overridden from Assertion */
157   public FluentIntegerAssertion<R> setOut(PrintStream value) {
158      super.setOut(value);
159      return this;
160   }
161
162   @Override /* Overridden from Assertion */
163   public FluentIntegerAssertion<R> setSilent() {
164      super.setSilent();
165      return this;
166   }
167
168   @Override /* Overridden from Assertion */
169   public FluentIntegerAssertion<R> setStdOut() {
170      super.setStdOut();
171      return this;
172   }
173
174   @Override /* Overridden from Assertion */
175   public FluentIntegerAssertion<R> setThrowable(Class<? extends java.lang.RuntimeException> value) {
176      super.setThrowable(value);
177      return this;
178   }
179}