allow default mock with target

This commit is contained in:
金戟 2021-02-21 10:49:30 +08:00
parent 55ccabbb39
commit f9621a6f2e
2 changed files with 3 additions and 5 deletions

View File

@ -14,6 +14,7 @@ import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InnerClassNode;
import javax.lang.model.type.NullType;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@ -229,10 +230,8 @@ public class TestableClassTransformer implements ClassFileTransformer {
ClassType type = AnnotationUtil.getAnnotationParameter(an, FIELD_TREAT_AS, ClassType.GuessByName,
ClassType.class);
if (isExpectedType(cn.name, type, expectedType)) {
Type clazz = AnnotationUtil.getAnnotationParameter(an, FIELD_VALUE, null, Type.class);
if (clazz == null) {
return null;
}
Type clazz = AnnotationUtil.getAnnotationParameter(an, FIELD_VALUE,
Type.getType(NullType.class), Type.class);
return clazz.getClassName();
}
}

View File

@ -18,7 +18,6 @@ public @interface MockWith {
/**
* explicitly specify mock class
* @note this parameter will become mandatory in v0.6
* @return type of mock class
*/
Class<?> value() default NullType.class;