mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-10 20:30:11 +08:00
fix diagnose setup when using MockWith annotation
This commit is contained in:
parent
8dfd0b4516
commit
9e7ceb2dc1
@ -232,6 +232,7 @@ public class TestableClassTransformer implements ClassFileTransformer {
|
||||
if (isExpectedType(cn.name, type, expectedType)) {
|
||||
Type clazz = AnnotationUtil.getAnnotationParameter(an, FIELD_VALUE,
|
||||
Type.getType(NullType.class), Type.class);
|
||||
DiagnoseUtil.setupByClass(ClassUtil.getClassNode(clazz.getClassName()));
|
||||
return clazz.getClassName();
|
||||
}
|
||||
}
|
||||
|
@ -15,21 +15,21 @@ public class DiagnoseUtil {
|
||||
private static final String FIELD_DIAGNOSE = "diagnose";
|
||||
|
||||
public static void setupByClass(ClassNode cn) {
|
||||
if (cn.visibleAnnotations == null) {
|
||||
if (cn == null || cn.visibleAnnotations == null) {
|
||||
return;
|
||||
}
|
||||
for (AnnotationNode an : cn.visibleAnnotations) {
|
||||
setupByAnnotation(an);
|
||||
if (toDotSeparateFullClassName(an.desc).equals(ConstPool.MOCK_DIAGNOSE)) {
|
||||
setupDiagnose(an, FIELD_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupByAnnotation(AnnotationNode an) {
|
||||
// to be remove in v0.6
|
||||
if (toDotSeparateFullClassName(an.desc).equals(MOCK_WITH)) {
|
||||
setupDiagnose(an, FIELD_DIAGNOSE);
|
||||
}
|
||||
if (toDotSeparateFullClassName(an.desc).equals(ConstPool.MOCK_DIAGNOSE)) {
|
||||
setupDiagnose(an, FIELD_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupDiagnose(AnnotationNode an, String fieldDiagnose) {
|
||||
|
Loading…
Reference in New Issue
Block a user