@@ -392,7 +392,8 @@ public void listaPaginadaOrdenada_invalidParameters_returns400(int pagina, int i
392392 }
393393
394394 @ Test @ Transactional
395- @ DisplayName ("Searches for clients using part of their names and returns a paginated list, retuns 200" )
395+ @ DisplayName ("Searches for clients using part of their names and returns a paginated list, "
396+ + "parameters are provided. Returns 200." )
396397 public void buscarPorNomePagina_successWithParameters_returns200 () throws Exception {
397398 Cliente cliente1 = new Cliente ();
398399 cliente1 .setNome ("Marcus" );
@@ -422,6 +423,39 @@ public void buscarPorNomePagina_successWithParameters_returns200() throws Except
422423 .andExpect (jsonPath ("$.content[0].email" ).value ("marcelo@gmail.com" ))
423424 .andExpect (jsonPath ("$.content.length()" ).value (2 ));
424425 }
426+
427+ @ Test @ Transactional
428+ @ DisplayName ("Searches for clients using part of their names and returns a paginated list, "
429+ + "page parameters are not provided. Returns 200." )
430+ public void buscarPorNomePagina_successNoParameters_returns200 () throws Exception {
431+ Cliente cliente1 = new Cliente ();
432+ cliente1 .setNome ("Marcus" );
433+ cliente1 .setCpf ("23501206586" );
434+ cliente1 .setEmail ("marcus@gmail.com" );
435+
436+ Cliente cliente2 = new Cliente ();
437+ cliente2 .setNome ("Antonio" );
438+ cliente2 .setCpf ("20219064674" );
439+ cliente2 .setEmail ("antonio@gmail.com" );
440+
441+ Cliente cliente3 = new Cliente ();
442+ cliente3 .setNome ("Marcelo" );
443+ cliente3 .setCpf ("47852136582" );
444+ cliente3 .setEmail ("marcelo@gmail.com" );
445+
446+ repository .saveAndFlush (cliente1 );
447+ repository .saveAndFlush (cliente2 );
448+ repository .saveAndFlush (cliente3 );
449+
450+ mvc .perform (get ("/buscapornome?nome=mar" )).andExpect (status ().isOk ())
451+ .andExpect (jsonPath ("$.content[1].nome" ).value ("Marcus" ))
452+ .andExpect (jsonPath ("$.content[0].nome" ).value ("Marcelo" ))
453+ .andExpect (jsonPath ("$.content[1].cpf" ).value ("23501206586" ))
454+ .andExpect (jsonPath ("$.content[0].cpf" ).value ("47852136582" ))
455+ .andExpect (jsonPath ("$.content[1].email" ).value ("marcus@gmail.com" ))
456+ .andExpect (jsonPath ("$.content[0].email" ).value ("marcelo@gmail.com" ))
457+ .andExpect (jsonPath ("$.content.length()" ).value (2 ));
458+ }
425459}
426460
427461
0 commit comments