public final class Assert extends Object
| Modifier and Type | Method and Description |
|---|---|
static <U,T extends U> |
aClassWhoseSuperClass(Matcher<? extends Class<? extends U>> classMatcher)
Facilitates making an assertion about the superclass of a
Class. |
static <T extends Collection<?>> |
aCollectionWhoseSize(Matcher<Integer> sizeMatcher)
Facilitates making an assertion about the size of a
Collection. |
static <T extends List<? extends E>,E> |
aListWhoseElementAtIndex(Integer index,
Matcher<E> matcher)
Facilitates making an assertion about the element at a given index of a
List. |
static <T extends Member> |
isAMemberWithModifier(Modifier modifier)
|
static Matcher<Class<?>> |
isNotInstantiable()
Asserts that a class is not instantiable - it exists only for its static members.
|
public static Matcher<Class<?>> isNotInstantiable()
More precisely, asserts that the class:
UnsupportedOperationException with message "Not Instantiable" if it is
invoked via reflection.
Usage:
assertThat(Values.class, isNotInstantiable());
public static <U,T extends U> uk.org.lidalia.test.FeatureMatcher<Class<? extends T>,Class<? extends U>> aClassWhoseSuperClass(Matcher<? extends Class<? extends U>> classMatcher)
Class.
Usage:
assertThat(String.class, is(aClassWhoseSuperClass(is(Object.class))));
U - the type of the superclass of the class being matchedT - the type of the class being matchedclassMatcher - the matcher that will be applied to the class's superclasspublic static <T extends Collection<?>> Matcher<T> aCollectionWhoseSize(Matcher<Integer> sizeMatcher)
Collection.
Usage:
assertThat(asList(1, 2, 3), is(aCollectionWhoseSize(is(3))));
T - the type of the collection whose size will be matchedsizeMatcher - the matcher that will be applied to the collection's sizepublic static <T extends List<? extends E>,E> Matcher<T> aListWhoseElementAtIndex(Integer index, Matcher<E> matcher)
List.
Usage:
assertThat(asList("a", "b", "c"), is(aListWhoseElementAtIndex(2, is("c"))));
T - the type of the ListE - the type of the elements in the Listindex - the index of the element in the list the matcher will be applied tomatcher - the matcher that will be applied to the elementpublic static <T extends Member> Matcher<T> isAMemberWithModifier(Modifier modifier)
Member has a given Modifier.
Usage:
assertThat(Object.class.getMethod("toString"), isAMemberWithModifier(Modifier.PUBLIC));
T - the type of the Membermodifier - the modifier the member is expected to haveCopyright © 2013. All Rights Reserved.