Skip to content

Commit

Permalink
✅ test: Teste de Inetgração com o Swagger Ui
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacAndra committed Aug 29, 2024
1 parent 8535150 commit 862c3f3
Showing 1 changed file with 30 additions and 0 deletions.
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");

}
}

0 comments on commit 862c3f3

Please sign in to comment.