@@ -276,7 +276,7 @@ public void encontrarClientePorCpf_clientNotFound_returns404() throws Exception{
276276 }
277277
278278 @ Test @ Transactional @ DisplayName ("Returns Page and 200. We gave the parameters to the Page." )
279- public void listaPaginada_succsses_retorno200 () throws Exception {
279+ public void listaPaginada_successWithParameters_returns200 () throws Exception {
280280 Cliente cliente1 = new Cliente ();
281281 cliente1 .setNome ("Marcus" );
282282 cliente1 .setCpf ("23501206586" );
@@ -299,6 +299,33 @@ public void listaPaginada_succsses_retorno200() throws Exception{
299299 .andExpect (jsonPath ("$.content[1].email" ).value ("antonio@gmail.com" ))
300300 .andExpect (jsonPath ("$.content.length()" ).value (2 ));
301301 }
302+
303+ @ Test @ Transactional
304+ @ DisplayName ("Returns Page and 200. We didn't give the parameters, we use the defaultValue from the"
305+ + "endpoint." )
306+ public void listaPaginada_successNoParameters_returns200 () throws Exception {
307+ Cliente cliente1 = new Cliente ();
308+ cliente1 .setNome ("Marcus" );
309+ cliente1 .setCpf ("23501206586" );
310+ cliente1 .setEmail ("marcus@gmail.com" );
311+
312+ Cliente cliente2 = new Cliente ();
313+ cliente2 .setNome ("Antonio" );
314+ cliente2 .setCpf ("20219064674" );
315+ cliente2 .setEmail ("antonio@gmail.com" );
316+
317+ repository .saveAndFlush (cliente1 );
318+ repository .saveAndFlush (cliente2 );
319+
320+ mvc .perform (get ("/paginada" )).andExpect (status ().isOk ())
321+ .andExpect (jsonPath ("$.content[0].nome" ).value ("Marcus" ))
322+ .andExpect (jsonPath ("$.content[1].nome" ).value ("Antonio" ))
323+ .andExpect (jsonPath ("$.content[0].cpf" ).value ("23501206586" ))
324+ .andExpect (jsonPath ("$.content[1].cpf" ).value ("20219064674" ))
325+ .andExpect (jsonPath ("$.content[0].email" ).value ("marcus@gmail.com" ))
326+ .andExpect (jsonPath ("$.content[1].email" ).value ("antonio@gmail.com" ))
327+ .andExpect (jsonPath ("$.content.length()" ).value (2 ));
328+ }
302329}
303330
304331
0 commit comments