MethodTester

@Deprecated(since = "0.7.0", forRemoval = true)
public class MethodTester(source)

Deprecated (for removal)

Since version 0.7.0

A method 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 MethodTester(ClassTester<? extends Object> classTester, String methodName, double similarity, int accessModifier, Class<? extends Object> returnType, List<ParameterMatcher> parameters, boolean allowSuperClass)
Constructs and initializes a method tester.
public void MethodTester(ClassTester<? extends Object> classTester, String methodName, double similarity, int accessModifier, Class<? extends Object> returnType, List<ParameterMatcher> parameters)
Constructs and initializes a method tester.
public void MethodTester(ClassTester<? extends Object> classTester, String methodName, double similarity, int accessModifier, Class<? extends Object> returnType, ArrayList<ParameterMatcher> parameters, boolean allowSuperClass, boolean looseReturnTypeChecking)
Constructs and initializes a method tester.
public void MethodTester(ClassTester<? extends Object> classTester, String methodName, double similarity, int accessModifier, Class<? extends Object> returnType)
Constructs and initializes a method tester.
public void MethodTester(ClassTester<? extends Object> classTester, String methodName, double similarity, int accessModifier)
Constructs and initializes a method tester.
public void MethodTester(ClassTester<? extends Object> classTester, String methodName, double similarity, Class<? extends Object> returnType, ArrayList<ParameterMatcher> parameters)
Constructs and initializes a method tester.
public void MethodTester(ClassTester<? extends Object> classTester, String methodName, double similarity)
Constructs and initializes a method tester.
public void MethodTester(ClassTester<? extends Object> classTester, String methodName)
Constructs and initializes a method tester.

Properties

Link copied to clipboard
public int accessModifier
The expected access modifier count.
Link copied to clipboard
public boolean allowSuperClass
Indicator if super class check are allowed.
Link copied to clipboard
public ClassTester<? extends Object> classTester
A class test (used for invoking).
Link copied to clipboard
The method identifier containing the name of the method and the similarity to accept alternative identifiers.
Link copied to clipboard
The expected parameters of the method.
Link copied to clipboard
public Class<? extends Object> returnType
The expected return type of the method.
Link copied to clipboard
The resolved method that will be tested.

Functions

