Package org.assertj.core.api
Class ClassAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,java.lang.Class<?>>
-
- org.assertj.core.api.AbstractClassAssert<ClassAssert>
-
- org.assertj.core.api.ClassAssert
-
- All Implemented Interfaces:
Assert<ClassAssert,java.lang.Class<?>>
,Descriptable<ClassAssert>
,ExtensionPoints<ClassAssert,java.lang.Class<?>>
public class ClassAssert extends AbstractClassAssert<ClassAssert>
Assertion methods forClass
es.To create a new instance of this class, invoke
Assertions.assertThat(Class)
-
-
Field Summary
-
Fields inherited from class org.assertj.core.api.AbstractClassAssert
classes
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, conditions, info, myself, objects
-
-
Constructor Summary
Constructors Constructor Description ClassAssert(java.lang.Class<?> actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassAssert
hasAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
Verifies that the actualClass
has the givenAnnotation
s.-
Methods inherited from class org.assertj.core.api.AbstractClassAssert
hasAnnotation, hasDeclaredFields, hasDeclaredMethods, hasFields, hasMethods, hasOnlyDeclaredFields, hasOnlyPublicFields, hasPublicFields, hasPublicMethods, isAnnotation, isAssignableFrom, isFinal, isInterface, isNotAnnotation, isNotFinal, isNotInterface, isProtected, isPublic
-
Methods inherited from class org.assertj.core.api.AbstractAssert
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, 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, overridingErrorMessage, satisfies, setCustomRepresentation, throwAssertionError, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
-
-
-
-
Method Detail
-
hasAnnotations
@SafeVarargs public final ClassAssert hasAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
Description copied from class:AbstractClassAssert
Verifies that the actualClass
has the givenAnnotation
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);
- Overrides:
hasAnnotations
in classAbstractClassAssert<ClassAssert>
- Parameters:
annotations
- annotations who must be attached to the class
-
-