public final class Assert extends Object
Modifier and Type | Method and Description |
---|---|
static <U,T extends U> |
aClassWhoseSuperClass(org.hamcrest.Matcher<? extends Class<? extends U>> classMatcher)
Facilitates making an assertion about the superclass of a
Class . |
static <T extends Collection<?>> |
aCollectionWhoseSize(org.hamcrest.Matcher<Integer> sizeMatcher)
Facilitates making an assertion about the size of a
Collection . |
static <T extends List<? extends E>,E> |
aListWhoseElementAtIndex(Integer index,
org.hamcrest.Matcher<E> matcher)
Facilitates making an assertion about the element at a given index of a
List . |
static <T extends Member> |
isAMemberWithModifier(uk.org.lidalia.lang.Modifier modifier)
Asserts that a given
Member has a given Modifier . |
static org.hamcrest.Matcher<Class<?>> |
isNotInstantiable()
Asserts that a class is not instantiable - it exists only for its static members.
|
public static org.hamcrest.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(org.hamcrest.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<?>> org.hamcrest.Matcher<T> aCollectionWhoseSize(org.hamcrest.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> org.hamcrest.Matcher<T> aListWhoseElementAtIndex(Integer index, org.hamcrest.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> org.hamcrest.Matcher<T> isAMemberWithModifier(uk.org.lidalia.lang.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.