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