Enum Class Messages
- All Implemented Interfaces:
Serializable, Comparable<Messages>, Constable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionShown when an argument does not fit the (deviating numeric) parameter type of the student's method.Shown when reading the value of an attribute fails.Shown when trying to set the value of a final attribute.Shown when the expected attribute is missing or deviates.Shown when setting the value of an attribute fails for an unexpected reason.Shown when a value returned by student code cannot be converted to the expected type.Shown when trying to directly instantiate an abstract class.Shown when trying to directly instantiate an interface.Intro line for a deviating class in ClassWrapper.toString().Shown when instantiating a class via its constructor fails.Intro line for a missing class in ClassWrapper.toString().Shown when the expected class is missing or deviates.Report of a class in ClassWrapper.toString().Shown when creating a ByteBuddy dynamic subclass instance fails.Intro line for an unchecked class in ClassWrapper.toString().Deprecated.Shown when the expected constructor is missing or deviates.Shown instead of the package name for the default package.Deprecated.no longer used, behaviour failures are reported asFailureblockLabel of the line with the actual outcome in aFailureblock.Appended below aFailureblock when several cases were checked.Label of the line with the expected outcome in aFailureblock.Expected outcome of a call that should throw an exception.Label of the line with the input (e.g. the arguments) in aFailureblock.Label of the line naming the method or constructor in aFailureblock.Label of the line describing the scenario (e.g. a generated case) in aFailureblock.Appended below aFailureblock whose actual outcome is aStackOverflowError.Deprecated.no longer used,testGetterreports with theGETTERS_SETTERS_*messagesDeprecated.no longer used, behaviour failures are reported asFailureblockSubtest label: the getter returns the value of the attribute.Expected outcome of a setter call with an invalid value.Deprecated.no longer used, behaviour failures are reported asFailureblockDeprecated.no longer used, behaviour failures are reported asFailureblockDeprecated.no longer used, behaviour failures are reported asFailureblockDeprecated.no longer used, behaviour failures are reported asFailureblockScenario of a getter/setter case.Subtest label: the setter stores the value in the attribute.Subtest label: the getter returns what the setter set.Deprecated.no longer used, behaviour failures are reported asFailureblockDeprecated.no longer used, behaviour failures are reported asFailureblockDeprecated.no longer used, behaviour failures are reported asFailureblockAppended on its own line to a failed constructor or method call with arguments.Deprecated.no longer used, behaviour failures are reported asFailureblockShown when the expected method is missing or deviates.Appended to a deviation when expected modifiers are missing.Shown when student code calls an abstract method that the test did not override.Shown when a method was not called as often as expected.Shown when a class cannot be subclassed for a mock.Shown when an enum should be created without a constructor.Shown when a method wrapper of another class is used for a mock (e.g. the class does not extend it).Shown when a method cannot be overridden in a mock.Appended on its own line toMOCK_CALL_COUNTif there were calls.Used as the "actual outcome" ofEXPECTED_EXCEPTION_NOT_THROWNwhen nothing was thrown.Thrown internally when a value is null where null is not permitted.Appended to a deviation when the actual element has modifiers that are not expected.Shown in a structural test when checking one element failed unexpectedly.Shown when a structural element deviates from the expected signature.Shown when a structural element is completely missing.Shown when a structural element has not been checked yet (debug / internal state). -
Method Summary
Modifier and TypeMethodDescriptionFormats the localized message template with the given arguments.get()Returns the message in the language currently configured inLevenshteinSettings.getLanguage().toString()static MessagesReturns the enum constant of this class with the specified name.static Messages[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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
Shown when a structural element is completely missing. Placeholders: (1) parent class name, (2) expected toString. -
MISSING_MODIFIERS
Appended to a deviation when expected modifiers are missing. Placeholders: (1) the missing modifiers, e.g."static". -
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
Shown when a structural element has not been checked yet (debug / internal state). Placeholders: (1) parent class name, (2) expected toString. -
CLASS_DEVIATION
Intro line for a deviating class in ClassWrapper.toString(). -
CLASS_MISSING
Intro line for a missing class in ClassWrapper.toString(). -
CLASS_UNCHECKED
Intro line for an unchecked class in ClassWrapper.toString(). -
CLASS_REPORT
Report of a class in ClassWrapper.toString(). Placeholders: (1) intro line, (2) package name, (3) expected toString, (4) actual toString. -
DEFAULT_PACKAGE
Shown instead of the package name for the default package. -
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
Shown when the expected class is missing or deviates. Placeholders: (1) class name, (2) package name. -
CLASS_CANNOT_INSTANTIATE_ABSTRACT
Shown when trying to directly instantiate an abstract class. Placeholder: (1) class name. -
CLASS_CANNOT_INSTANTIATE_INTERFACE
Shown when trying to directly instantiate an interface. Placeholder: (1) interface name. -
CLASS_INSTANTIATION_FAILED
Shown when instantiating a class via its constructor fails. Placeholder: (1) class name. -
CLASS_SUBCLASS_INSTANTIATION_FAILED
Shown when creating a ByteBuddy dynamic subclass instance fails. Placeholders: (1) class name, (2) error message. -
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
Shown when an enum should be created without a constructor. Placeholder: (1) class name. -
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
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
Shown when student code calls an abstract method that the test did not override. Placeholders: (1) method name, (2) class name. -
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
Appended on its own line toMOCK_CALL_COUNTif there were calls. Placeholder: (1) the arguments of each call, e.g.(5), (7). -
FAILURE_METHOD
-
FAILURE_SCENARIO
-
FAILURE_INPUT
-
FAILURE_EXPECTED
-
FAILURE_ACTUAL
-
FAILURE_CASES
-
FAILURE_STACK_OVERFLOW_HINT
Appended below aFailureblock whose actual outcome is aStackOverflowError. -
FAILURE_EXPECTED_EXCEPTION
Expected outcome of a call that should throw an exception. Placeholder: (1) the exception type. -
GETTERS_SETTERS_EXPECT_REJECTED
Expected outcome of a setter call with an invalid value. Placeholder: (1) the value before the call. -
GETTERS_SETTERS_SCENARIO
Scenario of a getter/setter case. Placeholders: (1) subtest label, e.g. "setter -> attribute", (2) attribute name. -
GETTERS_SETTERS_REPORT
Deprecated.no longer used, behaviour failures are reported asFailureblockReport 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
Subtest label: the setter stores the value in the attribute. -
GETTERS_SETTERS_ATTRIBUTE_TO_GETTER
Subtest label: the getter returns the value of the attribute. -
GETTERS_SETTERS_SETTER_TO_GETTER
Subtest label: the getter returns what the setter set. -
GETTERS_SETTERS_PASSED
Deprecated.no longer used, behaviour failures are reported asFailureblockResult of a passed subtest. * -
GETTERS_SETTERS_NOT_TESTED
Deprecated.no longer used, behaviour failures are reported asFailureblockResult of a subtest whose getter or setter was not given. * -
GETTERS_SETTERS_ATTRIBUTE
Deprecated.no longer used, behaviour failures are reported asFailureblockNames the attribute as the place a value is read from. Placeholders: (1) attribute name. -
GETTERS_SETTERS_VALUE_NOT_STORED
Deprecated.no longer used, behaviour failures are reported asFailureblockShown 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.no longer used, behaviour failures are reported asFailureblockShown 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.no longer used, behaviour failures are reported asFailureblockShown 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.no longer used, behaviour failures are reported asFailureblockShown 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.no longer used,testGetterreports with theGETTERS_SETTERS_*messagesShown when a getter method does not return the expected attribute value. Placeholders: (1) getter signature, (2) expected value, (3) actual value. -
METHOD_NOT_IMPLEMENTED
Shown when the expected method is missing or deviates. Placeholders: (1) method signature, (2) class name. -
METHOD_INVOCATION_EXCEPTION
Deprecated.no longer used, behaviour failures are reported asFailureblockShown when invoking a method throws an unexpected exception. Placeholders: (1) method signature, (2) class name. -
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
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
Shown when the expected attribute is missing or deviates. Placeholders: (1) attribute name, (2) class name. -
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
Shown when trying to set the value of a final attribute. Placeholders: (1) attribute name, (2) class name. -
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
Shown when the expected constructor is missing or deviates. Placeholders: (1) constructor signature, (2) class name. -
CONSTRUCTOR_INVOCATION_FAILED
Deprecated.no longer used, behaviour failures are reported asFailureblockShown when invoking a constructor throws an unexpected exception. Placeholders: (1) constructor signature, (2) class name, (3) exception message. -
EXPECTED_EXCEPTION_NOT_THROWN
Deprecated.no longer used, behaviour failures are reported asFailureblockShown 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
Used as the "actual outcome" ofEXPECTED_EXCEPTION_NOT_THROWNwhen nothing was thrown. -
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
Thrown internally when a value is null where null is not permitted.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
get
Returns the message in the language currently configured inLevenshteinSettings.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
-
toString
-
Failureblock