add predicate for CombinationAnnotationElement

This commit is contained in:
Looly
2022-04-27 11:22:31 +08:00
parent 780d974f12
commit f118bf8e7e
6 changed files with 143 additions and 54 deletions

View File

@@ -7,7 +7,7 @@ import java.lang.annotation.Target;
/**
* 用于单元测试的注解类<br>
* 注解类相关说明见https://www.cnblogs.com/xdp-gacl/p/3622275.html
* 注解类相关说明见:<a href="https://www.cnblogs.com/xdp-gacl/p/3622275.html">https://www.cnblogs.com/xdp-gacl/p/3622275.html</a>
*
* @author looly
*/

View File

@@ -3,13 +3,23 @@ package cn.hutool.core.annotation;
import org.junit.Assert;
import org.junit.Test;
import java.util.Set;
import java.lang.annotation.Annotation;
public class AnnotationUtilTest {
@Test
public void getRepeatAnnotationValueTest(){
Set<AnnotationForTest> annotations = AnnotationUtil.getRepeatedAnnotations(ClassWithAnnotation.class, AnnotationForTest.class);
Assert.assertTrue(annotations != null && annotations.size() == 2);
public void getCombinationAnnotationsTest(){
Annotation[] annotations = AnnotationUtil.getAnnotations(ClassWithAnnotation.class, true);
Assert.assertNotNull(annotations);
Assert.assertEquals(3, annotations.length);
}
@Test
public void getCombinationAnnotationsWithClassTest(){
AnnotationForTest[] annotations = AnnotationUtil.getCombinationAnnotations(ClassWithAnnotation.class, AnnotationForTest.class);
Assert.assertNotNull(annotations);
Assert.assertEquals(2, annotations.length);
Assert.assertEquals("测试", annotations[0].value());
}
@Test