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