File tree 1 file changed +9
-0
lines changed
complete/src/test/java/com/example/restservice
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,22 @@ public class GreetingControllerTests {
37
37
@ Test
38
38
public void noParamGreetingShouldReturnDefaultMessage () throws Exception {
39
39
40
+ // Realiza uma requisição GET para o endpoint "/greeting".
41
+ // O objetivo é verificar se a resposta retorna o status HTTP 200 (OK)
42
+ // e se o conteúdo da resposta JSON contém a chave "content" com o valor "Hello, World!".
43
+
40
44
this .mockMvc .perform (get ("/greeting" )).andDo (print ()).andExpect (status ().isOk ())
41
45
.andExpect (jsonPath ("$.content" ).value ("Hello, World!" ));
42
46
}
43
47
44
48
@ Test
45
49
public void paramGreetingShouldReturnTailoredMessage () throws Exception {
46
50
51
+ // Realiza uma requisição GET para o endpoint "/greeting" com um parâmetro "name" enviado.
52
+ // O objetivo é verificar se a resposta retorna o status HTTP 200 (OK)
53
+ // e se o conteúdo da resposta JSON contém a chave "content" com uma mensagem personalizada
54
+ // que inclui o nome fornecido como parâmetro ("Spring Community").
55
+
47
56
this .mockMvc .perform (get ("/greeting" ).param ("name" , "Spring Community" ))
48
57
.andDo (print ()).andExpect (status ().isOk ())
49
58
.andExpect (jsonPath ("$.content" ).value ("Hello, Spring Community!" ));
You can’t perform that action at this time.
0 commit comments