|  | 
|  | 1 | +package org.eclipse.microprofile.openapi.tck; | 
|  | 2 | + | 
|  | 3 | +import io.restassured.response.ValidatableResponse; | 
|  | 4 | +import org.eclipse.microprofile.openapi.apps.scanconfig.ScanConfigApplication; | 
|  | 5 | +import org.eclipse.microprofile.openapi.apps.scanconfig.a.AResource; | 
|  | 6 | +import org.jboss.arquillian.container.test.api.Deployment; | 
|  | 7 | +import org.jboss.shrinkwrap.api.ShrinkWrap; | 
|  | 8 | +import org.jboss.shrinkwrap.api.spec.WebArchive; | 
|  | 9 | +import org.testng.annotations.Test; | 
|  | 10 | + | 
|  | 11 | +import static org.hamcrest.Matchers.equalTo; | 
|  | 12 | + | 
|  | 13 | +/** | 
|  | 14 | + * Verify usage of the {@code @ExternalDocumentation} annotation. | 
|  | 15 | + */ | 
|  | 16 | +public class ExternalDocumentationAnnotationTest extends AppTestBase { | 
|  | 17 | + | 
|  | 18 | +    @Deployment(name = "externalDocs-test", testable = false) | 
|  | 19 | +    public static WebArchive deployment() { | 
|  | 20 | +        return ShrinkWrap.create(WebArchive.class, "externalDocs-test.war") | 
|  | 21 | +                .addClasses(ScanConfigApplication.class, AResource.class); | 
|  | 22 | +    } | 
|  | 23 | + | 
|  | 24 | +    /** | 
|  | 25 | +     * Check that the {@code externalDocs} element is present in the generated OpenAPI document when the | 
|  | 26 | +     * {@code @ExternalDocumentation} annotation is used on a resource class definition. | 
|  | 27 | +     * @param type Type of the OpenAPI output format | 
|  | 28 | +     */ | 
|  | 29 | +    @Test(dataProvider = "formatProvider") | 
|  | 30 | +    public void testExternalDocumentationAnnotationOnClass(String type) { | 
|  | 31 | +        ValidatableResponse vr = callEndpoint(type); | 
|  | 32 | + | 
|  | 33 | +        vr.body("externalDocs.description", equalTo("Find more information about this application")); | 
|  | 34 | +        vr.body("externalDocs.url", equalTo( | 
|  | 35 | +                "https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/ScanConfigApplication.java")); | 
|  | 36 | +    } | 
|  | 37 | + | 
|  | 38 | +    /** | 
|  | 39 | +     * Check that the {@code externalDocs} element is present in the generated OpenAPI document when the | 
|  | 40 | +     * {@code @ExternalDocumentation} annotation is used on a resource method definition. | 
|  | 41 | +     * @param type Type of the OpenAPI output format | 
|  | 42 | +     */ | 
|  | 43 | +    @Test(dataProvider = "formatProvider") | 
|  | 44 | +    public void testExternalDocumentationAnnotationOnMethod(String type) { | 
|  | 45 | +        ValidatableResponse vr = callEndpoint(type); | 
|  | 46 | + | 
|  | 47 | +        vr.body("paths.'/a'.externalDocs.description", equalTo("Find more information about this application resource")); | 
|  | 48 | +        vr.body("paths.'/a'.externalDocs.url", equalTo( | 
|  | 49 | +                "https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java")); | 
|  | 50 | +    } | 
|  | 51 | +} | 
0 commit comments