ClassTester

@Deprecated(since = "0.7.0", forRemoval = true)
public class ClassTester<T>(source)

Deprecated (for removal)

Since version 0.7.0

A class tester which tests properties of a class. This class is deprecated and will be removed in a future release. Use the new API located in the org.tudalgo.algoutils.tutor.general.reflections package instead.

Author

Ruben Deisenroth

Constructors

Link copied to clipboard
public void ClassTester(String packageName, String className, double similarity, int accessModifier, Class<? super T> superClass, List<IdentifierMatcher> implementsInterfaces, T classInstance)
Constructs and initializes a class tester.
public void ClassTester(String packageName, String className, double similarity, int accessModifier, Class<? super T> superClass, ArrayList<IdentifierMatcher> implementsInterfaces)
Constructs and initializes a class tester.
public void ClassTester(String packageName, String className, double similarity, int accessModifier)
Constructs and initializes a class tester.
public void ClassTester(String packageName, String className, double similarity)
Constructs and initializes a class tester.
public void ClassTester(String packageName, String className)
Constructs and initializes a class tester.
public void ClassTester(Class<T> clazz)
Constructs and initializes a class tester.

Properties

Link copied to clipboard
public int accessModifier
The expected access modifier count.
Link copied to clipboard
The class identifier containing the name of the class and the similarity to accept alternative identifiers.
Link copied to clipboard
The class instance of the tested class.
Link copied to clipboard
The matcher used for the interfaces that are expected to be implemented.
Link copied to clipboard
public Launcher spoon
The spoon launcher which allows source code analysis and transformation.
Link copied to clipboard
public Class<? super T> superClass
The expected super class.
Link copied to clipboard
public Class<T> theClass
The resolved class that will be tested.

Functions

