public class ClassAssert extends AbstractClassAssert<ClassAssert>
Class
es.
To create a new instance of this class, invoke Assertions.assertThat(Class)
classes
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals
Constructor and Description |
---|
ClassAssert(java.lang.Class<?> actual) |
Modifier and Type | Method and Description |
---|---|
ClassAssert |
hasAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
Verifies that the actual
Class has the given Annotation s. |
hasAnnotation, hasDeclaredFields, hasDeclaredMethods, hasFields, hasMethods, hasOnlyDeclaredFields, hasOnlyPublicFields, hasPublicFields, hasPublicMethods, isAbstract, isAnnotation, isAssignableFrom, isFinal, isInterface, isNotAnnotation, isNotFinal, isNotInterface, isProtected, isPublic
as, as, asInstanceOf, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withAssertionState, withFailMessage, withRepresentation, withThreadDumpOnError
@SafeVarargs public final ClassAssert hasAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
AbstractClassAssert
Class
has the given Annotation
s.
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 object