-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ test: Teste de Inetgração com o Swagger Ui
- Loading branch information
1 parent
8535150
commit 862c3f3
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
blog/src/test/java/com/isaacandrade/blog/integrationtests/SwaggerIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> response = testRestTemplate.getForEntity("/swagger-ui/index.html", String.class); | ||
assertEquals(HttpStatus.OK, response.getStatusCode(), "Swagger deve estar acessível"); | ||
|
||
ResponseEntity<String> apiDocsResponse = testRestTemplate.getForEntity("/v3/api-docs", String.class); | ||
assertEquals(HttpStatus.OK, apiDocsResponse.getStatusCode(), "Swagger API Docs deve estar acessível"); | ||
|
||
} | ||
} |