Class ClassAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<ClassAssert,Class<?>>
org.assertj.reflection.ClassAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<ClassAssert,Class<?>>, org.assertj.core.api.Descriptable<ClassAssert>, org.assertj.core.api.ExtensionPoints<ClassAssert,Class<?>>

public class ClassAssert extends org.assertj.core.api.AbstractAssert<ClassAssert,Class<?>>
Assertions for the Class type.
  • Field Summary

    Fields inherited from class org.assertj.core.api.AbstractAssert

    actual, info, myself, objects, throwUnsupportedExceptionOnEquals
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ClassAssert(Class<?> actual)
    Creates a new ClassAssert.
  • Method Summary

    Modifier and Type
    Method
    Description
    hasDeclaredConstructor(Class<?>... parameterTypes)
    Verifies that the Class has a declared constructor with the given argument types.
    hasDeclaredConstructor(Class<?>[] parameterTypes, java.util.function.Consumer<ConstructorAssert> constructorAssertConsumer)
    Verifies that the Class has a declared constructor with multiple arguments.
    hasDeclaredConstructor(Class<?> parameterType, java.util.function.Consumer<ConstructorAssert> constructorAssertConsumer)
    Verifies that the Class has a declared constructor with a single argument.
    hasDeclaredConstructor(java.util.function.Consumer<ConstructorAssert> constructorAssertConsumer)
    Verifies that the Class has a declared constructor with no arguments.
    Verifies that the Class has a declared field with the given name.
    hasDeclaredField(String fieldName, java.util.function.Consumer<FieldAssert> fieldAssertConsumer)
    Verifies that the Class has a declared field with the given name.
    hasDeclaredMethod(String methodName, Class<?>... parameterTypes)
    Verifies that the Class has a declared method with the given name and argument types.
    hasDeclaredMethod(String methodName, Class<?>[] parameterTypes, java.util.function.Consumer<MethodAssert> methodAssertConsumer)
    Verifies that the Class has a declared method with the given name and multiple arguments.
    hasDeclaredMethod(String methodName, Class<?> parameterType, java.util.function.Consumer<MethodAssert> methodAssertConsumer)
    Verifies that the Class has a declared method with the given name and a single argument.
    hasDeclaredMethod(String methodName, java.util.function.Consumer<MethodAssert> methodAssertConsumer)
    Verifies that the Class has a declared method with the given name and no arguments.
    hasNoDeclaredConstructor(Class<?>... parameterTypes)
    Verifies that the Class does not have a declared constructor with the given argument types.
    Verifies that the Class does not have a declared field with the given name.
    hasNoDeclaredMethod(String methodName, Class<?>... parameterTypes)
    Verifies that the Class has a declared method with the given name and argument types.

    Methods inherited from class org.assertj.core.api.AbstractAssert

    asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.assertj.core.api.Descriptable

    as, as, as, describedAs
  • Constructor Details

    • ClassAssert

      protected ClassAssert(Class<?> actual)
      Creates a new ClassAssert.
      Parameters:
      actual - The actual value.
  • Method Details

    • hasDeclaredConstructor

      public ClassAssert hasDeclaredConstructor(Class<?>... parameterTypes)
      Verifies that the Class has a declared constructor with the given argument types.
      Parameters:
      parameterTypes - The types of the constructor arguments.
      Returns:
      this ClassAssert instance.
    • hasDeclaredConstructor

      public ClassAssert hasDeclaredConstructor(java.util.function.Consumer<ConstructorAssert> constructorAssertConsumer)
      Verifies that the Class has a declared constructor with no arguments.
      Parameters:
      constructorAssertConsumer - Consumer that is invoked with an instance of ConstructorAssert, to perform additional assertions on the matched constructor.
      Returns:
      this ClassAssert instance.
    • hasDeclaredConstructor

      public ClassAssert hasDeclaredConstructor(Class<?> parameterType, java.util.function.Consumer<ConstructorAssert> constructorAssertConsumer)
      Verifies that the Class has a declared constructor with a single argument.
      Parameters:
      parameterType - The type of the constructor argument.
      constructorAssertConsumer - Consumer that is invoked with an instance of ConstructorAssert, to perform additional assertions on the matched constructor.
      Returns:
      this ClassAssert instance.
    • hasDeclaredConstructor

      public ClassAssert hasDeclaredConstructor(Class<?>[] parameterTypes, java.util.function.Consumer<ConstructorAssert> constructorAssertConsumer)
      Verifies that the Class has a declared constructor with multiple arguments.
      Parameters:
      parameterTypes - The types of the constructor arguments.
      constructorAssertConsumer - Consumer that is invoked with an instance of ConstructorAssert, to perform additional assertions on the matched constructor.
      Returns:
      this ClassAssert instance.
    • hasNoDeclaredConstructor

      public ClassAssert hasNoDeclaredConstructor(Class<?>... parameterTypes)
      Verifies that the Class does not have a declared constructor with the given argument types.
      Parameters:
      parameterTypes - The types of the constructor arguments.
      Returns:
      this ClassAssert instance.
    • hasDeclaredField

      public ClassAssert hasDeclaredField(String fieldName)
      Verifies that the Class has a declared field with the given name.
      Parameters:
      fieldName - The name of the declared field.
      Returns:
      this ClassAssert instance.
    • hasDeclaredField

      public ClassAssert hasDeclaredField(String fieldName, java.util.function.Consumer<FieldAssert> fieldAssertConsumer)
      Verifies that the Class has a declared field with the given name.
      Parameters:
      fieldName - The name of the declared field.
      fieldAssertConsumer - Consumer that is invoked with an instance of FieldAssert, to perform additional assertions on the matched field.
      Returns:
      this ClassAssert instance.
    • hasNoDeclaredField

      public ClassAssert hasNoDeclaredField(String fieldName)
      Verifies that the Class does not have a declared field with the given name.
      Parameters:
      fieldName - The name of the declared field.
      Returns:
      this ClassAssert instance.
    • hasDeclaredMethod

      public ClassAssert hasDeclaredMethod(String methodName, Class<?>... parameterTypes)
      Verifies that the Class has a declared method with the given name and argument types.
      Parameters:
      methodName - The name of the declared method.
      parameterTypes - The types of the declared method arguments.
      Returns:
      this ClassAssert instance.
    • hasDeclaredMethod

      public ClassAssert hasDeclaredMethod(String methodName, java.util.function.Consumer<MethodAssert> methodAssertConsumer)
      Verifies that the Class has a declared method with the given name and no arguments.
      Parameters:
      methodName - The name of the declared method.
      methodAssertConsumer - Consumer that is invoked with an instance of MethodAssert, to perform additional assertions on the matched method.
      Returns:
      this ClassAssert instance.
    • hasDeclaredMethod

      public ClassAssert hasDeclaredMethod(String methodName, Class<?> parameterType, java.util.function.Consumer<MethodAssert> methodAssertConsumer)
      Verifies that the Class has a declared method with the given name and a single argument.
      Parameters:
      methodName - The name of the declared method.
      parameterType - The type of the declared method argument.
      methodAssertConsumer - Consumer that is invoked with an instance of MethodAssert, to perform additional assertions on the matched method.
      Returns:
      this ClassAssert instance.
    • hasDeclaredMethod

      public ClassAssert hasDeclaredMethod(String methodName, Class<?>[] parameterTypes, java.util.function.Consumer<MethodAssert> methodAssertConsumer)
      Verifies that the Class has a declared method with the given name and multiple arguments.
      Parameters:
      methodName - The name of the declared method.
      parameterTypes - The types of the declared method arguments.
      methodAssertConsumer - Consumer that is invoked with an instance of MethodAssert, to perform additional assertions on the matched method.
      Returns:
      this ClassAssert instance.
    • hasNoDeclaredMethod

      public ClassAssert hasNoDeclaredMethod(String methodName, Class<?>... parameterTypes)
      Verifies that the Class has a declared method with the given name and argument types.
      Parameters:
      methodName - The name of the declared method.
      parameterTypes - The types of the declared method arguments.
      Returns:
      this ClassAssert instance.