001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.assertions; 014 015 016import java.io.*; 017import java.util.function.*; 018 019import org.apache.juneau.internal.*; 020import org.apache.juneau.serializer.*; 021 022/** 023 * Used for fluent assertion calls against longs. 024 * 025 * <h5 class='section'>Example:</h5> 026 * <p class='bjava'> 027 * <jc>// Validates the response length isn't too long.</jc> 028 * <jv>client</jv> 029 * .get(<jsf>URL</jsf>) 030 * .run() 031 * .assertLongHeader(<js>"Length"</js>).isLessThan(100000); 032 * </p> 033 * 034 * 035 * <h5 class='section'>Test Methods:</h5> 036 * <p> 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#isJson(String) isJson(String)} 058 * <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)} 059 * <li class='jm'>{@link FluentObjectAssertion#isSameJsonAs(Object) isSameJsonAs(Object)} 060 * <li class='jm'>{@link FluentObjectAssertion#isSameSortedJsonAs(Object) isSameSortedJsonAs(Object)} 061 * <li class='jm'>{@link FluentObjectAssertion#isSameSerializedAs(Object, WriterSerializer) isSameSerializedAs(Object, WriterSerializer)} 062 * <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)} 063 * <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} 064 * </ul> 065 * </ul> 066 * 067 * <h5 class='section'>Transform Methods:</h5> 068 * <p> 069 * <ul class='javatree'> 070 * <li class='jc'>{@link FluentLongAssertion} 071 * <ul class='javatreec'> 072 * <li class='jm'>{@link FluentLongAssertion#asInteger() asInteger()} 073 * </ul> 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="../../../../index.html#ja.Overview">Overview > juneau-assertions > Overview</a> 101 * </ul> 102 * 103 * @param <R> The return type. 104 */ 105@FluentSetters(returns="FluentLongAssertion<R>") 106public class FluentLongAssertion<R> extends FluentComparableAssertion<Long,R> { 107 108 //----------------------------------------------------------------------------------------------------------------- 109 // Instance 110 //----------------------------------------------------------------------------------------------------------------- 111 112 /** 113 * Constructor. 114 * 115 * @param value 116 * The object being tested. 117 * <br>Can be <jk>null</jk>. 118 * @param returns 119 * The object to return after a test method is called. 120 * <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be 121 * used on the same assertion. 122 */ 123 public FluentLongAssertion(Long value, R returns) { 124 this(null, value, returns); 125 } 126 127 /** 128 * Chained constructor. 129 * 130 * <p> 131 * Used when transforming one assertion into another so that the assertion config can be used by the new assertion. 132 * 133 * @param creator 134 * The assertion that created this assertion. 135 * <br>Should be <jk>null</jk> if this is the top-level assertion. 136 * @param value 137 * The object being tested. 138 * <br>Can be <jk>null</jk>. 139 * @param returns 140 * The object to return after a test method is called. 141 * <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be 142 * used on the same assertion. 143 */ 144 public FluentLongAssertion(Assertion creator, Long value, R returns) { 145 super(creator, value, returns); 146 } 147 148 //----------------------------------------------------------------------------------------------------------------- 149 // Transform methods 150 //----------------------------------------------------------------------------------------------------------------- 151 152 /** 153 * Converts this long into an integer and then returns it as an integer assertion. 154 * 155 * @return A new assertion. 156 */ 157 public FluentIntegerAssertion<R> asInteger() { 158 return new FluentIntegerAssertion<>(this, map(Long::intValue).orElse(null), returns()); 159 } 160 161 //----------------------------------------------------------------------------------------------------------------- 162 // Fluent setters 163 //----------------------------------------------------------------------------------------------------------------- 164 165 // <FluentSetters> 166 167 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 168 public FluentLongAssertion<R> setMsg(String msg, Object...args) { 169 super.setMsg(msg, args); 170 return this; 171 } 172 173 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 174 public FluentLongAssertion<R> setOut(PrintStream value) { 175 super.setOut(value); 176 return this; 177 } 178 179 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 180 public FluentLongAssertion<R> setSilent() { 181 super.setSilent(); 182 return this; 183 } 184 185 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 186 public FluentLongAssertion<R> setStdOut() { 187 super.setStdOut(); 188 return this; 189 } 190 191 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 192 public FluentLongAssertion<R> setThrowable(Class<? extends java.lang.RuntimeException> value) { 193 super.setThrowable(value); 194 return this; 195 } 196 197 // </FluentSetters> 198}