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 * <h2 class='section'>Example:</h2>
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 * <h2 class='section'>Test Methods:</h2>
037 * <ul class='javatree'>
038 *    <li class='jc'>{@link FluentComparableAssertion}
039 *    <ul class='javatreec'>
040 *       <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)}
041 *       <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)}
042 *       <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)}
043 *       <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)}
044 *       <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)}
045  *   </ul>
046 *    <li class='jc'>{@link FluentObjectAssertion}
047 *    <ul class='javatreec'>
048 *       <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()}
049 *       <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)}
050 *       <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)}
051 *       <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)}
052 *       <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)}
053 *       <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)}
054 *       <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()}
055 *       <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()}
056 *       <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)}
057 *       <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)}
058 *       <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)}
059 *       <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)}
060 *    </ul>
061 * </ul>
062 *
063 * <h2 class='section'>Transform Methods:</h2>
064 * <ul class='javatree'>
065 *    <li class='jc'>{@link FluentObjectAssertion}
066 *    <ul class='javatreec'>
067 *       <li class='jm'>{@link FluentObjectAssertion#asString() asString()}
068 *       <li class='jm'>{@link FluentObjectAssertion#asString(ThrowingFunction) asString(ThrowingFunction)}
069 *       <li class='jm'>{@link FluentObjectAssertion#asTransformed(UnaryOperator) asTransformed(UnaryOperator)}
070 *       <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()}
071 * </ul>
072 * </ul>
073 *
074 * <h2 class='section'>Configuration Methods:</h2>
075 * <ul class='javatree'>
076 *    <li class='jc'>{@link Assertion}
077 *    <ul class='javatreec'>
078 *       <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)}
079 *       <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)}
080 *       <li class='jm'>{@link Assertion#setSilent() setSilent()}
081 *       <li class='jm'>{@link Assertion#setStdOut() setStdOut()}
082 *       <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)}
083 *    </ul>
084 * </ul>
085 *
086 * <h2 class='section'>See Also:</h2><ul>
087 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem</a>
088 * </ul>
089 *
090 * @param <R> The return type.
091 */
092public class FluentIntegerAssertion<R> extends FluentComparableAssertion<Integer,R> {
093
094   /**
095    * Chained constructor.
096    *
097    * <p>
098    * Used when transforming one assertion into another so that the assertion config can be used by the new assertion.
099    *
100    * @param creator
101    *    The assertion that created this assertion.
102    *    <br>Should be <jk>null</jk> if this is the top-level assertion.
103    * @param value
104    *    The object being tested.
105    *    <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value).
106    * @param returns
107    *    The object to return after a test method is called.
108    *    <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be
109    * used on the same assertion.
110    */
111   public FluentIntegerAssertion(Assertion creator, Integer value, R returns) {
112      super(creator, value, returns);
113   }
114
115   /**
116    * Constructor.
117    *
118    * @param value
119    *    The object being tested.
120    *    <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value).
121    * @param returns
122    *    The object to return after a test method is called.
123    *    <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be
124    * used on the same assertion.
125    */
126   public FluentIntegerAssertion(Integer value, R returns) {
127      this(null, value, returns);
128   }
129
130   @Override /* Overridden from Assertion */
131   public FluentIntegerAssertion<R> setMsg(String msg, Object...args) {
132      super.setMsg(msg, args);
133      return this;
134   }
135
136   @Override /* Overridden from Assertion */
137   public FluentIntegerAssertion<R> setOut(PrintStream value) {
138      super.setOut(value);
139      return this;
140   }
141
142   @Override /* Overridden from Assertion */
143   public FluentIntegerAssertion<R> setSilent() {
144      super.setSilent();
145      return this;
146   }
147
148   @Override /* Overridden from Assertion */
149   public FluentIntegerAssertion<R> setStdOut() {
150      super.setStdOut();
151      return this;
152   }
153
154   @Override /* Overridden from Assertion */
155   public FluentIntegerAssertion<R> setThrowable(Class<? extends RuntimeException> value) {
156      super.setThrowable(value);
157      return this;
158   }
159}