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 015import java.io.*; 016import java.util.*; 017import java.util.function.*; 018 019import org.apache.juneau.internal.*; 020import org.apache.juneau.serializer.*; 021 022/** 023 * Used for assertion calls against arrays. 024 * 025 * <h5 class='section'>Example:</h5> 026 * <p class='bjava'> 027 * <jk>import static</jk> org.apache.juneau.assertions.Assertions.*; 028 * 029 * String[] <jv>array</jv> = {<js>"foo"</js>}; 030 * <jsm>assertArray</jsm>(<jv>array</jv>).exists().isSize(1); 031 * </p> 032 * 033 * <h5 class='topic'>Test Methods</h5> 034 * <ul class='javatree'> 035 * <li class='jc'>{@link FluentArrayAssertion} 036 * <ul class='javatreec'> 037 * <li class='jm'>{@link FluentArrayAssertion#isHas(Object[]) isHas(Object[])} 038 * <li class='jm'>{@link FluentArrayAssertion#is(Predicate) is(Predicate)} 039 * <li class='jm'>{@link FluentArrayAssertion#isAny(Predicate) isAny(Predicate)} 040 * <li class='jm'>{@link FluentArrayAssertion#isAll(Predicate) isAll(Predicate)} 041 * <li class='jm'>{@link FluentArrayAssertion#isEmpty() isEmpty()} 042 * <li class='jm'>{@link FluentArrayAssertion#isNotEmpty() isNotEmpty()} 043 * <li class='jm'>{@link FluentArrayAssertion#isSize(int) isSize(int)} 044 * <li class='jm'>{@link FluentArrayAssertion#isContains(Object) isContains(Object)} 045 * <li class='jm'>{@link FluentArrayAssertion#isNotContains(Object) isNotContains(Object)} 046 * </ul> 047 * <li class='jc'>{@link FluentObjectAssertion} 048 * <ul class='javatreec'> 049 * <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()} 050 * <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)} 051 * <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)} 052 * <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)} 053 * <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)} 054 * <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)} 055 * <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()} 056 * <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()} 057 * <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)} 058 * <li class='jm'>{@link FluentObjectAssertion#isJson(String) isJson(String)} 059 * <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)} 060 * <li class='jm'>{@link FluentObjectAssertion#isSameJsonAs(Object) isSameJsonAs(Object)} 061 * <li class='jm'>{@link FluentObjectAssertion#isSameSortedJsonAs(Object) isSameSortedJsonAs(Object)} 062 * <li class='jm'>{@link FluentObjectAssertion#isSameSerializedAs(Object, WriterSerializer) isSameSerializedAs(Object, WriterSerializer)} 063 * <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)} 064 * <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} 065 * </ul> 066 * </ul> 067 * 068 * <h5 class='topic'>Transform Methods</h5> 069 * <p> 070 * <ul class='javatree'> 071 * <li class='jc'>{@link FluentArrayAssertion} 072 * <ul class='javatreec'> 073 * <li class='jm'>{@link FluentArrayAssertion#asStrings() asStrings()} 074 * <li class='jm'>{@link FluentArrayAssertion#asStrings(Function) asStrings(Function)} 075 * <li class='jm'>{@link FluentArrayAssertion#asCdl() asCdl()} 076 * <li class='jm'>{@link FluentArrayAssertion#asCdl(Function) asCdl(Function)} 077 * <li class='jm'>{@link FluentArrayAssertion#asBeanList() asBeanList()} 078 * <li class='jm'>{@link FluentArrayAssertion#asItem(int) asItem(int)} 079 * <li class='jm'>{@link FluentArrayAssertion#asSorted() asSorted()} 080 * <li class='jm'>{@link FluentArrayAssertion#asSorted(Comparator) asSorted(Comparator)} 081 * </ul> 082 * <li class='jc'>{@link FluentObjectAssertion} 083 * <ul class='javatreec'> 084 * <li class='jm'>{@link FluentObjectAssertion#asString() asString()} 085 * <li class='jm'>{@link FluentObjectAssertion#asString(WriterSerializer) asString(WriterSerializer)} 086 * <li class='jm'>{@link FluentObjectAssertion#asString(Function) asString(Function)} 087 * <li class='jm'>{@link FluentObjectAssertion#asJson() asJson()} 088 * <li class='jm'>{@link FluentObjectAssertion#asJsonSorted() asJsonSorted()} 089 * <li class='jm'>{@link FluentObjectAssertion#asTransformed(Function) asApplied(Function)} 090 * <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()} 091 * </ul> 092 * </ul> 093 * 094 * <h5 class='topic'>Configuration Methods</h5> 095 * <p> 096 * <ul class='javatree'> 097 * <li class='jc'>{@link Assertion} 098 * <ul class='javatreec'> 099 * <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)} 100 * <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)} 101 * <li class='jm'>{@link Assertion#setSilent() setSilent()} 102 * <li class='jm'>{@link Assertion#setStdOut() setStdOut()} 103 * <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)} 104 * </ul> 105 * </ul> 106 * 107 * <h5 class='section'>See Also:</h5> 108 * <ul> 109 * <li class='link'><a class="doclink" href="../../../../index.html#ja.Overview">Overview > juneau-assertions > Overview</a> 110 * </ul> 111 * 112 * @param <E> The element type. 113 */ 114@FluentSetters(returns="ArrayAssertion<E>") 115public class ArrayAssertion<E> extends FluentArrayAssertion<E,ArrayAssertion<E>> { 116 117 //----------------------------------------------------------------------------------------------------------------- 118 // Static 119 //----------------------------------------------------------------------------------------------------------------- 120 121 /** 122 * Static creator. 123 * 124 * @param <E> The element type. 125 * @param value 126 * The object being tested. 127 * <br>Can be <jk>null</jk>. 128 * @return A new assertion object. 129 */ 130 public static <E> ArrayAssertion<E> create(E[] value) { 131 return new ArrayAssertion<>(value); 132 } 133 134 //----------------------------------------------------------------------------------------------------------------- 135 // Instance 136 //----------------------------------------------------------------------------------------------------------------- 137 138 /** 139 * Constructor. 140 * 141 * @param value 142 * The object being tested. 143 * <br>Can be <jk>null</jk>. 144 */ 145 public ArrayAssertion(E[] value) { 146 super(value, null); 147 } 148 149 //----------------------------------------------------------------------------------------------------------------- 150 // Fluent setters 151 //----------------------------------------------------------------------------------------------------------------- 152 153 // <FluentSetters> 154 155 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 156 public ArrayAssertion<E> setMsg(String msg, Object...args) { 157 super.setMsg(msg, args); 158 return this; 159 } 160 161 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 162 public ArrayAssertion<E> setOut(PrintStream value) { 163 super.setOut(value); 164 return this; 165 } 166 167 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 168 public ArrayAssertion<E> setSilent() { 169 super.setSilent(); 170 return this; 171 } 172 173 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 174 public ArrayAssertion<E> setStdOut() { 175 super.setStdOut(); 176 return this; 177 } 178 179 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 180 public ArrayAssertion<E> setThrowable(Class<? extends java.lang.RuntimeException> value) { 181 super.setThrowable(value); 182 return this; 183 } 184 185 // </FluentSetters> 186}