From 1ea17797ce21c6f5b442bc275211ba8037a5b96c Mon Sep 17 00:00:00 2001 From: lucashemi Date: Tue, 10 Jan 2023 17:05:09 -0300 Subject: first commit --- .../alura/DaysOfCodeSpring/ApplicationTests.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/java/br/com/alura/DaysOfCodeSpring/ApplicationTests.java (limited to 'src/test/java') 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 response = restTemplate.getForEntity(url, String.class); + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertNotNull(response.getBody()); + } + +} -- cgit v1.2.3-18-g5258