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