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.nio.charset.*; 017import java.util.function.*; 018 019import org.apache.juneau.internal.*; 020import org.apache.juneau.serializer.*; 021 022/** 023 * Used for assertion calls against byte arrays. 024 * 025 * <h5 class='section'>Example:</h5> 026 * <p class='bjava'> 027 * <jc>// Validates the byte array contains the string "foo".</jc> 028 * <jsm>assertBytes</jsm>(<jv>myByteArray</jv>).asHex().is(<js>"666F6F"</js>); 029 * </p> 030 * 031 * 032 * <h5 class='section'>Test Methods:</h5> 033 * <p> 034 * <ul class='javatree'> 035 * <li class='jc'>{@link FluentPrimitiveArrayAssertion} 036 * <ul class='javatreec'> 037 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#isHas(Object...) isHas(Object...)} 038 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#is(Predicate) is(Predicate)} 039 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#isAny(Predicate) isAny(Predicate)} 040 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#isAll(Predicate) isAll(Predicate)} 041 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#isEmpty() isEmpty()} 042 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#isNotEmpty() isNotEmpty()} 043 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#isSize(int) isSize(int)} 044 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#isContains(Object) isContains(Object)} 045 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#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='section'>Transform Methods:</h5> 069 * <p> 070 * <ul class='javatree'> 071 * <li class='jc'>{@link FluentByteArrayAssertion} 072 * <ul class='javatreec'> 073 * <li class='jm'>{@link FluentByteArrayAssertion#asString() asString()} 074 * <li class='jm'>{@link FluentByteArrayAssertion#asString(Charset) asString(Charset)} 075 * <li class='jm'>{@link FluentByteArrayAssertion#asBase64() asBase64()} 076 * <li class='jm'>{@link FluentByteArrayAssertion#asHex() asHex()} 077 * <li class='jm'>{@link FluentByteArrayAssertion#asSpacedHex() asSpacedHex()} 078 * </ul> 079 * <li class='jc'>{@link FluentPrimitiveArrayAssertion} 080 * <ul class='javatreec'> 081 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#asItem(int) asItem(int)} 082 * <li class='jm'>{@link FluentPrimitiveArrayAssertion#asLength() asLength()} 083 * </ul> 084 * <li class='jc'>{@link FluentObjectAssertion} 085 * <ul class='javatreec'> 086 * <li class='jm'>{@link FluentObjectAssertion#asString() asString()} 087 * <li class='jm'>{@link FluentObjectAssertion#asString(WriterSerializer) asString(WriterSerializer)} 088 * <li class='jm'>{@link FluentObjectAssertion#asString(Function) asString(Function)} 089 * <li class='jm'>{@link FluentObjectAssertion#asJson() asJson()} 090 * <li class='jm'>{@link FluentObjectAssertion#asJsonSorted() asJsonSorted()} 091 * <li class='jm'>{@link FluentObjectAssertion#asTransformed(Function) asApplied(Function)} 092 * <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()} 093 * </ul> 094 * </ul> 095 * 096 * <h5 class='section'>Configuration Methods:</h5> 097 * <p> 098 * <ul class='javatree'> 099 * <li class='jc'>{@link Assertion} 100 * <ul class='javatreec'> 101 * <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)} 102 * <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)} 103 * <li class='jm'>{@link Assertion#setSilent() setSilent()} 104 * <li class='jm'>{@link Assertion#setStdOut() setStdOut()} 105 * <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)} 106 * </ul> 107 * </ul> 108 * 109 * <h5 class='section'>See Also:</h5><ul> 110 * <li class='link'><a class="doclink" href="../../../../index.html#ja.Overview">Overview > juneau-assertions > Overview</a> 111 * </ul> 112 */ 113@FluentSetters(returns="ByteArrayAssertion") 114public class ByteArrayAssertion extends FluentByteArrayAssertion<ByteArrayAssertion> { 115 116 //----------------------------------------------------------------------------------------------------------------- 117 // Static 118 //----------------------------------------------------------------------------------------------------------------- 119 120 /** 121 * Static creator. 122 * 123 * @param value 124 * The object being tested. 125 * <br>Can be <jk>null</jk>. 126 * @return A new assertion object. 127 */ 128 public static ByteArrayAssertion create(byte[] value) { 129 return new ByteArrayAssertion(value); 130 } 131 132 //----------------------------------------------------------------------------------------------------------------- 133 // Instance 134 //----------------------------------------------------------------------------------------------------------------- 135 136 /** 137 * Constructor. 138 * 139 * @param value 140 * The object being tested. 141 * <br>Can be <jk>null</jk>. 142 */ 143 public ByteArrayAssertion(byte[] value) { 144 super(value, null); 145 } 146 147 //----------------------------------------------------------------------------------------------------------------- 148 // Fluent setters 149 //----------------------------------------------------------------------------------------------------------------- 150 151 // <FluentSetters> 152 153 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 154 public ByteArrayAssertion setMsg(String msg, Object...args) { 155 super.setMsg(msg, args); 156 return this; 157 } 158 159 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 160 public ByteArrayAssertion setOut(PrintStream value) { 161 super.setOut(value); 162 return this; 163 } 164 165 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 166 public ByteArrayAssertion setSilent() { 167 super.setSilent(); 168 return this; 169 } 170 171 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 172 public ByteArrayAssertion setStdOut() { 173 super.setStdOut(); 174 return this; 175 } 176 177 @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ 178 public ByteArrayAssertion setThrowable(Class<? extends java.lang.RuntimeException> value) { 179 super.setThrowable(value); 180 return this; 181 } 182 183 // </FluentSetters> 184}