public class ClassAssert extends AbstractClassAssert<ClassAssert>
Classes.
To create a new instance of this class, invoke Assertions.assertThat(Class)
actual, info, myself| Constructor and Description |
|---|
ClassAssert(Class<?> actual) |
| Modifier and Type | Method and Description |
|---|---|
ClassAssert |
hasAnnotations(Class<? extends Annotation>... annotations)
Verifies that the actual
Class has the given Annotations. |
hasAnnotation, hasDeclaredFields, hasDeclaredMethods, hasFields, hasMethods, hasOnlyDeclaredFields, hasOnlyPublicFields, hasPublicFields, hasPublicMethods, isAnnotation, isAssignableFrom, isFinal, isInterface, isNotAnnotation, isNotFinal, isNotInterface, isProtected, isPublicas, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnErrorpublic ClassAssert(Class<?> actual)
@SafeVarargs public final ClassAssert hasAnnotations(Class<? extends Annotation>... annotations)
AbstractClassAssertClass has the given Annotations.
Example:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
private static @interface Force { }
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
private static @interface Hero { }
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
private static @interface DarkSide { }
@Hero @Force
class Jedi implements Jedi {}
// this assertion succeeds:
assertThat(Jedi.class).containsAnnotations(Force.class, Hero.class);
// this assertion fails:
assertThat(Jedi.class).containsAnnotations(Force.class, DarkSide.class);hasAnnotations in class AbstractClassAssert<ClassAssert>annotations - annotations who must be attached to the classthis assertions objectCopyright © 2013–2018 AssertJ. All rights reserved.