summaryrefslogtreecommitdiff
path: root/src/test/java/br/com/alura
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/br/com/alura')
-rw-r--r--src/test/java/br/com/alura/DaysOfCodeSpring/ApplicationTests.java32
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());
+ }
+
+}