package com.hello.service;

import com.hello.annotation.HelloAnnotation;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.lang.annotation.Annotation;

@SpringBootTest
public class HelloBeanTest {
    @Autowired
    HelloBean helloBean;

    @Test
    public void testValue() {
        String ret = helloBean.osName;
        Assertions.assertNotNull(ret);

        System.out.println(String.format("osName：%s, resource: %s",
                helloBean.osName,
                helloBean.url.toString()
        ));
    }

    @Test
    public void testAnnotations() throws NoSuchMethodException {
        Class<?> clazz = HelloBean.class;
        Annotation[] annotations = clazz.getAnnotations();
        Assertions.assertNotNull(annotations);

        System.out.println(String.format("类： %s, 注解数量： %d",
                clazz.getSimpleName(),
                annotations.length
        ));
    }

    @Test
    public void testAnnotation() throws NoSuchMethodException {
        Class<?> clazz = HelloBean.class;
        HelloAnnotation annotation = clazz.getAnnotation(HelloAnnotation.class);
        Assertions.assertNotNull(annotation);

        System.out.println(String.format("类： %s, 注解： %s, 值：%s",
                clazz.getSimpleName(),
                annotation.annotationType().getSimpleName(),
                annotation.value()
        ));
    }
}

@@ -394,16 +394,179 @@
 oBean;%0A%0A
+    @Test%0A    public void testHello() %7B%0A        String ret = helloBean.sayHello();%0A        Assertions.assertNotNull(ret);%0A%0A        System.out.println(ret);%0A    %7D%0A%0A
     @Tes

test hello