diff options
| author | lucashemi <lucasxberger@gmail.com> | 2023-01-10 17:05:09 -0300 |
|---|---|---|
| committer | lucashemi <lucasxberger@gmail.com> | 2023-01-10 17:05:09 -0300 |
| commit | 1ea17797ce21c6f5b442bc275211ba8037a5b96c (patch) | |
| tree | 6ef3ca6248b0ea860ab5cbe70e35c1a97f5f5ab5 /src/test/java/br | |
Diffstat (limited to 'src/test/java/br')
| -rw-r--r-- | src/test/java/br/com/alura/DaysOfCodeSpring/ApplicationTests.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/java/br/com/alura/DaysOfCodeSpring/ApplicationTests.java b/src/test/java/br/com/alura/DaysOfCodeSpring/ApplicationTests.java new file mode 100644 index 0000000..1008263 --- /dev/null +++ b/src/test/java/br/com/alura/DaysOfCodeSpring/ApplicationTests.java @@ -0,0 +1,32 @@ +package br.com.alura.DaysOfCodeSpring; + +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 org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class ApplicationTests { + + @LocalServerPort + private int port; + + @Autowired + private TestRestTemplate restTemplate; + + @Test + void deveRetornarTop250FilmesIMDB() { + String url = "http://localhost:" + port + "/api"; + ResponseEntity<String> response = restTemplate.getForEntity(url, String.class); + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertNotNull(response.getBody()); + } + +} |
