// is testing type safe required
if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min
+ "public\\s+void\\s+[^\\s]*type\\("
+ RegExp.Anything_ZeroOrMore_Min)) {
TestMethodMeta meta = new TestMethodMeta();
meta.classMeta = targetClassMeta;
meta.isTypeTest = true;
addTestMethodMetaToListIfNotExists(dest, meta);
}
// 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 meta = new TestMethodMeta();
meta.classMeta = targetClassMeta;
meta.isInstantiationTest = true;
addTestMethodMetaToListIfNotExists(dest, meta);
}
}
}
// test methods
for (MethodMeta methodMeta : targetClassMeta.methods) {
try {
// 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)) {
continue;
}
// -----------
// at least one test method for the target
// the test method is not already exist
StringBuilder IS_ALREADY_EXISTS = new StringBuilder();
IS_ALREADY_EXISTS.append(RegExp.Anything_ZeroOrMore_Min);
// test method signature prefix
TestMethodMeta testMethodMeta = new TestMethodMeta();
testMethodMeta.methodMeta = methodMeta;
String testMethodNamePrefix = testMethodGenerator
.getTestMethodNamePrefix(testMethodMeta);
IS_ALREADY_EXISTS.append(testMethodNamePrefix);
IS_ALREADY_EXISTS.append("[");
IS_ALREADY_EXISTS.append(config.testMethodName.basicDelimiter);
IS_ALREADY_EXISTS.append("\\(");
IS_ALREADY_EXISTS.append("]");
IS_ALREADY_EXISTS.append(RegExp.Anything_ZeroOrMore_Min);
if (!checkTargetSourceCode.matches(Matcher
.quoteReplacement(IS_ALREADY_EXISTS.toString()))) {
// testing normal pattern
TestMethodMeta meta = testMethodGenerator
.getTestMethodMeta(methodMeta);
// extension assertions
meta = appendIfExtensionAssertionsExist(meta, config);
addTestMethodMetaToListIfNotExists(dest, meta);
// testing exception patterns
if (config.target.isExceptionPatternRequired) {
for (ExceptionMeta exceptionMeta : methodMeta.throwsExceptions) {
TestMethodMeta metaEx = testMethodGenerator
.getTestMethodMeta(methodMeta,
exceptionMeta);
// extension assertions
metaEx = appendIfExtensionAssertionsExist(metaEx,
config);
addTestMethodMetaToListIfNotExists(dest, metaEx);
}
}
}
// -----------
// Extension
if (config.isExtensionEnabled) {
// extension arg patterns
List<ExtArg> extArgs = config.extConfiguration.extArgs;
for (ExtArg extArg : extArgs) {
// import and className
for (ArgTypeMeta argType : methodMeta.argTypes) {
if (isCanonicalClassNameUsed(
extArg.canonicalClassName, argType.name,
targetClassMeta)) {
for (ExtArgPattern pattern : extArg.patterns) {
// extension pattern is not matched
// e.g.
// .*?doSomething_A$String_StringIsNull.*?
String IS_ALREADY_EXISTS_FOR_PATTERN = RegExp.Anything_ZeroOrMore_Min
+ testMethodNamePrefix
+ config.testMethodName.basicDelimiter
+ extArg.getCanonicalClassNameInMethodName()
+ "Is"
+ pattern
.getNameWhichFirstCharIsUpper()
+ RegExp.Anything_ZeroOrMore_Min;
IS_ALREADY_EXISTS_FOR_PATTERN = Matcher
.quoteReplacement(IS_ALREADY_EXISTS_FOR_PATTERN);
if (!checkTargetSourceCode
.matches(IS_ALREADY_EXISTS_FOR_PATTERN)) {
// testing target access modifier
TestMethodMeta meta = testMethodGenerator
.getTestMethodMeta(methodMeta,
null);
meta.extArgPattern = pattern;
// extension assertions
meta = appendIfExtensionAssertionsExist(