Link copied to clipboard
public void addParameter(Class<? extends Object> type)
Adds an expected parameter matchers to this tester.
public void addParameter(Array<ParameterMatcher> parameterMatchers)
public void addParameter(Class<? extends Object> type, String name, double similarity)
Adds an expected parameters' matcher to this tester.
Link copied to clipboard
public void assertAccessModifier()
Tests whether the actual access modifier count matches with the expected one.
Link copied to clipboard
public void assertClassResolved()
Tests whether the class tester used to invoke the method can be resolved.
Link copied to clipboard
Tests whether the class tester used to invoke the method is not null.
Link copied to clipboard
public void assertConstructsNotUsed(List<Class<? extends CtCodeElement>> disallowedConstructs)
Tests whether none of the blacklisted constructs where used in the constructor.
Link copied to clipboard
public void assertInvokeable()
Tests whether the method can be invoked.
Link copied to clipboard
public static void assertMethodNotNull(Method m, String name)
Tests whether the specified method is not null.
Link copied to clipboard
public void assertMethodResolved()
Tests whether the test method could be resolved.
Link copied to clipboard
public void assertParametersMatch()
Tests whether the method parameters matches with the expected parameters.
public static void assertParametersMatch(List<ParameterMatcher> expectedParameters, List<Parameter> actualParameters, boolean ignoreNames)
public static void assertParametersMatch(Method m, String methodName, List<ParameterMatcher> parameters, boolean ignoreNames)
Tests whether the method parameters match.
Link copied to clipboard
public void assertReturnType()
Tests whether the actual return type matches the expected return type.
Link copied to clipboard
public void assertReturnValueEquals(Object expected, Array<Object> params)
public void assertReturnValueEquals(Object expected, String additionalMessage, Array<Object> params)
Tests whether the return value after the invocation with the specified parameters are correct.
Link copied to clipboard
Assures that the method has been resolved.
Link copied to clipboard
public boolean classResolved()
Returns true if the class tester used to invoke the method is not null and can be resolved.
Link copied to clipboard
public static int countMatchingParameters(List<ParameterMatcher> expectedParameters, List<Parameter> actualParameters, boolean ignoreNames)
public static int countMatchingParameters(Method m, String methodName, List<ParameterMatcher> parameters, boolean ignoreNames)
Counts the matching parameters.
Link copied to clipboard
public int getAccessModifier()
Returns the expected access modifier count.
Link copied to clipboard
public static List<Method> getAllMethods(Class<? extends Object> clazz)
Returns all fields from a class and its super classes recursively.
Link copied to clipboard
public ClassTester<? extends Object> getClassTester()
Returns the class tester used to invoke the method.
Link copied to clipboard
public static String getClassTesterNullMessage(String methodName)
Generates a predefined class tester null message.
Link copied to clipboard
public static String getInvalidReturnTypeMessage(String methodName)
Generates a predefined message for an invalid return type.
Link copied to clipboard
public int getInvocationCount()
Gets the number of invocations.
Link copied to clipboard
public List<Invocation> getInvocations()
Gets the invocations of the test method.
Link copied to clipboard
Returns the method identifier containing the name of the method and the similarity to accept alternative identifiers.
Link copied to clipboard
public static String getMethodNotFoundMessage(String methodName)
Generates a predefined method not found message.
Link copied to clipboard
Returns the expected parameters.
Link copied to clipboard
Returns the random valid parameter values.
Link copied to clipboard
public Class<? extends Object> getReturnType()
Returns the expected class type of the test method.
Link copied to clipboard
public static String getShouldNotHaveParameterMessage(String methodName)
Generates a predefined should not have parameter message.
Link copied to clipboard
Returns the method that should be tested.
Link copied to clipboard
public Object invoke(Array<Object> params)
Invokes test method using the class tester.
Link copied to clipboard
public boolean invokeable()
Returns true if the method can be invoked, more formally returns true if the class tester used to invoke the method, the method itself can be resolved.
Link copied to clipboard
Invokes the test method with random parameters.
Link copied to clipboard
public boolean isLooseReturnTypeChecking()
Returns true if subtype are allowed for the return type.
Link copied to clipboard
public boolean methodResolved()
Returns true if test method is not null.
Link copied to clipboard
public Method resolveMethod(double similarity)
public Method resolveMethod(Class<? extends Object> theClass, String methodName, double similarity, List<ParameterMatcher> parameters)
public Method resolveMethod(Class<? extends Object> theClass, String methodName, double similarity, List<ParameterMatcher> parameters, boolean allowSuperClass)
Resolves the method with the tolerances, more formally the method is searched first using its name.
Link copied to clipboard
public static String safeArrayToString(Array<Object> array)
Represents a safe string as an array.
Link copied to clipboard
public void setAccessModifier(int accessModifier)
Sets the expected access modifier count to the new value.
Link copied to clipboard
public void setClassTester(ClassTester<? extends Object> classTester)
Sets the class tester used to invoke the method to the specified value.
Link copied to clipboard
public void setLooseReturnTypeChecking(boolean looseReturnTypeChecking)
Sets the boolean value whether to allow subtypes for the return type.
Link copied to clipboard
public void setMethodIdentifier(IdentifierMatcher methodIdentifier)
Set the method identifier containing the name of the method and the similarity to accept alternative identifiers to the specified value.
Link copied to clipboard
public void setParameters(List<ParameterMatcher> parameters)
Sets the expected parameters to the specified value.
Link copied to clipboard
public void setReturnType(Class<? extends Object> returnType)
Sets the expected class type of the test method to the specified value.
Link copied to clipboard
public void setTheMethod(Method theMethod)
Sets the method that should be tested to the specified value.
Link copied to clipboard
Verifies that the method was declared correctly.