String checkTargetSourceCode = TrimFilterUtil.doAllFilters(currentTestCaseSourceCode);
// is testing type safe required
if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min + "public\\s+void\\s+[^\\s]*type\\("
+ RegExp.Anything_ZeroOrMore_Min)) {
TestMethodMeta testMethod = new TestMethodMeta();
testMethod.classMeta = targetClassMeta;
testMethod.isTypeTest = true;
dest.add(testMethod);
}
// is testing instantiation required
if (!targetClassMeta.isEnum && targetClassMeta.constructors.size() > 0) {
ConstructorMeta notPrivateConstructor = null;
for (ConstructorMeta constructor : targetClassMeta.constructors) {
if (constructor.accessModifier != AccessModifier.Private) {
notPrivateConstructor = constructor;
break;
}
}
// instantiation test
if (notPrivateConstructor != null) {
if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min
+ "public\\s+void\\s+[^\\s]*instantiation\\(" + RegExp.Anything_ZeroOrMore_Min)) {
TestMethodMeta testMethod = new TestMethodMeta();
testMethod.classMeta = targetClassMeta;
testMethod.isInstantiationTest = true;
dest.add(testMethod);
}
}
}
// test methods
for (MethodMeta methodMeta : targetClassMeta.methods) {
TestMethodMeta testMethodMeta = new TestMethodMeta();
testMethodMeta.methodMeta = methodMeta;
String testMethodNamePrefix = testMethodGenerator.getTestMethodNamePrefix(testMethodMeta);
// the test method is not already exist
String regExpForDiscriminateOverloadMethods = "";
if (!config.testMethodName.isReturnRequired) {
String argDelimiter = Matcher.quoteReplacement(config.testMethodName.argsAreaDelimiter);
regExpForDiscriminateOverloadMethods = "[^" + argDelimiter + "]";
}
String regExpForCheckAlreadyExists = RegExp.Anything_ZeroOrMore_Min + testMethodNamePrefix
+ regExpForDiscriminateOverloadMethods + RegExp.Anything_ZeroOrMore_Min;
regExpForCheckAlreadyExists = Matcher.quoteReplacement(regExpForCheckAlreadyExists);
try {
if (!checkTargetSourceCode.matches(regExpForCheckAlreadyExists)) {
// exclude accessors
if (config.target.isAccessorExcluded && methodMeta.isAccessor) {
continue;
}
// testing target access modifier
if (isPublicMethodAndTestingRequired(methodMeta, config.target)
|| isProtectedMethodAndTestingRequired(methodMeta, config.target)
|| isPackageLocalMethodAndTestingRequired(methodMeta, config.target)) {
dest.add(testMethodGenerator.getTestMethodMeta(methodMeta));
if (config.target.isExceptionPatternRequired) {
// testing exception patterns
for (ExceptionMeta exceptionMeta : methodMeta.throwsExceptions) {
TestMethodMeta newOne = testMethodGenerator
.getTestMethodMeta(methodMeta, exceptionMeta);
dest.add(newOne);
}
}
}