Class ClassAssert

    • Constructor Detail

      • ClassAssert

        public ClassAssert​(Class<?> actual)
    • Method Detail

      • hasAnnotations

        @SafeVarargs
        public final ClassAssert hasAnnotations​(Class<? extends Annotation>... annotations)
        Description copied from class: AbstractClassAssert
        Verifies that the actual Class 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);
        Overrides:
        hasAnnotations in class AbstractClassAssert<ClassAssert>
        Parameters:
        annotations - annotations who must be attached to the class
        Returns:
        this assertions object