if (isCanonicalClassNameUsed(ins.canonicalClassName, argTypeMeta.name, testMethodMeta.classMeta)) {
return ins.assignCode.trim();
}
}
}
AvailableTypeDetector availableTypeDetector = new AvailableTypeDetector(targetClassMeta);
if (availableTypeDetector.isJavaLangPackageType(argTypeMeta.name)) {
return "null";
} else if (PrimitiveTypeUtil.isPrimitive(argTypeMeta.name)) {
return PrimitiveTypeUtil.getTypeDefaultValue(argTypeMeta.name);
} else if (argTypeMeta.name.matches(".+?\\[\\]$")) {
return "new " + argTypeMeta.name + " {}";
} else if (argTypeMeta.name.matches("List(<[^>]+>)?")
&& availableTypeDetector.isAvailableType("java.util.List", config)) {
targetClassMeta.importedList.add("java.util.ArrayList");
String genericsString = argTypeMeta.getGenericsAsString();
if (genericsString.equals("<?>")) {
genericsString = "";
}
return "new ArrayList" + genericsString + "()";
} else if (argTypeMeta.name.matches("Map(<[^>]+>)?")
&& availableTypeDetector.isAvailableType("java.util.Map", config)) {
targetClassMeta.importedList.add("java.util.HashMap");
String genericsString = argTypeMeta.getGenericsAsString();
if (genericsString.matches("<.*\\?.*>")) {
genericsString = "";
}
return "new HashMap" + genericsString + "()";
} else if (config.mockObjectFramework == MockObjectFramework.EasyMock) {
return "mocks.createMock(" + argTypeMeta.name.replaceAll(RegExp.Generics, StringValue.Empty) + ".class)";
} else if (config.mockObjectFramework == MockObjectFramework.JMock2) {
return "context.mock(" + argTypeMeta.name.replaceAll(RegExp.Generics, StringValue.Empty) + ".class)";
} else if (config.mockObjectFramework == MockObjectFramework.JMockit) {
if (new AvailableTypeDetector(targetClassMeta).isJMockitMockableType(argTypeMeta.name)) {
return "this." + getTestMethodNamePrefix(testMethodMeta, testMethodMeta.testingTargetException) + "_"
+ argName;
} else {
return "null";
}