From 14379560ed91bedefab0ee018dcf539818e2877c Mon Sep 17 00:00:00 2001 From: mercyblitz Date: Fri, 18 Oct 2019 15:42:05 +0800 Subject: [PATCH] Polish apache/dubbo#5034 : Refactor --- .../processing/util/AnnotationUtils.java | 99 ++++++++++--- .../util/AnnotationProcessorUtilsTest.java | 138 ------------------ .../processing/util/AnnotationUtilsTest.java | 134 +++++++++++++++-- .../processing/util/TypeUtilsTest.java | 6 +- 4 files changed, 200 insertions(+), 177 deletions(-) delete mode 100644 dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationProcessorUtilsTest.java diff --git a/dubbo-metadata/dubbo-metadata-processor/src/main/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationUtils.java b/dubbo-metadata/dubbo-metadata-processor/src/main/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationUtils.java index b7c348731d9..24f2f0d4e9e 100644 --- a/dubbo-metadata/dubbo-metadata-processor/src/main/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationUtils.java +++ b/dubbo-metadata/dubbo-metadata-processor/src/main/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationUtils.java @@ -28,17 +28,18 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Predicate; import java.util.stream.Collectors; import static java.util.Collections.emptyList; import static org.apache.dubbo.common.function.Predicates.EMPTY_ARRAY; -import static org.apache.dubbo.common.function.Predicates.alwaysTrue; import static org.apache.dubbo.common.function.Streams.filterAll; import static org.apache.dubbo.common.function.Streams.filterFirst; import static org.apache.dubbo.metadata.annotation.processing.util.TypeUtils.getHierarchicalTypes; import static org.apache.dubbo.metadata.annotation.processing.util.TypeUtils.getType; import static org.apache.dubbo.metadata.annotation.processing.util.TypeUtils.isSameType; +import static org.apache.dubbo.metadata.annotation.processing.util.TypeUtils.ofTypeElement; /** * The utilities class for annotation in the package "javax.lang.model.*" @@ -49,7 +50,9 @@ public interface AnnotationUtils { static AnnotationMirror getAnnotation(AnnotatedConstruct annotatedConstruct, Class annotationClass) { - return getAnnotation(annotatedConstruct, annotationClass.getTypeName()); + return annotationClass == null ? + null : + getAnnotation(annotatedConstruct, annotationClass.getTypeName()); } static AnnotationMirror getAnnotation(AnnotatedConstruct annotatedConstruct, CharSequence annotationClassName) { @@ -58,52 +61,103 @@ static AnnotationMirror getAnnotation(AnnotatedConstruct annotatedConstruct, Cha } static List getAnnotations(AnnotatedConstruct annotatedConstruct, Class annotationClass) { - return getAnnotations(annotatedConstruct, annotationClass.getName()); + return annotationClass == null ? + emptyList() : + getAnnotations(annotatedConstruct, annotationClass.getTypeName()); } static List getAnnotations(AnnotatedConstruct annotatedConstruct, CharSequence annotationClassName) { - return annotatedConstruct.getAnnotationMirrors() - .stream() - .filter(annotation -> isSameType(annotation.getAnnotationType(), annotationClassName)) - .collect(Collectors.toList()); + return getAnnotations(annotatedConstruct, + annotation -> isSameType(annotation.getAnnotationType(), annotationClassName)); + } + + static List getAnnotations(AnnotatedConstruct annotatedConstruct) { + return getAnnotations(annotatedConstruct, EMPTY_ARRAY); + } + + static List getAnnotations(AnnotatedConstruct annotatedConstruct, + Predicate... annotationFilters) { + + AnnotatedConstruct actualAnnotatedConstruct = annotatedConstruct; + + if (annotatedConstruct instanceof TypeMirror) { + actualAnnotatedConstruct = ofTypeElement((TypeMirror) actualAnnotatedConstruct); + } + + return actualAnnotatedConstruct == null ? + emptyList() : + filterAll((List) actualAnnotatedConstruct.getAnnotationMirrors(), annotationFilters); } static List getAllAnnotations(TypeMirror type) { - return getAllAnnotations(type, alwaysTrue()); + return getAllAnnotations(ofTypeElement(type)); + } + + static List getAllAnnotations(Element element) { + return getAllAnnotations(element, EMPTY_ARRAY); + } + + static List getAllAnnotations(TypeMirror type, Class annotationClass) { + return getAllAnnotations(ofTypeElement(type), annotationClass); + } + + static List getAllAnnotations(Element element, Class annotationClass) { + return element == null || annotationClass == null ? + emptyList() : + getAllAnnotations(element, annotationClass.getTypeName()); + } + + static List getAllAnnotations(TypeMirror type, CharSequence annotationClassName) { + return getAllAnnotations(ofTypeElement(type), annotationClassName); + } + + static List getAllAnnotations(Element element, CharSequence annotationClassName) { + return getAllAnnotations(element, annotation -> isSameType(annotation.getAnnotationType(), annotationClassName)); } static List getAllAnnotations(TypeMirror type, Predicate... annotationFilters) { - return filterAll(getHierarchicalTypes(type) + return getAllAnnotations(ofTypeElement(type), annotationFilters); + } + + static List getAllAnnotations(Element element, Predicate... annotationFilters) { + return filterAll(getHierarchicalTypes(element) .stream() - .map(AnnotatedConstruct::getAnnotationMirrors) + .map(AnnotationUtils::getAnnotations) .flatMap(Collection::stream) .collect(Collectors.toList()), annotationFilters); } - static List getAllAnnotations(Element element) { - return getAllAnnotations(element, EMPTY_ARRAY); + static List getAllAnnotations(ProcessingEnvironment processingEnv, Type annotatedType) { + return getAllAnnotations(processingEnv, annotatedType, EMPTY_ARRAY); } - static List getAllAnnotations(Element element, Predicate... annotationFilters) { - return element == null ? emptyList() : getAllAnnotations(element.asType(), annotationFilters); + static List getAllAnnotations(ProcessingEnvironment processingEnv, Type annotatedType, + Predicate... annotationFilters) { + return annotatedType == null ? + emptyList() : + getAllAnnotations(processingEnv, annotatedType.getTypeName(), annotationFilters); } - static List getAllAnnotations(ProcessingEnvironment processingEnv, Type type) { - return getAllAnnotations(processingEnv, type, EMPTY_ARRAY); + static List getAllAnnotations(ProcessingEnvironment processingEnv, CharSequence annotatedTypeName, + Predicate... annotationFilters) { + return getAllAnnotations(getType(processingEnv, annotatedTypeName), annotationFilters); } - static List getAllAnnotations(ProcessingEnvironment processingEnv, Type type, - Predicate... annotationFilters) { - return getAllAnnotations(getType(processingEnv, type), annotationFilters); + static AnnotationMirror findAnnotation(TypeMirror type, Class annotationClass) { + return annotationClass == null ? null : findAnnotation(type, annotationClass.getTypeName()); } static AnnotationMirror findAnnotation(TypeMirror type, CharSequence annotationClassName) { - return filterFirst(getAllAnnotations(type, annotation -> isSameType(annotation.getAnnotationType(), annotationClassName))); + return findAnnotation(ofTypeElement(type), annotationClassName); + } + + static AnnotationMirror findAnnotation(Element element, Class annotationClass) { + return annotationClass == null ? null : findAnnotation(element, annotationClass.getTypeName()); } static AnnotationMirror findAnnotation(Element element, CharSequence annotationClassName) { - return element == null ? null : findAnnotation(element.asType(), annotationClassName); + return filterFirst(getAllAnnotations(element, annotation -> isSameType(annotation.getAnnotationType(), annotationClassName))); } static T getAttribute(AnnotationMirror annotation, String attributeName) { @@ -115,7 +169,7 @@ static T getAttribute(Map entry : attributesMap.entrySet()) { ExecutableElement executableElement = entry.getKey(); - if (attributeName.equals(executableElement.getSimpleName().toString())) { + if (Objects.equals(attributeName, executableElement.getSimpleName().toString())) { attributeValue = (T) entry.getValue().getValue(); break; } @@ -126,5 +180,4 @@ static T getAttribute(Map T getValue(AnnotationMirror annotation) { return (T) getAttribute(annotation, "value"); } - } diff --git a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationProcessorUtilsTest.java b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationProcessorUtilsTest.java deleted file mode 100644 index e0e0137e18c..00000000000 --- a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationProcessorUtilsTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.metadata.annotation.processing.util; - -import org.apache.dubbo.metadata.annotation.processing.AbstractAnnotationProcessingTest; -import org.apache.dubbo.metadata.annotation.processing.model.Model; -import org.apache.dubbo.metadata.tools.DefaultTestService; -import org.apache.dubbo.metadata.tools.GenericTestService; -import org.apache.dubbo.metadata.tools.TestService; -import org.apache.dubbo.metadata.tools.TestServiceImpl; - -import org.junit.jupiter.api.Test; - -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.POST; -import java.io.Serializable; -import java.util.EventListener; -import java.util.List; -import java.util.Set; - -import static org.apache.dubbo.metadata.annotation.processing.util.AnnotationUtils.getAnnotation; -import static org.apache.dubbo.metadata.annotation.processing.util.AnnotationUtils.getValue; -import static org.apache.dubbo.metadata.annotation.processing.util.MethodUtils.findMethod; -import static org.apache.dubbo.metadata.annotation.processing.util.MethodUtils.getOverrideMethod; -import static org.apache.dubbo.metadata.annotation.processing.util.TypeUtils.getHierarchicalTypes; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * {@link AnnotationProcessorUtils} Test - * - * @since 2.7.5 - */ -public class AnnotationProcessorUtilsTest extends AbstractAnnotationProcessingTest { - - private TypeElement testType; - - @Override - protected void beforeEach() { - testType = getType(TestServiceImpl.class); - } - - @Override - protected void addCompiledClasses(Set> classesToBeCompiled) { - classesToBeCompiled.add(TestServiceImpl.class); - } - - @Test - public void testGetHierarchicalTypes() { - Set hierarchicalTypes = getHierarchicalTypes(testType); - assertEquals(8, hierarchicalTypes.size()); - assertTrue(hierarchicalTypes.contains(getType(TestServiceImpl.class))); - assertTrue(hierarchicalTypes.contains(getType(GenericTestService.class))); - assertTrue(hierarchicalTypes.contains(getType(TestService.class))); - assertTrue(hierarchicalTypes.contains(getType(DefaultTestService.class))); - assertTrue(hierarchicalTypes.contains(getType(Object.class))); - assertTrue(hierarchicalTypes.contains(getType(AutoCloseable.class))); - assertTrue(hierarchicalTypes.contains(getType(Serializable.class))); - assertTrue(hierarchicalTypes.contains(getType(EventListener.class))); - } - - @Test - public void testMethods() { - } - - @Test - public void testFindMethod() { - ExecutableElement method = findMethod(testType, "echo", String.class); - assertEquals("echo", method.getSimpleName().toString()); - - method = findMethod(testType, "model", Model.class); - assertEquals("model", method.getSimpleName().toString()); - - method = findMethod(testType, "hashCode"); - assertEquals("hashCode", method.getSimpleName().toString()); - } - - @Test - public void testGetOverrideMethod() { - ExecutableElement method = findMethod(testType, "echo", String.class); - ExecutableElement declaringMethod = findMethod(getType(TestService.class), "echo", String.class); - assertEquals(method, getOverrideMethod(processingEnv, testType, declaringMethod)); - } - - @Test - public void testGetHierarchicalMethods() { -// List methods = getMethods(testType, Object.class); -// methods.forEach(method -> { -// List m = getAllDeclaredMethods(method); -// if ("echo".equals(method.getSimpleName().toString())) { -// assertEquals(4, m.size()); -// } else { -// assertEquals(2, m.size()); -// } -// }); - } - - @Test - public void testGetAllDeclaredMethods() { - List methods = MethodUtils.getAllDeclaredMethods(testType, Object.class); - assertEquals(6, methods.size()); - } - - @Test - public void testFindAnnotation() { - ExecutableElement modelMethodFromEchoService = findMethod(getType(TestService.class), "model", Model.class); - ExecutableElement modelMethodFromTestEchoService = findMethod(testType, "model", Model.class); - AnnotationMirror annotation = getAnnotation(modelMethodFromEchoService, POST.class); - AnnotationMirror annotation2 = getAnnotation(modelMethodFromTestEchoService, POST.class); - assertEquals(annotation, annotation2); - } - - @Test - public void testFindMetaAnnotation() { - ExecutableElement method = findMethod(testType, "model", Model.class); - AnnotationMirror annotation = getAnnotation(method, HttpMethod.class); - assertEquals("POST", getValue(annotation)); - } -} - - diff --git a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationUtilsTest.java b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationUtilsTest.java index 5a0307b6c74..56fb0e0278e 100644 --- a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationUtilsTest.java +++ b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/AnnotationUtilsTest.java @@ -23,18 +23,25 @@ import org.junit.jupiter.api.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; import javax.ws.rs.Path; +import java.util.Iterator; import java.util.List; import java.util.Set; +import static org.apache.dubbo.metadata.annotation.processing.util.AnnotationUtils.findAnnotation; import static org.apache.dubbo.metadata.annotation.processing.util.AnnotationUtils.getAllAnnotations; import static org.apache.dubbo.metadata.annotation.processing.util.AnnotationUtils.getAnnotation; import static org.apache.dubbo.metadata.annotation.processing.util.AnnotationUtils.getAnnotations; import static org.apache.dubbo.metadata.annotation.processing.util.AnnotationUtils.getAttribute; import static org.apache.dubbo.metadata.annotation.processing.util.AnnotationUtils.getValue; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * The {@link AnnotationUtils} Test @@ -60,32 +67,133 @@ public void testGetAnnotation() { assertEquals("3.0.0", getAttribute(serviceAnnotation, "version")); assertEquals("test", getAttribute(serviceAnnotation, "group")); assertEquals("org.apache.dubbo.metadata.tools.EchoService", getAttribute(serviceAnnotation, "interfaceName")); + + assertNull(getAnnotation(testType, (Class) null)); + assertNull(getAnnotation(testType, (String) null)); + + assertNull(getAnnotation(testType.asType(), (Class) null)); + assertNull(getAnnotation(testType.asType(), (String) null)); + + assertNull(getAnnotation((Element) null, (Class) null)); + assertNull(getAnnotation((Element) null, (String) null)); + + assertNull(getAnnotation((TypeElement) null, (Class) null)); + assertNull(getAnnotation((TypeElement) null, (String) null)); } @Test - public void testGetValue() { - AnnotationMirror pathAnnotation = getAnnotation(getType(TestService.class), Path.class); - assertEquals("/echo", getValue(pathAnnotation)); + public void testGetAnnotations() { + List annotations = getAnnotations(testType); + Iterator iterator = annotations.iterator(); + + assertEquals(2, annotations.size()); + assertEquals("com.alibaba.dubbo.config.annotation.Service", iterator.next().getAnnotationType().toString()); + assertEquals("org.apache.dubbo.config.annotation.Service", iterator.next().getAnnotationType().toString()); + + annotations = getAnnotations(testType, Service.class); + iterator = annotations.iterator(); + assertEquals(1, annotations.size()); + assertEquals("org.apache.dubbo.config.annotation.Service", iterator.next().getAnnotationType().toString()); + + annotations = getAnnotations(testType.asType(), Service.class); + iterator = annotations.iterator(); + assertEquals(1, annotations.size()); + assertEquals("org.apache.dubbo.config.annotation.Service", iterator.next().getAnnotationType().toString()); + + annotations = getAnnotations(testType.asType(), Service.class.getTypeName()); + iterator = annotations.iterator(); + assertEquals(1, annotations.size()); + assertEquals("org.apache.dubbo.config.annotation.Service", iterator.next().getAnnotationType().toString()); + + annotations = getAnnotations(testType, Override.class); + assertEquals(0, annotations.size()); + + annotations = getAnnotations(testType, com.alibaba.dubbo.config.annotation.Service.class); + assertEquals(1, annotations.size()); + + assertTrue(getAnnotations(null, (Class) null).isEmpty()); + assertTrue(getAnnotations(null, (String) null).isEmpty()); + assertTrue(getAnnotations(testType, (Class) null).isEmpty()); + assertTrue(getAnnotations(testType, (String) null).isEmpty()); + + assertTrue(getAnnotations(null, Service.class).isEmpty()); + assertTrue(getAnnotations(null, Service.class.getTypeName()).isEmpty()); } @Test public void testGetAllAnnotations() { + List annotations = getAllAnnotations(testType); - List legacyAnnotations = getAllAnnotations(processingEnv, com.alibaba.dubbo.config.annotation.Service.class); assertEquals(5, annotations.size()); - assertEquals(5, legacyAnnotations.size()); + + annotations = getAllAnnotations(processingEnv, TestServiceImpl.class); + assertEquals(5, annotations.size()); + + annotations = getAllAnnotations(testType, Service.class); + assertEquals(3, annotations.size()); + + annotations = getAllAnnotations(testType, Override.class); + assertEquals(0, annotations.size()); + + annotations = getAllAnnotations(testType, com.alibaba.dubbo.config.annotation.Service.class); + assertEquals(1, annotations.size()); + + assertTrue(getAllAnnotations((Element) null, (Class) null).isEmpty()); + assertTrue(getAllAnnotations((TypeMirror) null, (String) null).isEmpty()); + assertTrue(getAllAnnotations((ProcessingEnvironment) null, (Class) null).isEmpty()); + assertTrue(getAllAnnotations((ProcessingEnvironment) null, (String) null).isEmpty()); + + assertTrue(getAllAnnotations((Element) null).isEmpty()); + assertTrue(getAllAnnotations((TypeMirror) null).isEmpty()); + assertTrue(getAllAnnotations(processingEnv, (Class) null).isEmpty()); + assertTrue(getAllAnnotations(processingEnv, (String) null).isEmpty()); + + + assertTrue(getAllAnnotations(testType, (Class) null).isEmpty()); + assertTrue(getAllAnnotations(testType.asType(), (Class) null).isEmpty()); + + assertTrue(getAllAnnotations(testType, (String) null).isEmpty()); + assertTrue(getAllAnnotations(testType.asType(), (String) null).isEmpty()); + + assertTrue(getAllAnnotations((Element) null, Service.class).isEmpty()); + assertTrue(getAllAnnotations((TypeMirror) null, Service.class.getTypeName()).isEmpty()); } + @Test - public void testGetAnnotations() { - List serviceAnnotations = getAnnotations(testType, Service.class); - assertEquals(3, serviceAnnotations.size()); + public void testFindAnnotation() { + + assertEquals("org.apache.dubbo.config.annotation.Service", findAnnotation(testType, Service.class).getAnnotationType().toString()); + assertEquals("com.alibaba.dubbo.config.annotation.Service", findAnnotation(testType, com.alibaba.dubbo.config.annotation.Service.class).getAnnotationType().toString()); + assertEquals("javax.ws.rs.Path", findAnnotation(testType, Path.class).getAnnotationType().toString()); + assertEquals("javax.ws.rs.Path", findAnnotation(testType.asType(), Path.class).getAnnotationType().toString()); + assertEquals("javax.ws.rs.Path", findAnnotation(testType.asType(), Path.class.getTypeName()).getAnnotationType().toString()); + assertNull(findAnnotation(testType, Override.class)); - serviceAnnotations = getAnnotations(testType, Override.class); - assertEquals(0, serviceAnnotations.size()); + assertNull(findAnnotation((Element) null, (Class) null)); + assertNull(findAnnotation((Element) null, (String) null)); + assertNull(findAnnotation((TypeMirror) null, (Class) null)); + assertNull(findAnnotation((TypeMirror) null, (String) null)); - List legacyServiceAnnotations = getAnnotations(testType, - com.alibaba.dubbo.config.annotation.Service.class); - assertEquals(1, legacyServiceAnnotations.size()); + assertNull(findAnnotation(testType, (Class) null)); + assertNull(findAnnotation(testType, (String) null)); + assertNull(findAnnotation(testType.asType(), (Class) null)); + assertNull(findAnnotation(testType.asType(), (String) null)); + } + + @Test + public void testGetAttribute() { + assertEquals("org.apache.dubbo.metadata.tools.EchoService", getAttribute(findAnnotation(testType, Service.class), "interfaceName")); + assertEquals("org.apache.dubbo.metadata.tools.EchoService", getAttribute(findAnnotation(testType, Service.class).getElementValues(), "interfaceName")); + assertEquals("/echo", getAttribute(findAnnotation(testType, Path.class), "value")); + + assertNull(getAttribute(findAnnotation(testType, Path.class), null)); + assertNull(getAttribute(findAnnotation(testType, (Class) null), null)); + } + + @Test + public void testGetValue() { + AnnotationMirror pathAnnotation = getAnnotation(getType(TestService.class), Path.class); + assertEquals("/echo", getValue(pathAnnotation)); } } diff --git a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/TypeUtilsTest.java b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/TypeUtilsTest.java index 2ae8c184548..83ec6aa8472 100644 --- a/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/TypeUtilsTest.java +++ b/dubbo-metadata/dubbo-metadata-processor/src/test/java/org/apache/dubbo/metadata/annotation/processing/util/TypeUtilsTest.java @@ -205,8 +205,8 @@ public void testIsAnnotationType() { @Test public void testGetHierarchicalTypes() { - Set hierarchicalTypes = getHierarchicalTypes(testType.asType(), true, true, true); - Iterator iterator = hierarchicalTypes.iterator(); + Set hierarchicalTypes = getHierarchicalTypes(testType.asType(), true, true, true); + Iterator iterator = hierarchicalTypes.iterator(); assertEquals(8, hierarchicalTypes.size()); assertEquals("org.apache.dubbo.metadata.tools.TestServiceImpl", iterator.next().toString()); assertEquals("org.apache.dubbo.metadata.tools.GenericTestService", iterator.next().toString()); @@ -217,7 +217,7 @@ public void testGetHierarchicalTypes() { assertEquals("java.io.Serializable", iterator.next().toString()); assertEquals("java.util.EventListener", iterator.next().toString()); - hierarchicalTypes = getHierarchicalTypes(testType.asType()); + hierarchicalTypes = getHierarchicalTypes(testType); iterator = hierarchicalTypes.iterator(); assertEquals(8, hierarchicalTypes.size()); assertEquals("org.apache.dubbo.metadata.tools.TestServiceImpl", iterator.next().toString());