MethodTester
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.
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
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
The expected return type of the method.
Functions
Link copied to clipboard
Adds an expected parameter matchers to this tester.
Adds an expected parameters' matcher to this tester.
Link copied to clipboard
Tests whether the actual access modifier count matches with the expected one.
Link copied to clipboard
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
Tests whether none of the blacklisted constructs where used in the constructor.
Link copied to clipboard
Tests whether the method can be invoked.
Link copied to clipboard
Tests whether the specified method is not
null
.Link copied to clipboard
Tests whether the test method could be resolved.
Link copied to clipboard
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
Tests whether the actual return type matches the expected return type.
Link copied to clipboard
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
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
Returns the expected access modifier count.
Link copied to clipboard
Returns all fields from a class and its super classes recursively.
Link copied to clipboard
Returns the class tester used to invoke the method.
Link copied to clipboard
Generates a predefined class tester
null
message.Link copied to clipboard
Generates a predefined message for an invalid return type.
Link copied to clipboard
Gets the number of invocations.
Link copied to clipboard
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
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
Returns the expected class type of the test method.
Link copied to clipboard
Generates a predefined should not have parameter message.
Link copied to clipboard
Returns the method that should be tested.
Link copied to clipboard
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
Returns
true
if subtype are allowed for the return type.Link copied to clipboard
Returns
true
if test method is not null
.Link copied to clipboard
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
Represents a safe string as an array.
Link copied to clipboard
Sets the expected access modifier count to the new value.
Link copied to clipboard
Sets the class tester used to invoke the method to the specified value.
Link copied to clipboard
Sets the boolean value whether to allow subtypes for the return type.
Link copied to clipboard
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
Sets the expected parameters to the specified value.
Link copied to clipboard
Sets the expected class type of the test method to the specified value.
Link copied to clipboard
Sets the method that should be tested to the specified value.
Link copied to clipboard
Verifies that the method was declared correctly.