mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-10 20:30:11 +08:00
allow default mock with target
This commit is contained in:
parent
55ccabbb39
commit
f9621a6f2e
@ -14,6 +14,7 @@ import org.objectweb.asm.tree.AnnotationNode;
|
|||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.InnerClassNode;
|
import org.objectweb.asm.tree.InnerClassNode;
|
||||||
|
|
||||||
|
import javax.lang.model.type.NullType;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -229,10 +230,8 @@ public class TestableClassTransformer implements ClassFileTransformer {
|
|||||||
ClassType type = AnnotationUtil.getAnnotationParameter(an, FIELD_TREAT_AS, ClassType.GuessByName,
|
ClassType type = AnnotationUtil.getAnnotationParameter(an, FIELD_TREAT_AS, ClassType.GuessByName,
|
||||||
ClassType.class);
|
ClassType.class);
|
||||||
if (isExpectedType(cn.name, type, expectedType)) {
|
if (isExpectedType(cn.name, type, expectedType)) {
|
||||||
Type clazz = AnnotationUtil.getAnnotationParameter(an, FIELD_VALUE, null, Type.class);
|
Type clazz = AnnotationUtil.getAnnotationParameter(an, FIELD_VALUE,
|
||||||
if (clazz == null) {
|
Type.getType(NullType.class), Type.class);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return clazz.getClassName();
|
return clazz.getClassName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ public @interface MockWith {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* explicitly specify mock class
|
* explicitly specify mock class
|
||||||
* @note this parameter will become mandatory in v0.6
|
|
||||||
* @return type of mock class
|
* @return type of mock class
|
||||||
*/
|
*/
|
||||||
Class<?> value() default NullType.class;
|
Class<?> value() default NullType.class;
|
||||||
|
Loading…
Reference in New Issue
Block a user