Class Classes

java.lang.Object
org.assertj.core.internal.Classes

public class Classes extends Object
Reusable assertions for Classs.
Author:
William Delanoue
  • Constructor Details

    • Classes

      public Classes()
  • Method Details

    • instance

      public static Classes instance()
      Returns the singleton instance of this class.
      Returns:
      the singleton instance of this class.
    • assertIsAssignableFrom

      public void assertIsAssignableFrom(AssertionInfo info, Class<?> actual, Class<?>... others)
      Verifies that the actual Class is assignable from all the others classes.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      others - the others Class who this actual class must be assignable.
      Throws:
      NullPointerException - if one of the others is null.
      AssertionError - if actual is null.
      AssertionError - if the actual Class is not assignable from all of the others classes.
    • assertContainsAnnotations

      public void assertContainsAnnotations(AssertionInfo info, Class<?> actual, Class<? extends Annotation>[] annotations)
      Verifies that the actual Class contains the given Annotations.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      annotations - annotations who must be attached to the class
      Throws:
      AssertionError - if actual is null.
      AssertionError - if the actual Class doesn't contains all of these annotations.
    • assertHasPublicFields

      public void assertHasPublicFields(AssertionInfo info, Class<?> actual, String... fields)
      Verifies that the actual Class has the fields.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      fields - the fields who must be present in the class.
      Throws:
      AssertionError - if actual is null.
      AssertionError - if the actual Class doesn't contains all of the field.
    • assertHasOnlyPublicFields

      public void assertHasOnlyPublicFields(AssertionInfo info, Class<?> actual, String... expectedFields)
      Verifies that the actual Class has only the fields and nothing more. in any order.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      expectedFields - all the fields that are expected to be in the class.
      Throws:
      AssertionError - if actual is null.
      AssertionError - if fields are not all the fields of the actual Class.
    • assertHasDeclaredFields

      public void assertHasDeclaredFields(AssertionInfo info, Class<?> actual, String... fields)
      Verifies that the actual Class has the declared fields.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      fields - the fields who must be declared in the class.
      Throws:
      AssertionError - if actual is null.
      AssertionError - if the actual Class doesn't contains all of the field.
    • assertHasOnlyDeclaredFields

      public void assertHasOnlyDeclaredFields(AssertionInfo info, Class<?> actual, String... expectedFields)
      Verifies that the actual Class has the exactly the fields and nothing more. in any order.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      expectedFields - all the fields that are expected to be in the class.
      Throws:
      AssertionError - if actual is null.
      AssertionError - if fields are not all the fields of the actual Class.
    • assertHasMethods

      public void assertHasMethods(AssertionInfo info, Class<?> actual, String... methods)
      Verifies that the actual Class has the methods.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      methods - the methods who must be present in the class.
      Throws:
      AssertionError - if actual is null.
      AssertionError - if the actual Class doesn't contains all the methods.
    • assertHasDeclaredMethods

      public void assertHasDeclaredMethods(AssertionInfo info, Class<?> actual, String... methods)
      Verifies that the actual Class has the declared methods.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      methods - the methods who must be declared in the class.
      Throws:
      AssertionError - if actual is null.
      AssertionError - if the actual Class doesn't contains all the methods.
    • assertHasPublicMethods

      public void assertHasPublicMethods(AssertionInfo info, Class<?> actual, String... methods)
      Verifies that the actual Class has the public methods.
      Parameters:
      info - contains information about the assertion.
      actual - the "actual" Class.
      methods - the public methods who must be present in the class.
      Throws:
      AssertionError - if actual is null.
      AssertionError - if the actual Class doesn't contains all the public methods.
    • classParameterIsNotNull

      public void classParameterIsNotNull(Class<?> clazz)
      used to check that the class to compare is not null, in that case throws a NullPointerException with an explicit message.
      Parameters:
      clazz - the class to check
      Throws:
      NullPointerException - with an explicit message if the given class is null