Class Verify
- java.lang.Object
-
- org.junit.Assert
-
- org.eclipse.collections.impl.test.Verify
-
public final class Verify extends org.junit.Assert
An extension of theAssert
class, which adds useful additional "assert" methods. You can import this class instead of Assert, and use it thus, e.g.:Verify.assertEquals("fred", name); // from original Assert class Verify.assertContains("fred", nameList); // from new extensions Verify.assertBefore("fred", "jim", orderedNamesList); // from new extensions
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Base64.Decoder
DECODER
private static java.util.Base64.Encoder
ENCODER
private static byte[]
LINE_SEPARATOR
private static int
MAX_DIFFERENCES
-
Constructor Summary
Constructors Modifier Constructor Description private
Verify()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static java.lang.String
addFinalNewline(java.lang.String string)
static <T> void
assertAllSatisfy(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
static <T> void
assertAllSatisfy(java.lang.String message, java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
static <K,V>
voidassertAllSatisfy(java.util.Map<K,V> map, Predicate<? super V> predicate)
static <T> void
assertAnySatisfy(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
static <T> void
assertAnySatisfy(java.lang.String message, java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
static <K,V>
voidassertAnySatisfy(java.util.Map<K,V> map, Predicate<? super V> predicate)
static <K,V>
voidassertBagMultimapsEqual(java.lang.String multimapName, BagMultimap<K,V> expectedBagMultimap, BagMultimap<K,V> actualBagMultimap)
static <K,V>
voidassertBagMultimapsEqual(BagMultimap<K,V> expectedBagMultimap, BagMultimap<K,V> actualBagMultimap)
static void
assertBagsEqual(java.lang.String bagName, Bag<?> expectedBag, Bag<?> actualBag)
static void
assertBagsEqual(Bag<?> expectedBag, Bag<?> actualBag)
static void
assertBefore(java.lang.Object formerItem, java.lang.Object latterItem, java.util.List<?> actualList)
Assert that the formerItem appears before the latterItem in the givenCollection
.static void
assertBefore(java.lang.String listName, java.lang.Object formerItem, java.lang.Object latterItem, java.util.List<?> actualList)
Assert that the formerItem appears before the latterItem in the givenCollection
.static <T> void
assertClassNonInstantiable(java.lang.Class<T> aClass)
static void
assertContains(java.lang.Object expectedItem, java.util.Collection<?> actualCollection)
Assert that the givenCollection
contains the given item.static void
assertContains(java.lang.Object expectedItem, ImmutableCollection<?> actualImmutableCollection)
Assert that the givenImmutableCollection
contains the given item.static void
assertContains(java.lang.String collectionName, java.lang.Object expectedItem, java.util.Collection<?> actualCollection)
Assert that the givenCollection
contains the given item.static void
assertContains(java.lang.String immutableCollectionName, java.lang.Object expectedItem, ImmutableCollection<?> actualImmutableCollection)
Assert that the givenImmutableCollection
contains the given item.static void
assertContains(java.lang.String stringToFind, java.lang.String stringToSearch)
Assert that the givenstringToFind
is contained within thestringToSearch
.static void
assertContains(java.lang.String stringName, java.lang.String stringToFind, java.lang.String stringToSearch)
Assert that the givenstringToFind
is contained within thestringToSearch
.static void
assertContainsAll(java.lang.Iterable<?> iterable, java.lang.Object... items)
static void
assertContainsAll(java.lang.String collectionName, java.lang.Iterable<?> iterable, java.lang.Object... items)
static void
assertContainsAllEntries(java.lang.String multimapName, Multimap<?,?> actualMultimap, java.lang.Object... expectedKeyValues)
Assert the givenMultimap
contains all the given keys and values.static void
assertContainsAllEntries(Multimap<?,?> actualMultimap, java.lang.Object... keyValues)
Assert the givenMultimap
contains all the given keys and values.static void
assertContainsAllKeyValues(java.lang.String mapName, java.util.Map<?,?> actualMap, java.lang.Object... expectedKeyValues)
Assert that the givenMap
contains all the given keys and values.static void
assertContainsAllKeyValues(java.lang.String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, java.lang.Object... expectedKeyValues)
Assert that the givenImmutableMapIterable
contains all the given keys and values.static void
assertContainsAllKeyValues(java.lang.String mapIterableName, MapIterable<?,?> mapIterable, java.lang.Object... expectedKeyValues)
Assert that the givenMapIterable
contains all the given keys and values.static void
assertContainsAllKeyValues(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, java.lang.Object... expectedKeyValues)
Assert that the givenMutableMapIterable
contains all the given keys and values.static void
assertContainsAllKeyValues(java.util.Map<?,?> actualMap, java.lang.Object... keyValues)
Assert that the givenMap
contains all the given keys and values.static void
assertContainsAllKeyValues(ImmutableMapIterable<?,?> immutableMapIterable, java.lang.Object... keyValues)
Assert that the givenImmutableMapIterable
contains all the given keys and values.static void
assertContainsAllKeyValues(MapIterable<?,?> mapIterable, java.lang.Object... keyValues)
Assert that the givenMapIterable
contains all the given keys and values.static void
assertContainsAllKeyValues(MutableMapIterable<?,?> mutableMapIterable, java.lang.Object... keyValues)
Assert that the givenMutableMapIterable
contains all the given keys and values.static <K,V>
voidassertContainsEntry(java.lang.String multimapName, K expectedKey, V expectedValue, Multimap<K,V> actualMultimap)
Assert that the givenMultimap
contains an entry with the given key and value.static <K,V>
voidassertContainsEntry(K expectedKey, V expectedValue, Multimap<K,V> actualMultimap)
Assert that the givenMultimap
contains an entry with the given key and value.static void
assertContainsKey(java.lang.Object expectedKey, java.util.Map<?,?> actualMap)
Assert that the givenMap
contains an entry with the given key.static void
assertContainsKey(java.lang.Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterable
contains an entry with the given key.static void
assertContainsKey(java.lang.Object expectedKey, MapIterable<?,?> mapIterable)
Assert that the givenMapIterable
contains an entry with the given key.static void
assertContainsKey(java.lang.Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterable
contains an entry with the given key.static void
assertContainsKey(java.lang.String mapName, java.lang.Object expectedKey, java.util.Map<?,?> actualMap)
Assert that the givenMap
contains an entry with the given key.static void
assertContainsKey(java.lang.String immutableMapIterableName, java.lang.Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterable
contains an entry with the given key.static void
assertContainsKey(java.lang.String mapIterableName, java.lang.Object expectedKey, MapIterable<?,?> mapIterable)
Assert that the givenMapIterable
contains an entry with the given key.static void
assertContainsKey(java.lang.String mutableMapIterableName, java.lang.Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterable
contains an entry with the given key.static void
assertContainsKeyValue(java.lang.Object expectedKey, java.lang.Object expectedValue, java.util.Map<?,?> actualMap)
Assert that the givenMap
contains an entry with the given key and value.static void
assertContainsKeyValue(java.lang.Object expectedKey, java.lang.Object expectedValue, ImmutableMapIterable<?,?> mapIterable)
Assert that the givenImmutableMapIterable
contains an entry with the given key and value.static void
assertContainsKeyValue(java.lang.Object expectedKey, java.lang.Object expectedValue, MapIterable<?,?> mapIterable)
Assert that the givenMapIterable
contains an entry with the given key and value.static void
assertContainsKeyValue(java.lang.Object expectedKey, java.lang.Object expectedValue, MutableMapIterable<?,?> mapIterable)
Assert that the givenMutableMapIterable
contains an entry with the given key and value.static void
assertContainsKeyValue(java.lang.String mapName, java.lang.Object expectedKey, java.lang.Object expectedValue, java.util.Map<?,?> actualMap)
Assert that the givenMap
contains an entry with the given key and value.static void
assertContainsKeyValue(java.lang.String mapIterableName, java.lang.Object expectedKey, java.lang.Object expectedValue, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterable
contains an entry with the given key and value.static void
assertContainsKeyValue(java.lang.String mapIterableName, java.lang.Object expectedKey, java.lang.Object expectedValue, MapIterable<?,?> mapIterable)
Assert that the givenMapIterable
contains an entry with the given key and value.static void
assertContainsKeyValue(java.lang.String mapIterableName, java.lang.Object expectedKey, java.lang.Object expectedValue, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterable
contains an entry with the given key and value.static void
assertContainsNone(java.util.Collection<?> actualCollection, java.lang.Object... items)
static <T> void
assertCount(int expectedCount, java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
static void
assertDeserializedForm(java.lang.String expectedBase64Form, java.lang.Object actualObject)
static void
assertEmpty(java.lang.Iterable<?> actualIterable)
Assert that the givenIterable
is empty.static void
assertEmpty(java.lang.String iterableName, java.lang.Iterable<?> actualIterable)
Assert that the givenCollection
is empty.static void
assertEmpty(java.lang.String mapName, java.util.Map<?,?> actualMap)
Assert that the givenMap
is empty.static void
assertEmpty(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenCollection
is empty.static void
assertEmpty(java.lang.String multimapName, Multimap<?,?> actualMultimap)
Assert that the givenMultimap
is empty.static void
assertEmpty(java.lang.String iterableName, PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterable
is empty.static void
assertEmpty(java.util.Map<?,?> actualMap)
Assert that the givenMap
is empty.static void
assertEmpty(MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterable
is empty.static void
assertEmpty(Multimap<?,?> actualMultimap)
Assert that the givenMultimap
is empty.static void
assertEmpty(PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterable
is empty.static <T> void
assertEndsWith(java.util.List<T> list, T... items)
static <T> void
assertEndsWith(T[] array, T... items)
static void
assertEqualsAndHashCode(java.lang.Object objectA, java.lang.Object objectB)
Assert thatobjectA
andobjectB
are equal via theObject.equals(Object)
method, and that they both return the sameObject.hashCode()
.static void
assertEqualsAndHashCode(java.lang.String itemNames, java.lang.Object objectA, java.lang.Object objectB)
Assert thatobjectA
andobjectB
are equal (via theObject.equals(Object)
method, and that they both return the sameObject.hashCode()
.static void
assertError(java.lang.Class<? extends java.lang.Error> expectedErrorClass, java.lang.Runnable code)
static void
assertInstanceOf(java.lang.Class<?> expectedClassType, java.lang.Object actualObject)
Assert that the given object is an instanceof expectedClassType.static void
assertInstanceOf(java.lang.String objectName, java.lang.Class<?> expectedClassType, java.lang.Object actualObject)
Assert that the given object is an instanceof expectedClassType.static void
assertItemAtIndex(java.lang.Object expectedItem, int index, java.lang.Object[] array)
Assert that the givenitem
is at theindex
in the givenarray
.static void
assertItemAtIndex(java.lang.Object expectedItem, int index, java.util.List<?> list)
Assert that the givenitem
is at theindex
in the givenList
.static void
assertItemAtIndex(java.lang.String arrayName, java.lang.Object expectedItem, int index, java.lang.Object[] array)
Assert that the givenitem
is at theindex
in the givenList
.static void
assertItemAtIndex(java.lang.String listName, java.lang.Object expectedItem, int index, java.util.List<?> list)
Assert that the givenitem
is at theindex
in the givenList
.static void
assertIterableEmpty(java.lang.Iterable<?> iterable)
Assert that the givenIterable
is empty.static void
assertIterableEmpty(java.lang.String iterableName, java.lang.Iterable<?> iterable)
Assert that the givenIterable
is empty.static void
assertIterableNotEmpty(java.lang.Iterable<?> iterable)
Assert that the givenIterable
is not empty.static void
assertIterableNotEmpty(java.lang.String iterableName, java.lang.Iterable<?> iterable)
Assert that the givenIterable
is not empty.static void
assertIterablesEqual(java.lang.Iterable<?> expectedIterable, java.lang.Iterable<?> actualIterable)
static void
assertIterablesEqual(java.lang.String iterableName, java.lang.Iterable<?> expectedIterable, java.lang.Iterable<?> actualIterable)
static void
assertIterableSize(int expectedSize, java.lang.Iterable<?> actualIterable)
Assert the size of the givenIterable
.static void
assertIterableSize(java.lang.String iterableName, int expectedSize, java.lang.Iterable<?> actualIterable)
Assert the size of the givenIterable
.static <K,V>
voidassertListMultimapsEqual(java.lang.String multimapName, ListMultimap<K,V> expectedListMultimap, ListMultimap<K,V> actualListMultimap)
static <K,V>
voidassertListMultimapsEqual(ListMultimap<K,V> expectedListMultimap, ListMultimap<K,V> actualListMultimap)
static void
assertListsEqual(java.lang.String listName, java.util.List<?> expectedList, java.util.List<?> actualList)
static void
assertListsEqual(java.util.List<?> expectedList, java.util.List<?> actualList)
private static void
assertMapContainsKeys(java.lang.String mapName, java.util.Map<?,?> actualMap, java.lang.Object... expectedKeyValues)
private static void
assertMapContainsKeys(java.lang.String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, java.lang.Object... expectedKeyValues)
private static void
assertMapContainsKeys(java.lang.String mapIterableName, MapIterable<?,?> mapIterable, java.lang.Object... expectedKeyValues)
private static void
assertMapContainsKeys(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, java.lang.Object... expectedKeyValues)
private static void
assertMapContainsValues(java.lang.String mapName, java.util.Map<?,?> actualMap, java.lang.Object... expectedKeyValues)
private static void
assertMapContainsValues(java.lang.String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, java.lang.Object... expectedKeyValues)
private static void
assertMapContainsValues(java.lang.String mapIterableName, MapIterable<?,?> mapIterable, java.lang.Object... expectedKeyValues)
private static void
assertMapContainsValues(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, java.lang.Object... expectedKeyValues)
static void
assertMapsEqual(java.lang.String mapName, java.util.Map<?,?> expectedMap, java.util.Map<?,?> actualMap)
static void
assertMapsEqual(java.util.Map<?,?> expectedMap, java.util.Map<?,?> actualMap)
static void
assertNegative(int value)
Asserts that a value is negative.static <T> void
assertNoneSatisfy(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
static <T> void
assertNoneSatisfy(java.lang.String message, java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
static <K,V>
voidassertNoneSatisfy(java.util.Map<K,V> map, Predicate<? super V> predicate)
static void
assertNotContains(java.lang.Object unexpectedItem, java.lang.Iterable<?> iterable)
Assert that the givenIterable
does not contain the given item.static void
assertNotContains(java.lang.Object unexpectedItem, java.util.Collection<?> actualCollection)
Assert that the givenCollection
does not contain the given item.static void
assertNotContains(java.lang.String collectionName, java.lang.Object unexpectedItem, java.lang.Iterable<?> iterable)
Assert that the givenIterable
does not contain the given item.static void
assertNotContains(java.lang.String collectionName, java.lang.Object unexpectedItem, java.util.Collection<?> actualCollection)
Assert that the givenCollection
does not contain the given item.static void
assertNotContains(java.lang.String unexpectedString, java.lang.String stringToSearch)
Assert that the givenunexpectedString
is not contained within thestringToSearch
.static void
assertNotContains(java.lang.String stringName, java.lang.String unexpectedString, java.lang.String stringToSearch)
Assert that the givenunexpectedString
is not contained within thestringToSearch
.static void
assertNotContainsKey(java.lang.Object unexpectedKey, java.util.Map<?,?> actualMap)
Assert that the givenCollection
does not contain the given item.static void
assertNotContainsKey(java.lang.String mapName, java.lang.Object unexpectedKey, java.util.Map<?,?> actualMap)
Assert that the givenCollection
does not contain the given item.static void
assertNotEmpty(java.lang.Iterable<?> actualIterable)
Assert that the givenIterable
is not empty.static void
assertNotEmpty(java.lang.String iterableName, java.lang.Iterable<?> actualIterable)
Assert that the givenIterable
is not empty.static void
assertNotEmpty(java.lang.String mapName, java.util.Map<?,?> actualMap)
Assert that the givenMap
is not empty.static void
assertNotEmpty(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterable
is not empty.static void
assertNotEmpty(java.lang.String multimapName, Multimap<?,?> actualMultimap)
Assert that the givenMultimap
is not empty.static void
assertNotEmpty(java.lang.String iterableName, PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterable
is not empty.static <T> void
assertNotEmpty(java.lang.String itemsName, T[] items)
static void
assertNotEmpty(java.util.Map<?,?> actualMap)
Assert that the givenMap
is not empty.static void
assertNotEmpty(MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterable
is not empty.static void
assertNotEmpty(Multimap<?,?> actualMultimap)
Assert that the givenMultimap
is not empty.static void
assertNotEmpty(PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterable
is not empty.static <T> void
assertNotEmpty(T[] items)
static void
assertNotInstanceOf(java.lang.Class<?> expectedClassType, java.lang.Object actualObject)
Assert that the given object is not an instanceof expectedClassType.static void
assertNotInstanceOf(java.lang.String objectName, java.lang.Class<?> expectedClassType, java.lang.Object actualObject)
Assert that the given object is not an instanceof expectedClassType.static void
assertNotSerializable(java.lang.Object actualObject)
static void
assertObjectNotNull(java.lang.String objectName, java.lang.Object actualObject)
static void
assertPositive(int value)
Asserts that a value is positive.static void
assertPostSerializedEqualsAndHashCode(java.lang.Object object)
static void
assertPostSerializedEqualsHashCodeAndToString(java.lang.Object object)
static void
assertPostSerializedIdentity(java.lang.Object object)
static void
assertSerializedForm(long expectedSerialVersionUID, java.lang.String expectedBase64Form, java.lang.Object actualObject)
static void
assertSerializedForm(java.lang.String expectedBase64Form, java.lang.Object actualObject)
static <K,V>
voidassertSetMultimapsEqual(java.lang.String multimapName, SetMultimap<K,V> expectedSetMultimap, SetMultimap<K,V> actualSetMultimap)
static <K,V>
voidassertSetMultimapsEqual(SetMultimap<K,V> expectedSetMultimap, SetMultimap<K,V> actualSetMultimap)
static void
assertSetsEqual(java.lang.String setName, java.util.Set<?> expectedSet, java.util.Set<?> actualSet)
static void
assertSetsEqual(java.util.Set<?> expectedSet, java.util.Set<?> actualSet)
static void
assertShallowClone(java.lang.Cloneable object)
Deprecated.since 8.2.0 as will not work with Java 9static void
assertShallowClone(java.lang.String itemName, java.lang.Cloneable object)
Deprecated.since 8.2.0 as will not work with Java 9static void
assertSize(int expectedSize, java.lang.Iterable<?> actualIterable)
Assert the size of the givenIterable
.static void
assertSize(int expectedSize, java.lang.Object[] actualArray)
Assert the size of the given array.static void
assertSize(int expectedSize, java.util.Map<?,?> actualMap)
Assert the size of the givenMap
.static void
assertSize(int expectedSize, MutableMapIterable<?,?> mutableMapIterable)
Assert the size of the givenMutableMapIterable
.static void
assertSize(int expectedSize, Multimap<?,?> actualMultimap)
Assert the size of the givenMultimap
.static void
assertSize(int expectedSize, PrimitiveIterable primitiveIterable)
Assert the size of the givenPrimitiveIterable
.static void
assertSize(int expectedSize, ImmutableSet<?> actualImmutableSet)
Assert the size of the givenImmutableSet
.static void
assertSize(java.lang.String iterableName, int expectedSize, java.lang.Iterable<?> actualIterable)
Assert the size of the givenIterable
.static void
assertSize(java.lang.String arrayName, int expectedSize, java.lang.Object[] actualArray)
Assert the size of the given array.static void
assertSize(java.lang.String mapName, int expectedSize, java.util.Map<?,?> actualMap)
Assert the size of the givenMap
.static void
assertSize(java.lang.String mapName, int expectedSize, MutableMapIterable<?,?> mutableMapIterable)
Assert the size of the givenMutableMapIterable
.static void
assertSize(java.lang.String multimapName, int expectedSize, Multimap<?,?> actualMultimap)
Assert the size of the givenMultimap
.static void
assertSize(java.lang.String primitiveIterableName, int expectedSize, PrimitiveIterable actualPrimitiveIterable)
Assert the size of the givenPrimitiveIterable
.static void
assertSize(java.lang.String immutableSetName, int expectedSize, ImmutableSet<?> actualImmutableSet)
Assert the size of the givenImmutableSet
.static <K,V>
voidassertSortedBagMultimapsEqual(java.lang.String multimapName, SortedBagMultimap<K,V> expectedSortedBagMultimap, SortedBagMultimap<K,V> actualSortedBagMultimap)
static <K,V>
voidassertSortedBagMultimapsEqual(SortedBagMultimap<K,V> expectedSortedBagMultimap, SortedBagMultimap<K,V> actualSortedBagMultimap)
static void
assertSortedBagsEqual(java.lang.String bagName, SortedBag<?> expectedBag, SortedBag<?> actualBag)
static void
assertSortedBagsEqual(SortedBag<?> expectedBag, SortedBag<?> actualBag)
static void
assertSortedMapsEqual(java.lang.String mapName, SortedMapIterable<?,?> expectedMap, SortedMapIterable<?,?> actualMap)
static void
assertSortedMapsEqual(SortedMapIterable<?,?> expectedMap, SortedMapIterable<?,?> actualMap)
static <K,V>
voidassertSortedSetMultimapsEqual(java.lang.String multimapName, SortedSetMultimap<K,V> expectedSortedSetMultimap, SortedSetMultimap<K,V> actualSortedSetMultimap)
static <K,V>
voidassertSortedSetMultimapsEqual(SortedSetMultimap<K,V> expectedSortedSetMultimap, SortedSetMultimap<K,V> actualSortedSetMultimap)
static void
assertSortedSetsEqual(java.lang.String setName, java.util.SortedSet<?> expectedSet, java.util.SortedSet<?> actualSet)
static void
assertSortedSetsEqual(java.util.SortedSet<?> expectedSet, java.util.SortedSet<?> actualSet)
static <T> void
assertStartsWith(java.lang.String listName, java.util.List<T> list, T... items)
static <T> void
assertStartsWith(java.util.List<T> list, T... items)
static <T> void
assertStartsWith(T[] array, T... items)
static void
assertThrows(java.lang.Class<? extends java.lang.Exception> expectedExceptionClass, java.util.concurrent.Callable<?> code)
Runs theCallable
code
and asserts that it throws anException
of the typeexpectedExceptionClass
.static void
assertThrowsWithCause(java.lang.Class<? extends java.lang.Exception> expectedExceptionClass, java.lang.Class<? extends java.lang.Throwable> expectedCauseClass, java.lang.Runnable code)
Runs theRunnable
code
and asserts that it throws anException
of the typeexpectedExceptionClass
, which contains a cause of type expectedCauseClass.static void
assertThrowsWithCause(java.lang.Class<? extends java.lang.Exception> expectedExceptionClass, java.lang.Class<? extends java.lang.Throwable> expectedCauseClass, java.util.concurrent.Callable<?> code)
Runs theCallable
code
and asserts that it throws anException
of the typeexpectedExceptionClass
, which contains a cause of type expectedCauseClass.static void
assertZero(int value)
Asserts that a value is positive.private static <T> boolean
canInstantiateThroughReflection(java.lang.Class<T> aClass)
private static java.lang.Object
decodeObject(java.lang.String expectedBase64Form)
static void
denyContainsAny(java.lang.String collectionName, java.util.Collection<?> actualCollection, java.lang.Object... items)
static void
denyContainsAny(java.util.Collection<?> actualCollection, java.lang.Object... items)
static void
denyContainsKey(java.lang.Object unexpectedKey, java.util.Map<?,?> actualMap)
Deny that the givenMap
contains an entry with the given key.static void
denyContainsKey(java.lang.String mapName, java.lang.Object unexpectedKey, java.util.Map<?,?> actualMap)
Deny that the givenMap
contains an entry with the given key.private static java.lang.String
encodeObject(java.lang.Object actualObject)
static void
fail(java.lang.String message, java.lang.Throwable cause)
static void
throwMangledException(java.lang.AssertionError e)
Mangles the stack trace ofAssertionError
so that it looks like it's been thrown from the line that called to a custom assertion.static void
throwMangledException(java.lang.AssertionError e, int framesToPop)
Mangles the stack trace ofAssertionError
so that it looks like it's been thrown from the line that called to a custom assertion.-
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertThrows, assertThrows, assertTrue, assertTrue, fail, fail
-
-
-
-
Field Detail
-
MAX_DIFFERENCES
private static final int MAX_DIFFERENCES
- See Also:
- Constant Field Values
-
LINE_SEPARATOR
private static final byte[] LINE_SEPARATOR
-
ENCODER
private static final java.util.Base64.Encoder ENCODER
-
DECODER
private static final java.util.Base64.Decoder DECODER
-
-
Method Detail
-
throwMangledException
public static void throwMangledException(java.lang.AssertionError e)
Mangles the stack trace ofAssertionError
so that it looks like it's been thrown from the line that called to a custom assertion.This method behaves identically to
throwMangledException(AssertionError, int)
and is provided for convenience for assert methods that only want to pop two stack frames. The only time that you would want to call the otherthrowMangledException(AssertionError, int)
method is if you have a custom assert that calls another custom assert i.e. the source line calling the custom asserts is more than two stack frames away- Parameters:
e
- The exception to mangle.- See Also:
throwMangledException(AssertionError, int)
-
throwMangledException
public static void throwMangledException(java.lang.AssertionError e, int framesToPop)
Mangles the stack trace ofAssertionError
so that it looks like it's been thrown from the line that called to a custom assertion.This is useful for when you are in a debugging session, and you want to go to the source of the problem in the test case quickly. The regular use case for this would be something along the lines of:
public class TestFoo extends junit.framework.TestCase { public void testFoo() throws Exception { Foo foo = new Foo(); ... assertFoo(foo); } // Custom assert private static void assertFoo(Foo foo) { try { assertEquals(...); ... assertSame(...); } catch (AssertionFailedException e) { AssertUtils.throwMangledException(e, 2); } } }
Without the
try ... catch
block around lines 11-13 the stack trace following a test failure would look a little like:java.lang.AssertionError: ... at TestFoo.assertFoo(TestFoo.java:11) at TestFoo.testFoo(TestFoo.java:5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) ...
Note that the source of the error isn't readily apparent as the first line in the stack trace is the code within the custom assert. If we were debugging the failure we would be more interested in the second line of the stack trace which shows us where in our tests the assert failed.
With the
try ... catch
block around lines 11-13 the stack trace would look like the following:java.lang.AssertionError: ... at TestFoo.testFoo(TestFoo.java:5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) ...
Here the source of the error is more visible as we can instantly see that the testFoo test is failing at line 5.
- Parameters:
e
- The exception to mangle.framesToPop
- The number of frames to remove from the stack trace.- Throws:
java.lang.AssertionError
- that was given as an argument with its stack trace mangled.
-
fail
public static void fail(java.lang.String message, java.lang.Throwable cause)
-
assertEmpty
public static void assertEmpty(java.lang.Iterable<?> actualIterable)
Assert that the givenIterable
is empty.
-
assertEmpty
public static void assertEmpty(java.lang.String iterableName, java.lang.Iterable<?> actualIterable)
Assert that the givenCollection
is empty.
-
assertEmpty
public static void assertEmpty(MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterable
is empty.
-
assertEmpty
public static void assertEmpty(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenCollection
is empty.
-
assertEmpty
public static void assertEmpty(PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterable
is empty.
-
assertEmpty
public static void assertEmpty(java.lang.String iterableName, PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterable
is empty.
-
assertIterableEmpty
public static void assertIterableEmpty(java.lang.Iterable<?> iterable)
Assert that the givenIterable
is empty.
-
assertIterableEmpty
public static void assertIterableEmpty(java.lang.String iterableName, java.lang.Iterable<?> iterable)
Assert that the givenIterable
is empty.
-
assertInstanceOf
public static void assertInstanceOf(java.lang.Class<?> expectedClassType, java.lang.Object actualObject)
Assert that the given object is an instanceof expectedClassType.
-
assertInstanceOf
public static void assertInstanceOf(java.lang.String objectName, java.lang.Class<?> expectedClassType, java.lang.Object actualObject)
Assert that the given object is an instanceof expectedClassType.
-
assertNotInstanceOf
public static void assertNotInstanceOf(java.lang.Class<?> expectedClassType, java.lang.Object actualObject)
Assert that the given object is not an instanceof expectedClassType.
-
assertNotInstanceOf
public static void assertNotInstanceOf(java.lang.String objectName, java.lang.Class<?> expectedClassType, java.lang.Object actualObject)
Assert that the given object is not an instanceof expectedClassType.
-
assertEmpty
public static void assertEmpty(java.util.Map<?,?> actualMap)
Assert that the givenMap
is empty.
-
assertEmpty
public static void assertEmpty(Multimap<?,?> actualMultimap)
Assert that the givenMultimap
is empty.
-
assertEmpty
public static void assertEmpty(java.lang.String multimapName, Multimap<?,?> actualMultimap)
Assert that the givenMultimap
is empty.
-
assertEmpty
public static void assertEmpty(java.lang.String mapName, java.util.Map<?,?> actualMap)
Assert that the givenMap
is empty.
-
assertNotEmpty
public static void assertNotEmpty(java.lang.Iterable<?> actualIterable)
Assert that the givenIterable
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(java.lang.String iterableName, java.lang.Iterable<?> actualIterable)
Assert that the givenIterable
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterable
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterable
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterable
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(java.lang.String iterableName, PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterable
is not empty.
-
assertIterableNotEmpty
public static void assertIterableNotEmpty(java.lang.Iterable<?> iterable)
Assert that the givenIterable
is not empty.
-
assertIterableNotEmpty
public static void assertIterableNotEmpty(java.lang.String iterableName, java.lang.Iterable<?> iterable)
Assert that the givenIterable
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(java.util.Map<?,?> actualMap)
Assert that the givenMap
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(java.lang.String mapName, java.util.Map<?,?> actualMap)
Assert that the givenMap
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(Multimap<?,?> actualMultimap)
Assert that the givenMultimap
is not empty.
-
assertNotEmpty
public static void assertNotEmpty(java.lang.String multimapName, Multimap<?,?> actualMultimap)
Assert that the givenMultimap
is not empty.
-
assertNotEmpty
public static <T> void assertNotEmpty(java.lang.String itemsName, T[] items)
-
assertNotEmpty
public static <T> void assertNotEmpty(T[] items)
-
assertSize
public static void assertSize(int expectedSize, java.lang.Object[] actualArray)
Assert the size of the given array.
-
assertSize
public static void assertSize(java.lang.String arrayName, int expectedSize, java.lang.Object[] actualArray)
Assert the size of the given array.
-
assertSize
public static void assertSize(int expectedSize, java.lang.Iterable<?> actualIterable)
Assert the size of the givenIterable
.
-
assertSize
public static void assertSize(java.lang.String iterableName, int expectedSize, java.lang.Iterable<?> actualIterable)
Assert the size of the givenIterable
.
-
assertSize
public static void assertSize(int expectedSize, PrimitiveIterable primitiveIterable)
Assert the size of the givenPrimitiveIterable
.
-
assertSize
public static void assertSize(java.lang.String primitiveIterableName, int expectedSize, PrimitiveIterable actualPrimitiveIterable)
Assert the size of the givenPrimitiveIterable
.
-
assertIterableSize
public static void assertIterableSize(int expectedSize, java.lang.Iterable<?> actualIterable)
Assert the size of the givenIterable
.
-
assertIterableSize
public static void assertIterableSize(java.lang.String iterableName, int expectedSize, java.lang.Iterable<?> actualIterable)
Assert the size of the givenIterable
.
-
assertSize
public static void assertSize(java.lang.String mapName, int expectedSize, java.util.Map<?,?> actualMap)
Assert the size of the givenMap
.
-
assertSize
public static void assertSize(int expectedSize, java.util.Map<?,?> actualMap)
Assert the size of the givenMap
.
-
assertSize
public static void assertSize(int expectedSize, Multimap<?,?> actualMultimap)
Assert the size of the givenMultimap
.
-
assertSize
public static void assertSize(java.lang.String multimapName, int expectedSize, Multimap<?,?> actualMultimap)
Assert the size of the givenMultimap
.
-
assertSize
public static void assertSize(int expectedSize, MutableMapIterable<?,?> mutableMapIterable)
Assert the size of the givenMutableMapIterable
.
-
assertSize
public static void assertSize(java.lang.String mapName, int expectedSize, MutableMapIterable<?,?> mutableMapIterable)
Assert the size of the givenMutableMapIterable
.
-
assertSize
public static void assertSize(int expectedSize, ImmutableSet<?> actualImmutableSet)
Assert the size of the givenImmutableSet
.
-
assertSize
public static void assertSize(java.lang.String immutableSetName, int expectedSize, ImmutableSet<?> actualImmutableSet)
Assert the size of the givenImmutableSet
.
-
assertContains
public static void assertContains(java.lang.String stringToFind, java.lang.String stringToSearch)
Assert that the givenstringToFind
is contained within thestringToSearch
.
-
assertNotContains
public static void assertNotContains(java.lang.String unexpectedString, java.lang.String stringToSearch)
Assert that the givenunexpectedString
is not contained within thestringToSearch
.
-
assertContains
public static void assertContains(java.lang.String stringName, java.lang.String stringToFind, java.lang.String stringToSearch)
Assert that the givenstringToFind
is contained within thestringToSearch
.
-
assertNotContains
public static void assertNotContains(java.lang.String stringName, java.lang.String unexpectedString, java.lang.String stringToSearch)
Assert that the givenunexpectedString
is not contained within thestringToSearch
.
-
assertCount
public static <T> void assertCount(int expectedCount, java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
-
assertAllSatisfy
public static <T> void assertAllSatisfy(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
-
assertAllSatisfy
public static <K,V> void assertAllSatisfy(java.util.Map<K,V> map, Predicate<? super V> predicate)
-
assertAllSatisfy
public static <T> void assertAllSatisfy(java.lang.String message, java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
-
assertAnySatisfy
public static <T> void assertAnySatisfy(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
-
assertAnySatisfy
public static <K,V> void assertAnySatisfy(java.util.Map<K,V> map, Predicate<? super V> predicate)
-
assertAnySatisfy
public static <T> void assertAnySatisfy(java.lang.String message, java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
-
assertNoneSatisfy
public static <T> void assertNoneSatisfy(java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
-
assertNoneSatisfy
public static <K,V> void assertNoneSatisfy(java.util.Map<K,V> map, Predicate<? super V> predicate)
-
assertNoneSatisfy
public static <T> void assertNoneSatisfy(java.lang.String message, java.lang.Iterable<T> iterable, Predicate<? super T> predicate)
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(java.util.Map<?,?> actualMap, java.lang.Object... keyValues)
Assert that the givenMap
contains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(java.lang.String mapName, java.util.Map<?,?> actualMap, java.lang.Object... expectedKeyValues)
Assert that the givenMap
contains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(MapIterable<?,?> mapIterable, java.lang.Object... keyValues)
Assert that the givenMapIterable
contains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(java.lang.String mapIterableName, MapIterable<?,?> mapIterable, java.lang.Object... expectedKeyValues)
Assert that the givenMapIterable
contains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(MutableMapIterable<?,?> mutableMapIterable, java.lang.Object... keyValues)
Assert that the givenMutableMapIterable
contains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, java.lang.Object... expectedKeyValues)
Assert that the givenMutableMapIterable
contains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(ImmutableMapIterable<?,?> immutableMapIterable, java.lang.Object... keyValues)
Assert that the givenImmutableMapIterable
contains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(java.lang.String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, java.lang.Object... expectedKeyValues)
Assert that the givenImmutableMapIterable
contains all the given keys and values.
-
denyContainsAny
public static void denyContainsAny(java.util.Collection<?> actualCollection, java.lang.Object... items)
-
assertContainsNone
public static void assertContainsNone(java.util.Collection<?> actualCollection, java.lang.Object... items)
-
assertContains
public static void assertContains(java.lang.Object expectedItem, java.util.Collection<?> actualCollection)
Assert that the givenCollection
contains the given item.
-
assertContains
public static void assertContains(java.lang.String collectionName, java.lang.Object expectedItem, java.util.Collection<?> actualCollection)
Assert that the givenCollection
contains the given item.
-
assertContains
public static void assertContains(java.lang.Object expectedItem, ImmutableCollection<?> actualImmutableCollection)
Assert that the givenImmutableCollection
contains the given item.
-
assertContains
public static void assertContains(java.lang.String immutableCollectionName, java.lang.Object expectedItem, ImmutableCollection<?> actualImmutableCollection)
Assert that the givenImmutableCollection
contains the given item.
-
assertContainsAll
public static void assertContainsAll(java.lang.Iterable<?> iterable, java.lang.Object... items)
-
assertContainsAll
public static void assertContainsAll(java.lang.String collectionName, java.lang.Iterable<?> iterable, java.lang.Object... items)
-
assertListsEqual
public static void assertListsEqual(java.util.List<?> expectedList, java.util.List<?> actualList)
-
assertListsEqual
public static void assertListsEqual(java.lang.String listName, java.util.List<?> expectedList, java.util.List<?> actualList)
-
assertSetsEqual
public static void assertSetsEqual(java.util.Set<?> expectedSet, java.util.Set<?> actualSet)
-
assertSetsEqual
public static void assertSetsEqual(java.lang.String setName, java.util.Set<?> expectedSet, java.util.Set<?> actualSet)
-
assertSortedSetsEqual
public static void assertSortedSetsEqual(java.util.SortedSet<?> expectedSet, java.util.SortedSet<?> actualSet)
-
assertSortedSetsEqual
public static void assertSortedSetsEqual(java.lang.String setName, java.util.SortedSet<?> expectedSet, java.util.SortedSet<?> actualSet)
-
assertSortedBagsEqual
public static void assertSortedBagsEqual(SortedBag<?> expectedBag, SortedBag<?> actualBag)
-
assertSortedBagsEqual
public static void assertSortedBagsEqual(java.lang.String bagName, SortedBag<?> expectedBag, SortedBag<?> actualBag)
-
assertSortedMapsEqual
public static void assertSortedMapsEqual(SortedMapIterable<?,?> expectedMap, SortedMapIterable<?,?> actualMap)
-
assertSortedMapsEqual
public static void assertSortedMapsEqual(java.lang.String mapName, SortedMapIterable<?,?> expectedMap, SortedMapIterable<?,?> actualMap)
-
assertIterablesEqual
public static void assertIterablesEqual(java.lang.Iterable<?> expectedIterable, java.lang.Iterable<?> actualIterable)
-
assertIterablesEqual
public static void assertIterablesEqual(java.lang.String iterableName, java.lang.Iterable<?> expectedIterable, java.lang.Iterable<?> actualIterable)
-
assertMapsEqual
public static void assertMapsEqual(java.util.Map<?,?> expectedMap, java.util.Map<?,?> actualMap)
-
assertMapsEqual
public static void assertMapsEqual(java.lang.String mapName, java.util.Map<?,?> expectedMap, java.util.Map<?,?> actualMap)
-
assertBagsEqual
public static void assertBagsEqual(java.lang.String bagName, Bag<?> expectedBag, Bag<?> actualBag)
-
assertListMultimapsEqual
public static <K,V> void assertListMultimapsEqual(ListMultimap<K,V> expectedListMultimap, ListMultimap<K,V> actualListMultimap)
-
assertListMultimapsEqual
public static <K,V> void assertListMultimapsEqual(java.lang.String multimapName, ListMultimap<K,V> expectedListMultimap, ListMultimap<K,V> actualListMultimap)
-
assertSetMultimapsEqual
public static <K,V> void assertSetMultimapsEqual(SetMultimap<K,V> expectedSetMultimap, SetMultimap<K,V> actualSetMultimap)
-
assertSetMultimapsEqual
public static <K,V> void assertSetMultimapsEqual(java.lang.String multimapName, SetMultimap<K,V> expectedSetMultimap, SetMultimap<K,V> actualSetMultimap)
-
assertBagMultimapsEqual
public static <K,V> void assertBagMultimapsEqual(BagMultimap<K,V> expectedBagMultimap, BagMultimap<K,V> actualBagMultimap)
-
assertBagMultimapsEqual
public static <K,V> void assertBagMultimapsEqual(java.lang.String multimapName, BagMultimap<K,V> expectedBagMultimap, BagMultimap<K,V> actualBagMultimap)
-
assertSortedSetMultimapsEqual
public static <K,V> void assertSortedSetMultimapsEqual(SortedSetMultimap<K,V> expectedSortedSetMultimap, SortedSetMultimap<K,V> actualSortedSetMultimap)
-
assertSortedSetMultimapsEqual
public static <K,V> void assertSortedSetMultimapsEqual(java.lang.String multimapName, SortedSetMultimap<K,V> expectedSortedSetMultimap, SortedSetMultimap<K,V> actualSortedSetMultimap)
-
assertSortedBagMultimapsEqual
public static <K,V> void assertSortedBagMultimapsEqual(SortedBagMultimap<K,V> expectedSortedBagMultimap, SortedBagMultimap<K,V> actualSortedBagMultimap)
-
assertSortedBagMultimapsEqual
public static <K,V> void assertSortedBagMultimapsEqual(java.lang.String multimapName, SortedBagMultimap<K,V> expectedSortedBagMultimap, SortedBagMultimap<K,V> actualSortedBagMultimap)
-
assertMapContainsKeys
private static void assertMapContainsKeys(java.lang.String mapName, java.util.Map<?,?> actualMap, java.lang.Object... expectedKeyValues)
-
assertMapContainsValues
private static void assertMapContainsValues(java.lang.String mapName, java.util.Map<?,?> actualMap, java.lang.Object... expectedKeyValues)
-
assertMapContainsKeys
private static void assertMapContainsKeys(java.lang.String mapIterableName, MapIterable<?,?> mapIterable, java.lang.Object... expectedKeyValues)
-
assertMapContainsValues
private static void assertMapContainsValues(java.lang.String mapIterableName, MapIterable<?,?> mapIterable, java.lang.Object... expectedKeyValues)
-
assertMapContainsKeys
private static void assertMapContainsKeys(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, java.lang.Object... expectedKeyValues)
-
assertMapContainsValues
private static void assertMapContainsValues(java.lang.String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, java.lang.Object... expectedKeyValues)
-
assertMapContainsKeys
private static void assertMapContainsKeys(java.lang.String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, java.lang.Object... expectedKeyValues)
-
assertMapContainsValues
private static void assertMapContainsValues(java.lang.String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, java.lang.Object... expectedKeyValues)
-
assertContainsEntry
public static <K,V> void assertContainsEntry(K expectedKey, V expectedValue, Multimap<K,V> actualMultimap)
Assert that the givenMultimap
contains an entry with the given key and value.
-
assertContainsEntry
public static <K,V> void assertContainsEntry(java.lang.String multimapName, K expectedKey, V expectedValue, Multimap<K,V> actualMultimap)
Assert that the givenMultimap
contains an entry with the given key and value.
-
assertContainsAllEntries
public static void assertContainsAllEntries(Multimap<?,?> actualMultimap, java.lang.Object... keyValues)
Assert the givenMultimap
contains all the given keys and values.
-
assertContainsAllEntries
public static void assertContainsAllEntries(java.lang.String multimapName, Multimap<?,?> actualMultimap, java.lang.Object... expectedKeyValues)
Assert the givenMultimap
contains all the given keys and values.
-
denyContainsAny
public static void denyContainsAny(java.lang.String collectionName, java.util.Collection<?> actualCollection, java.lang.Object... items)
-
assertContainsKey
public static void assertContainsKey(java.lang.Object expectedKey, java.util.Map<?,?> actualMap)
Assert that the givenMap
contains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(java.lang.String mapName, java.lang.Object expectedKey, java.util.Map<?,?> actualMap)
Assert that the givenMap
contains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(java.lang.Object expectedKey, MapIterable<?,?> mapIterable)
Assert that the givenMapIterable
contains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(java.lang.String mapIterableName, java.lang.Object expectedKey, MapIterable<?,?> mapIterable)
Assert that the givenMapIterable
contains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(java.lang.Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterable
contains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(java.lang.String mutableMapIterableName, java.lang.Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterable
contains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(java.lang.Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterable
contains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(java.lang.String immutableMapIterableName, java.lang.Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterable
contains an entry with the given key.
-
denyContainsKey
public static void denyContainsKey(java.lang.Object unexpectedKey, java.util.Map<?,?> actualMap)
Deny that the givenMap
contains an entry with the given key.
-
denyContainsKey
public static void denyContainsKey(java.lang.String mapName, java.lang.Object unexpectedKey, java.util.Map<?,?> actualMap)
Deny that the givenMap
contains an entry with the given key.
-
assertContainsKeyValue
public static void assertContainsKeyValue(java.lang.Object expectedKey, java.lang.Object expectedValue, java.util.Map<?,?> actualMap)
Assert that the givenMap
contains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(java.lang.String mapName, java.lang.Object expectedKey, java.lang.Object expectedValue, java.util.Map<?,?> actualMap)
Assert that the givenMap
contains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(java.lang.Object expectedKey, java.lang.Object expectedValue, MapIterable<?,?> mapIterable)
Assert that the givenMapIterable
contains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(java.lang.String mapIterableName, java.lang.Object expectedKey, java.lang.Object expectedValue, MapIterable<?,?> mapIterable)
Assert that the givenMapIterable
contains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(java.lang.Object expectedKey, java.lang.Object expectedValue, MutableMapIterable<?,?> mapIterable)
Assert that the givenMutableMapIterable
contains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(java.lang.String mapIterableName, java.lang.Object expectedKey, java.lang.Object expectedValue, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterable
contains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(java.lang.Object expectedKey, java.lang.Object expectedValue, ImmutableMapIterable<?,?> mapIterable)
Assert that the givenImmutableMapIterable
contains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(java.lang.String mapIterableName, java.lang.Object expectedKey, java.lang.Object expectedValue, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterable
contains an entry with the given key and value.
-
assertNotContains
public static void assertNotContains(java.lang.Object unexpectedItem, java.util.Collection<?> actualCollection)
Assert that the givenCollection
does not contain the given item.
-
assertNotContains
public static void assertNotContains(java.lang.String collectionName, java.lang.Object unexpectedItem, java.util.Collection<?> actualCollection)
Assert that the givenCollection
does not contain the given item.
-
assertNotContains
public static void assertNotContains(java.lang.Object unexpectedItem, java.lang.Iterable<?> iterable)
Assert that the givenIterable
does not contain the given item.
-
assertNotContains
public static void assertNotContains(java.lang.String collectionName, java.lang.Object unexpectedItem, java.lang.Iterable<?> iterable)
Assert that the givenIterable
does not contain the given item.
-
assertNotContainsKey
public static void assertNotContainsKey(java.lang.Object unexpectedKey, java.util.Map<?,?> actualMap)
Assert that the givenCollection
does not contain the given item.
-
assertNotContainsKey
public static void assertNotContainsKey(java.lang.String mapName, java.lang.Object unexpectedKey, java.util.Map<?,?> actualMap)
Assert that the givenCollection
does not contain the given item.
-
assertBefore
public static void assertBefore(java.lang.Object formerItem, java.lang.Object latterItem, java.util.List<?> actualList)
Assert that the formerItem appears before the latterItem in the givenCollection
. Both the formerItem and the latterItem must appear in the collection, or this assert will fail.
-
assertBefore
public static void assertBefore(java.lang.String listName, java.lang.Object formerItem, java.lang.Object latterItem, java.util.List<?> actualList)
Assert that the formerItem appears before the latterItem in the givenCollection
.assertContains(String, Object, Collection)
will be called for both the formerItem and the latterItem, prior to the "before" assertion.
-
assertObjectNotNull
public static void assertObjectNotNull(java.lang.String objectName, java.lang.Object actualObject)
-
assertItemAtIndex
public static void assertItemAtIndex(java.lang.Object expectedItem, int index, java.util.List<?> list)
Assert that the givenitem
is at theindex
in the givenList
.
-
assertItemAtIndex
public static void assertItemAtIndex(java.lang.Object expectedItem, int index, java.lang.Object[] array)
Assert that the givenitem
is at theindex
in the givenarray
.
-
assertStartsWith
public static <T> void assertStartsWith(T[] array, T... items)
-
assertStartsWith
public static <T> void assertStartsWith(java.util.List<T> list, T... items)
-
assertStartsWith
public static <T> void assertStartsWith(java.lang.String listName, java.util.List<T> list, T... items)
-
assertEndsWith
public static <T> void assertEndsWith(java.util.List<T> list, T... items)
-
assertEndsWith
public static <T> void assertEndsWith(T[] array, T... items)
-
assertItemAtIndex
public static void assertItemAtIndex(java.lang.String listName, java.lang.Object expectedItem, int index, java.util.List<?> list)
Assert that the givenitem
is at theindex
in the givenList
.
-
assertItemAtIndex
public static void assertItemAtIndex(java.lang.String arrayName, java.lang.Object expectedItem, int index, java.lang.Object[] array)
Assert that the givenitem
is at theindex
in the givenList
.
-
assertPostSerializedEqualsAndHashCode
public static void assertPostSerializedEqualsAndHashCode(java.lang.Object object)
-
assertPostSerializedEqualsHashCodeAndToString
public static void assertPostSerializedEqualsHashCodeAndToString(java.lang.Object object)
-
assertPostSerializedIdentity
public static void assertPostSerializedIdentity(java.lang.Object object)
-
assertSerializedForm
public static void assertSerializedForm(java.lang.String expectedBase64Form, java.lang.Object actualObject)
-
assertSerializedForm
public static void assertSerializedForm(long expectedSerialVersionUID, java.lang.String expectedBase64Form, java.lang.Object actualObject)
-
assertDeserializedForm
public static void assertDeserializedForm(java.lang.String expectedBase64Form, java.lang.Object actualObject)
-
decodeObject
private static java.lang.Object decodeObject(java.lang.String expectedBase64Form)
-
encodeObject
private static java.lang.String encodeObject(java.lang.Object actualObject)
-
addFinalNewline
private static java.lang.String addFinalNewline(java.lang.String string)
-
assertNotSerializable
public static void assertNotSerializable(java.lang.Object actualObject)
-
assertEqualsAndHashCode
public static void assertEqualsAndHashCode(java.lang.Object objectA, java.lang.Object objectB)
Assert thatobjectA
andobjectB
are equal via theObject.equals(Object)
method, and that they both return the sameObject.hashCode()
.
-
assertNegative
public static void assertNegative(int value)
Asserts that a value is negative.
-
assertPositive
public static void assertPositive(int value)
Asserts that a value is positive.
-
assertZero
public static void assertZero(int value)
Asserts that a value is positive.
-
assertEqualsAndHashCode
public static void assertEqualsAndHashCode(java.lang.String itemNames, java.lang.Object objectA, java.lang.Object objectB)
Assert thatobjectA
andobjectB
are equal (via theObject.equals(Object)
method, and that they both return the sameObject.hashCode()
.
-
assertShallowClone
@Deprecated public static void assertShallowClone(java.lang.Cloneable object)
Deprecated.since 8.2.0 as will not work with Java 9
-
assertShallowClone
@Deprecated public static void assertShallowClone(java.lang.String itemName, java.lang.Cloneable object)
Deprecated.since 8.2.0 as will not work with Java 9
-
assertClassNonInstantiable
public static <T> void assertClassNonInstantiable(java.lang.Class<T> aClass)
-
canInstantiateThroughReflection
private static <T> boolean canInstantiateThroughReflection(java.lang.Class<T> aClass)
-
assertError
public static void assertError(java.lang.Class<? extends java.lang.Error> expectedErrorClass, java.lang.Runnable code)
-
assertThrows
public static void assertThrows(java.lang.Class<? extends java.lang.Exception> expectedExceptionClass, java.util.concurrent.Callable<?> code)
Runs theCallable
code
and asserts that it throws anException
of the typeexpectedExceptionClass
.Callable
is most appropriate when a checked exception will be thrown. If a subclass ofRuntimeException
will be thrown, the formAssert.assertThrows(Class, org.junit.function.ThrowingRunnable)
may be more convenient.e.g.
Verify.assertThrows(StringIndexOutOfBoundsException.class, new Callable<String>() { public String call() throws Exception { return "Craig".substring(42, 3); } });
- See Also:
Assert.assertThrows(Class, org.junit.function.ThrowingRunnable)
-
assertThrowsWithCause
public static void assertThrowsWithCause(java.lang.Class<? extends java.lang.Exception> expectedExceptionClass, java.lang.Class<? extends java.lang.Throwable> expectedCauseClass, java.util.concurrent.Callable<?> code)
Runs theCallable
code
and asserts that it throws anException
of the typeexpectedExceptionClass
, which contains a cause of type expectedCauseClass.Callable
is most appropriate when a checked exception will be thrown. If a subclass ofRuntimeException
will be thrown, the formassertThrowsWithCause(Class, Class, Runnable)
may be more convenient.e.g.
Verify.assertThrowsWithCause(RuntimeException.class, IOException.class, new Callable<Void>() { public Void call() throws Exception { try { new File("").createNewFile(); } catch (final IOException e) { throw new RuntimeException("Uh oh!", e); } return null; } });
-
assertThrowsWithCause
public static void assertThrowsWithCause(java.lang.Class<? extends java.lang.Exception> expectedExceptionClass, java.lang.Class<? extends java.lang.Throwable> expectedCauseClass, java.lang.Runnable code)
Runs theRunnable
code
and asserts that it throws anException
of the typeexpectedExceptionClass
, which contains a cause of type expectedCauseClass.Runnable
is most appropriate when a subclass ofRuntimeException
will be thrown. If a checked exception will be thrown, the formassertThrowsWithCause(Class, Class, Callable)
may be more convenient.e.g.
Verify.assertThrowsWithCause(RuntimeException.class, StringIndexOutOfBoundsException.class, new Runnable() { public void run() { try { LOGGER.info("Craig".substring(42, 3)); } catch (final StringIndexOutOfBoundsException e) { throw new RuntimeException("Uh oh!", e); } } });
-
-