From f9621a6f2e6aeb1bbebbeba0d5d86fad8b7eabbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Sun, 21 Feb 2021 10:49:30 +0800 Subject: [PATCH] allow default mock with target --- .../agent/transformer/TestableClassTransformer.java | 7 +++---- .../com/alibaba/testable/core/annotation/MockWith.java | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java b/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java index 786ae7f..1612dd0 100644 --- a/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java +++ b/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java @@ -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(); } } diff --git a/testable-core/src/main/java/com/alibaba/testable/core/annotation/MockWith.java b/testable-core/src/main/java/com/alibaba/testable/core/annotation/MockWith.java index 29e53c8..4bd719b 100644 --- a/testable-core/src/main/java/com/alibaba/testable/core/annotation/MockWith.java +++ b/testable-core/src/main/java/com/alibaba/testable/core/annotation/MockWith.java @@ -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;