Link copied to clipboard
public void addImplementsInterface(String interfaceName)
public void addImplementsInterface(IdentifierMatcher interfaceMatcher)
public void addImplementsInterface(String interfaceName, double similarity)
Adds an interface matcher used for the test class.
Link copied to clipboard
public void assertAccessModifier()
Tests whether the access modifier count is correct and fails it with a predefined message if it fails.
Link copied to clipboard
Tests whether the class instance of the tested class is not null.
Link copied to clipboard
public static void assertClassNotNull(Class<? extends Object> theClass, String className)
Tests whether the class instance is not null and fails with a proper message if it is null.
Link copied to clipboard
public void assertClassResolved()
Tests that theClass is not null and fails with the predefined message if it cannot be resolved.
Link copied to clipboard
public void assertConstructorValid(Constructor<T> constructor, int accessModifier, ArrayList<ParameterMatcher> parameters)
public void assertConstructorValid(Constructor<T> constructor, int accessModifier, Array<ParameterMatcher> parameters)
Tests whether a constructor was declared correctly.
Link copied to clipboard
Tests whether there are no interface extension.
Link copied to clipboard
public void assertEnumConstants(Array<String> expectedConstants)
Tests whether the enum constants with the specified names exists.
Link copied to clipboard
public void assertFieldEquals(Field field, Object expected)
Tests whether a field has a certain content.
public void assertFieldEquals(Field field, Object expected, String additionalMessage)
Tests whether the specified field has a specified content.
Link copied to clipboard
public void assertHasGetter(Field attribute, Array<ParameterMatcher> parameters)
Tests whether the specified field has a Getter-Method.
Link copied to clipboard
public void assertHasSetter(Field attribute)
public void assertHasSetter(Field attribute, Object testValue)
Tests whether the specified field has a Setter-Method.
Link copied to clipboard
public void assertImplementsInterfaces(List<IdentifierMatcher> implementsInterfaces)
Tests whether all described interfaces by the specified matchers are being extended.
Link copied to clipboard
public void assertIsEnum()
Tests whether the test class is an enum.
public static void assertIsEnum(Class<? extends Object> theClass, String className)
Tests whether the class instance is an enum.
Link copied to clipboard
public void assertIsInterface()
Tests whether the test class is an interface.
public static void assertIsInterface(Class<? extends Object> theClass, String className)
Tests whether the class instance is an interface.
Link copied to clipboard
public void assertIsPlainClass()
Tests whether the test class is a plain class.
public static void assertIsPlainClass(Class<? extends Object> theClass, String className)
Tests whether the class instance is a plain class.
Link copied to clipboard
Tests whether this class is a spy.
Link copied to clipboard
public void assertSuperclass()
Tests whether the super classes fo the test classes matches the specified super classes.
Link copied to clipboard
Resolves the class if necessary.
Link copied to clipboard
Makes the class a spy if not done already.
Link copied to clipboard
Returns instance of a class tester with the needed configuration for spoon.
Link copied to clipboard
public boolean class_resolved()
Returns true if theClass is not null.
Link copied to clipboard
public boolean classInstanceResolved()
Returns true if the class instance of the tested class is not null.
Link copied to clipboard
public Class<T> findClass()
Resolves a class with the current class name and similarity.
public Class<T> findClass(double similarity)
Resolves a class with the specified similarity.
public Class<T> findClass(String packageName, String className, double similarity)
Resolves a class with the specified name and similarity.
Link copied to clipboard
public static T findInstance<T>(Class<? super T> clazz, String className)
Resolves an instance of a given class (even abstract).
Link copied to clipboard
public static Class<? extends T> generateDerivedClass<T>(Class<T> clazz, String className, String derivedClassName)
Generates a derived class from a specified class.
Link copied to clipboard
public int getAccessModifier()
Returns the expected access modifier.
Link copied to clipboard
Returns all fields of the test class and its super classes.
public static List<Field> getAllFields(Class<? extends Object> clazz)
Returns all fields of a class and its super classes recursively.
Link copied to clipboard
Returns the class matcher used on the test class.
Link copied to clipboard
Returns class instance of the tested class.
Link copied to clipboard
public static String getClassNotFoundMessage(String className)
Generates a predefined class not found message.
Link copied to clipboard
public static Object getDefaultValue(Class<? extends Object> type)
Returns the default value for the specified type.
Link copied to clipboard
public static String getEnumConstantMissingMessage(String constantName)
Generates a predefined message for a missing enum constant.
Link copied to clipboard
public Enum<? extends Object> getEnumValue(String expectedName, double similarity)
Returns a specific enum value.
public static Enum<? extends Object> getEnumValue<T>(Class<Enum<? extends Object>> enumClass, String expectedName, double similarity)
Returns the specified enum value.
Link copied to clipboard
public Object getFieldValue(Field field)
Returns the field content.
public static Object getFieldValue(Object instance, Field field)
Returns the content of a field.
Link copied to clipboard
Returns the implemented interfaces of the tested class.
Link copied to clipboard
public static String getInterfaceNotImplementedMessage(String interfaceName)
Generates a predefined interface not found message.
Link copied to clipboard
public MockingDetails getMockingDetails()
Returns the MockingDetails of theClass.
Link copied to clipboard
public T getNewInstance()
Returns a new test class instance.
Link copied to clipboard
Returns a new test class instance.
Link copied to clipboard
public Enum<? extends Object> getRandomEnumConstant()
Returns a random enum constant.
public static Enum<? extends Object> getRandomEnumConstant(Class<Enum<? extends Object>> enumClass, String enumClassName)
Returns a random enum constant from the available enum constants.
Link copied to clipboard
public static Object getRandomValue(Class<? extends Object> type)
Returns a random value for the specified type.
Link copied to clipboard
public Launcher getSpoon()
Returns the spoon launcher which allows source code analysis and transformation.
Link copied to clipboard
public Class<? super T> getSuperClass()
Returns the super class of the tested class.
Link copied to clipboard
public Class<T> getTheClass()
Returns the test classes if it is already resolved.
Link copied to clipboard
public boolean is_mock()
Returns true if theClass is mocked.
Link copied to clipboard
public boolean is_spy()
Returns true if theClass is a spy.
Link copied to clipboard
public static T legacyFindInstance<T>(Class<? super T> clazz, String className)
Resolves an instance of a given class (even abstract).
Link copied to clipboard
public ClassTester<T> resolve()
Resolves the class and instance and stores them.
Link copied to clipboard
Resolves a field (attribute) with a specified matcher.
Link copied to clipboard
Finds the class to test and stores it.
Link copied to clipboard
Resolves a constructor with the specified parameters.
Resolves a constructor with the parameters.
Link copied to clipboard
public T resolveInstance()
Resolves a test class instance.
Link copied to clipboard
Resolves the class and instance and stores them.
Link copied to clipboard
Resolve a real test class instance.
Link copied to clipboard
public void setAccessModifier(int accessModifier)
Sets the expected access modifier the specified value.
Link copied to clipboard
public void setClassIdentifier(IdentifierMatcher classIdentifier)
Sets the class matcher used on the test class to the new value.
Link copied to clipboard
public void setClassInstance(T classInstance)
Sets class instance of the tested class to the specified value.
Link copied to clipboard
public void setField(Field field, Object value)
Sets a field value to the specified value.
public static void setField(Object instance, Field field, Object value)
Sets the field to the specified value.
Link copied to clipboard
public Object setFieldRandom(Field field)
Sets a field value to a random value.
Link copied to clipboard
public static void setFieldTyped(Field field, Object obj, Object value)
Sets the typed field to the specified value.
Link copied to clipboard
public void setImplementsInterfaces(List<IdentifierMatcher> implementsInterfaces)
Sets the implemented class of the tested class to the specified value.
Link copied to clipboard
public void setSpoon(Launcher spoon)
Sets the spoon launcher which allows source code analysis and transformation to the specified value.
Link copied to clipboard
public void setSuperClass(Class<? super T> superClass)
Sets the super class of the tested class to the specified value.
Link copied to clipboard
public void setTheClass(Class<T> theClass)
Sets the test class instance to the specified class instance.
Link copied to clipboard
public ClassTester<T> verify()
public ClassTester<T> verify(double minSimilarity)
Tests whether the Class is declared correctly.