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 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 * <jsm>assertInteger</jsm>(<jv>httpReponse</jv>).isAny(200,404); 030 * </p> 031 * 032 * <h5 class='section'>Test Methods:</h5> 033 * <p> 034 * <ul class='javatree'> 035 * <li class='jc'>{@link FluentComparableAssertion} 036 * <ul class='javatreec'> 037 * <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)} 038 * <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)} 039 * <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)} 040 * <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)} 041 * <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)} 042 * </ul> 043 * <li class='jc'>{@link FluentObjectAssertion} 044 * <ul class='javatreec'> 045 * <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()} 046 * <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)} 047 * <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)} 048 * <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)} 049 * <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)} 050 * <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)} 051 * <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()} 052 * <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()} 053 * <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)} 054 * <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)} 055 * <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)} 056 * <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} 057 * </ul> 058 * </ul> 059 * 060 * <h5 class='section'>Transform Methods:</h5> 061 * <p> 062 * <ul class='javatree'> 063 * <li class='jc'>{@link FluentObjectAssertion} 064 * <ul class='javatreec'> 065 * <li class='jm'>{@link FluentObjectAssertion#asString() asString()} 066 * <li class='jm'>{@link FluentObjectAssertion#asString(ThrowingFunction) asString(ThrowingFunction)} 067 * <li class='jm'>{@link FluentObjectAssertion#asTransformed(UnaryOperator) asTransformed(UnaryOperator)} 068 * <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()} 069 * </ul> 070 * </ul> 071 * 072 * <h5 class='section'>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="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem</a> 087 * </ul> 088 */ 089@SuppressWarnings({ 090 "java:S110" // Inheritance depth acceptable for IntegerAssertion hierarchy 091}) 092public class IntegerAssertion extends FluentIntegerAssertion<IntegerAssertion> { 093 094 /** 095 * Static creator. 096 * 097 * @param value 098 * The object being tested. 099 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 100 * @return A new assertion object. 101 */ 102 public static IntegerAssertion create(Integer value) { 103 return new IntegerAssertion(value); 104 } 105 106 /** 107 * Constructor. 108 * 109 * @param value 110 * The object being tested. 111 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 112 */ 113 public IntegerAssertion(Integer value) { 114 super(value, null); 115 } 116 117 @Override /* Overridden from Assertion */ 118 public IntegerAssertion setMsg(String msg, Object...args) { 119 super.setMsg(msg, args); 120 return this; 121 } 122 123 @Override /* Overridden from Assertion */ 124 public IntegerAssertion setOut(PrintStream value) { 125 super.setOut(value); 126 return this; 127 } 128 129 @Override /* Overridden from Assertion */ 130 public IntegerAssertion setSilent() { 131 super.setSilent(); 132 return this; 133 } 134 135 @Override /* Overridden from Assertion */ 136 public IntegerAssertion setStdOut() { 137 super.setStdOut(); 138 return this; 139 } 140 141 @Override /* Overridden from Assertion */ 142 public IntegerAssertion setThrowable(Class<? extends RuntimeException> value) { 143 super.setThrowable(value); 144 return this; 145 } 146}