Enum Class Messages

java.lang.Object
java.lang.Enum<Messages>
io.github.valentinherrmann.levenshtein.Messages
All Implemented Interfaces:
Serializable, Comparable<Messages>, Constable

public enum Messages extends Enum<Messages>
Central message catalog for all assertion and feedback messages shown to students.

Language Switching

All messages are available in German and English. The active language is read from LevenshteinSettings.getLanguage() every time a message is requested, so it can be switched at runtime, e.g. in a static initializer or @BeforeAll of the exam's test class:

LevenshteinSettings.setLanguage(LevenshteinSettings.Language.ENGLISH);

Usage

All entries are format templates:

fail(Messages.CLASS_NOT_IMPLEMENTED.format(name, pkg));
assertThat(x).withFailMessage(Messages.CAST_FAILED.get(), value, actualType, expectedType).isEqualTo(y);
See Also:
  • Enum Constant Details

    • WRAPPER_DEVIATION

      public static final Messages WRAPPER_DEVIATION
      Shown when a structural element deviates from the expected signature. Placeholders: (1) parent class name, (2) expected toString, (3) actual toString.
    • WRAPPER_MISSING

      public static final Messages WRAPPER_MISSING
      Shown when a structural element is completely missing. Placeholders: (1) parent class name, (2) expected toString.
    • MISSING_MODIFIERS

      public static final Messages MISSING_MODIFIERS
      Appended to a deviation when expected modifiers are missing. Placeholders: (1) the missing modifiers, e.g. "static".
    • UNEXPECTED_MODIFIERS

      public static final Messages UNEXPECTED_MODIFIERS
      Appended to a deviation when the actual element has modifiers that are not expected. Placeholders: (1) the unexpected modifiers, e.g. "static".
    • WRAPPER_UNCHECKED

      public static final Messages WRAPPER_UNCHECKED
      Shown when a structural element has not been checked yet (debug / internal state). Placeholders: (1) parent class name, (2) expected toString.
    • CLASS_DEVIATION

      public static final Messages CLASS_DEVIATION
      Intro line for a deviating class in ClassWrapper.toString().
    • CLASS_MISSING

      public static final Messages CLASS_MISSING
      Intro line for a missing class in ClassWrapper.toString().
    • CLASS_UNCHECKED

      public static final Messages CLASS_UNCHECKED
      Intro line for an unchecked class in ClassWrapper.toString().
    • CLASS_REPORT

      public static final Messages CLASS_REPORT
      Report of a class in ClassWrapper.toString(). Placeholders: (1) intro line, (2) package name, (3) expected toString, (4) actual toString.
    • DEFAULT_PACKAGE

      public static final Messages DEFAULT_PACKAGE
      Shown instead of the package name for the default package.
    • WRAPPER_CHECK_FAILED

      public static final Messages WRAPPER_CHECK_FAILED
      Shown in a structural test when checking one element failed unexpectedly. Placeholders: (1) class name, (2) expected toString, (3) cause.
    • CLASS_NOT_IMPLEMENTED

      public static final Messages CLASS_NOT_IMPLEMENTED
      Shown when the expected class is missing or deviates. Placeholders: (1) class name, (2) package name.
    • CLASS_CANNOT_INSTANTIATE_ABSTRACT

      public static final Messages CLASS_CANNOT_INSTANTIATE_ABSTRACT
      Shown when trying to directly instantiate an abstract class. Placeholder: (1) class name.
    • CLASS_CANNOT_INSTANTIATE_INTERFACE

      public static final Messages CLASS_CANNOT_INSTANTIATE_INTERFACE
      Shown when trying to directly instantiate an interface. Placeholder: (1) interface name.
    • CLASS_INSTANTIATION_FAILED

      public static final Messages CLASS_INSTANTIATION_FAILED
      Shown when instantiating a class via its constructor fails. Placeholder: (1) class name.
    • CLASS_SUBCLASS_INSTANTIATION_FAILED

      public static final Messages CLASS_SUBCLASS_INSTANTIATION_FAILED
      Shown when creating a ByteBuddy dynamic subclass instance fails. Placeholders: (1) class name, (2) error message.
    • MOCK_CLASS_NOT_OVERRIDABLE

      public static final Messages MOCK_CLASS_NOT_OVERRIDABLE
      Shown when a class cannot be subclassed for a mock. Placeholders: (1) class name, (2) reason (e.g. final, record, enum, sealed).
    • MOCK_ENUM_NOT_INSTANTIABLE

      public static final Messages MOCK_ENUM_NOT_INSTANTIABLE
      Shown when an enum should be created without a constructor. Placeholder: (1) class name.
    • MOCK_METHOD_NOT_OVERRIDABLE

      public static final Messages MOCK_METHOD_NOT_OVERRIDABLE
      Shown when a method cannot be overridden in a mock. Placeholders: (1) method signature, (2) class name, (3) reason (e.g. final, static).
    • MOCK_METHOD_NOT_IN_CLASS

      public static final Messages MOCK_METHOD_NOT_IN_CLASS
      Shown when a method wrapper of another class is used for a mock (e.g. the class does not extend it). Placeholders: (1) method signature, (2) class of the method, (3) class of the mock.
    • MOCK_ABSTRACT_NOT_OVERRIDDEN

      public static final Messages MOCK_ABSTRACT_NOT_OVERRIDDEN
      Shown when student code calls an abstract method that the test did not override. Placeholders: (1) method name, (2) class name.
    • MOCK_CALL_COUNT

      public static final Messages MOCK_CALL_COUNT
      Shown when a method was not called as often as expected. Placeholders: (1) method signature, (2) class name, (3) expected count, (4) actual count.
    • MOCK_RECORDED_CALLS

      public static final Messages MOCK_RECORDED_CALLS
      Appended on its own line to MOCK_CALL_COUNT if there were calls. Placeholder: (1) the arguments of each call, e.g. (5), (7).
    • FAILURE_METHOD

      public static final Messages FAILURE_METHOD
      Label of the line naming the method or constructor in a Failure block.
    • FAILURE_SCENARIO

      public static final Messages FAILURE_SCENARIO
      Label of the line describing the scenario (e.g. a generated case) in a Failure block.
    • FAILURE_INPUT

      public static final Messages FAILURE_INPUT
      Label of the line with the input (e.g. the arguments) in a Failure block.
    • FAILURE_EXPECTED

      public static final Messages FAILURE_EXPECTED
      Label of the line with the expected outcome in a Failure block.
    • FAILURE_ACTUAL

      public static final Messages FAILURE_ACTUAL
      Label of the line with the actual outcome in a Failure block.
    • FAILURE_CASES

      public static final Messages FAILURE_CASES
      Appended below a Failure block when several cases were checked. Placeholders: (1) failed cases, (2) all cases.
    • FAILURE_STACK_OVERFLOW_HINT

      public static final Messages FAILURE_STACK_OVERFLOW_HINT
      Appended below a Failure block whose actual outcome is a StackOverflowError.
    • FAILURE_EXPECTED_EXCEPTION

      public static final Messages FAILURE_EXPECTED_EXCEPTION
      Expected outcome of a call that should throw an exception. Placeholder: (1) the exception type.
    • GETTERS_SETTERS_EXPECT_REJECTED

      public static final Messages GETTERS_SETTERS_EXPECT_REJECTED
      Expected outcome of a setter call with an invalid value. Placeholder: (1) the value before the call.
    • GETTERS_SETTERS_SCENARIO

      public static final Messages GETTERS_SETTERS_SCENARIO
      Scenario of a getter/setter case. Placeholders: (1) subtest label, e.g. "setter -> attribute", (2) attribute name.
    • GETTERS_SETTERS_REPORT

      @Deprecated public static final Messages GETTERS_SETTERS_REPORT
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Report of a failed getter/setter test, one line per subtest. Placeholders: (1) attribute name, (2) class name, (3) subtest lines.
    • GETTERS_SETTERS_SETTER_TO_ATTRIBUTE

      public static final Messages GETTERS_SETTERS_SETTER_TO_ATTRIBUTE
      Subtest label: the setter stores the value in the attribute.
    • GETTERS_SETTERS_ATTRIBUTE_TO_GETTER

      public static final Messages GETTERS_SETTERS_ATTRIBUTE_TO_GETTER
      Subtest label: the getter returns the value of the attribute.
    • GETTERS_SETTERS_SETTER_TO_GETTER

      public static final Messages GETTERS_SETTERS_SETTER_TO_GETTER
      Subtest label: the getter returns what the setter set.
    • GETTERS_SETTERS_PASSED

      @Deprecated public static final Messages GETTERS_SETTERS_PASSED
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Result of a passed subtest. *
    • GETTERS_SETTERS_NOT_TESTED

      @Deprecated public static final Messages GETTERS_SETTERS_NOT_TESTED
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Result of a subtest whose getter or setter was not given. *
    • GETTERS_SETTERS_ATTRIBUTE

      @Deprecated public static final Messages GETTERS_SETTERS_ATTRIBUTE
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Names the attribute as the place a value is read from. Placeholders: (1) attribute name.
    • GETTERS_SETTERS_VALUE_NOT_STORED

      @Deprecated public static final Messages GETTERS_SETTERS_VALUE_NOT_STORED
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Shown when a valid value is not stored by the setter. Placeholders: (1) setter name, (2) value, (3) where the value is read from, (4) actual, (5) expected.
    • GETTERS_SETTERS_INVALID_VALUE_STORED

      @Deprecated public static final Messages GETTERS_SETTERS_INVALID_VALUE_STORED
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Shown when the setter stores a value that violates the setter condition. Placeholders: (1) setter name, (2) value, (3) where the value is read from, (4) actual, (5) value before.
    • GETTERS_SETTERS_WRONG_VALUE_RETURNED

      @Deprecated public static final Messages GETTERS_SETTERS_WRONG_VALUE_RETURNED
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Shown when the getter does not return the value of the attribute. Placeholders: (1) attribute, (2) attribute value, (3) getter name, (4) returned value.
    • GETTERS_SETTERS_THREW

      @Deprecated public static final Messages GETTERS_SETTERS_THREW
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Shown when a getter or setter throws an exception for a valid value. Placeholders: (1) method name, (2) argument (empty for getters), (3) exception.
    • GETTER_WRONG_VALUE

      @Deprecated public static final Messages GETTER_WRONG_VALUE
      Deprecated.
      no longer used, testGetter reports with the GETTERS_SETTERS_* messages
      Shown when a getter method does not return the expected attribute value. Placeholders: (1) getter signature, (2) expected value, (3) actual value.
    • METHOD_NOT_IMPLEMENTED

      public static final Messages METHOD_NOT_IMPLEMENTED
      Shown when the expected method is missing or deviates. Placeholders: (1) method signature, (2) class name.
    • METHOD_INVOCATION_EXCEPTION

      @Deprecated public static final Messages METHOD_INVOCATION_EXCEPTION
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Shown when invoking a method throws an unexpected exception. Placeholders: (1) method signature, (2) class name.
    • INVOCATION_ARGUMENTS

      public static final Messages INVOCATION_ARGUMENTS
      Appended on its own line to a failed constructor or method call with arguments. Placeholder: (1) the argument values, e.g. 2.5, "text".
    • ARGUMENT_DOES_NOT_FIT

      public static final Messages ARGUMENT_DOES_NOT_FIT
      Shown when an argument does not fit the (deviating numeric) parameter type of the student's method. Placeholders: (1) argument position, (2) value, (3) parameter type, (4) signature.
    • ATTRIBUTE_NOT_IMPLEMENTED

      public static final Messages ATTRIBUTE_NOT_IMPLEMENTED
      Shown when the expected attribute is missing or deviates. Placeholders: (1) attribute name, (2) class name.
    • ATTRIBUTE_ACCESS_FAILED

      public static final Messages ATTRIBUTE_ACCESS_FAILED
      Shown when reading the value of an attribute fails. Placeholders: (1) attribute name, (2) class name, (3) cause / exception message.
    • ATTRIBUTE_FINAL_CANNOT_SET

      public static final Messages ATTRIBUTE_FINAL_CANNOT_SET
      Shown when trying to set the value of a final attribute. Placeholders: (1) attribute name, (2) class name.
    • ATTRIBUTE_SET_FAILED

      public static final Messages ATTRIBUTE_SET_FAILED
      Shown when setting the value of an attribute fails for an unexpected reason. Placeholders: (1) attribute name, (2) class name.
    • CONSTRUCTOR_NOT_IMPLEMENTED

      public static final Messages CONSTRUCTOR_NOT_IMPLEMENTED
      Shown when the expected constructor is missing or deviates. Placeholders: (1) constructor signature, (2) class name.
    • CONSTRUCTOR_INVOCATION_FAILED

      @Deprecated public static final Messages CONSTRUCTOR_INVOCATION_FAILED
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Shown when invoking a constructor throws an unexpected exception. Placeholders: (1) constructor signature, (2) class name, (3) exception message.
    • EXPECTED_EXCEPTION_NOT_THROWN

      @Deprecated public static final Messages EXPECTED_EXCEPTION_NOT_THROWN
      Deprecated.
      no longer used, behaviour failures are reported as Failure block
      Shown when student code was expected to throw an exception but did not, or threw a different one. Placeholders: (1) member signature, (2) class name, (3) expected exception type, (4) actual outcome.
    • NOTHING_THROWN

      public static final Messages NOTHING_THROWN
      Used as the "actual outcome" of EXPECTED_EXCEPTION_NOT_THROWN when nothing was thrown.
    • CAST_FAILED

      public static final Messages CAST_FAILED
      Shown when a value returned by student code cannot be converted to the expected type. Placeholders: (1) value, (2) actual type, (3) expected type.
    • NULL_NOT_ALLOWED

      public static final Messages NULL_NOT_ALLOWED
      Thrown internally when a value is null where null is not permitted.
  • Method Details

    • values

      public static Messages[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Messages valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • get

      public String get()
      Returns the message in the language currently configured in LevenshteinSettings.getLanguage(). The language is resolved on every call, so it can be changed at runtime (e.g. in @BeforeAll).
      Returns:
      the localized message template
    • format

      public String format(Object... args)
      Formats the localized message template with the given arguments.
      Parameters:
      args - the format arguments
      Returns:
      the formatted, localized message
    • toString

      public String toString()
      Overrides:
      toString in class Enum<Messages>