From 862c3f36affa65f99420b237b5ae28dd4f4439c0 Mon Sep 17 00:00:00 2001 From: IsaacAndra Date: Thu, 29 Aug 2024 14:52:49 -0300 Subject: [PATCH] =?UTF-8?q?:white=5Fcheck=5Fmark:=20test:=20Teste=20de=20I?= =?UTF-8?q?netgra=C3=A7=C3=A3o=20com=20o=20Swagger=20Ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SwaggerIntegrationTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 blog/src/test/java/com/isaacandrade/blog/integrationtests/SwaggerIntegrationTest.java diff --git a/blog/src/test/java/com/isaacandrade/blog/integrationtests/SwaggerIntegrationTest.java b/blog/src/test/java/com/isaacandrade/blog/integrationtests/SwaggerIntegrationTest.java new file mode 100644 index 0000000..2f683d7 --- /dev/null +++ b/blog/src/test/java/com/isaacandrade/blog/integrationtests/SwaggerIntegrationTest.java @@ -0,0 +1,30 @@ +package com.isaacandrade.blog.integrationtests; + +import com.isaacandrade.blog.integrationtests.config.MyIntegrationTest; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@ActiveProfiles("test") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) +public class SwaggerIntegrationTest extends MyIntegrationTest { + + @Autowired + private TestRestTemplate testRestTemplate; + + @Test + void SwaggerUiLoads(){ + ResponseEntity response = testRestTemplate.getForEntity("/swagger-ui/index.html", String.class); + assertEquals(HttpStatus.OK, response.getStatusCode(), "Swagger deve estar acessível"); + + ResponseEntity apiDocsResponse = testRestTemplate.getForEntity("/v3/api-docs", String.class); + assertEquals(HttpStatus.OK, apiDocsResponse.getStatusCode(), "Swagger API Docs deve estar acessível"); + + } +}