@@ -605,7 +605,7 @@ public void buscaPorEmail_successFullPage_withPageParameters_returns200() throws
605605 @ Test @ Transactional @ DisplayName ("Searches for an e-mail address and returns a page with the"
606606 + "client from that email. Page parameters are NOT provided." )
607607 public void buscaPorEmail_successFullPage_noParameters_returns200 () throws Exception {
608- /*This is only a test to make sure that the correct content is returned. The email address is
608+ /*This is only a test to ensure that the correct content is returned. The email address is
609609 *unique and we can't have two clients with the same e-mail. For that reason the real Page only
610610 *return one client.*/
611611 Cliente cliente1 = new Cliente ();
@@ -712,7 +712,36 @@ public void atualizarEmail_existingEmail_returns409() throws Exception{
712712
713713 mvc .perform (patch ("/atualizaremail/" +cliente1 .getId ()).param ("email" , "antonio@gmail.com" ))
714714 .andExpect (status ().isConflict ()).andExpect (content ().string (containsString ("indisponível" )));
715+ }
716+
717+ @ Test @ Transactional @ DisplayName ("Searches for the client by email and returns a Page with that "
718+ + "client. Returns 200." )
719+ public void buscarPorEmailOrdenada_successFullPage_returns200 () throws Exception {
720+ /*This is only a test to ensure that the correct content is returned. The email address is
721+ *unique and we cannot have two clients with the same e-mail. For that reason the real Page only
722+ *return one client.*/
723+ Cliente cliente1 = new Cliente ();
724+ cliente1 .setNome ("Marcus" );
725+ cliente1 .setCpf ("23501206586" );
726+ cliente1 .setEmail ("marcus@gmail.com" );
727+
728+ Cliente cliente2 = new Cliente ();
729+ cliente2 .setNome ("Antonio" );
730+ cliente2 .setCpf ("20219064674" );
731+ cliente2 .setEmail ("antonio@gmail.com" );
732+
733+ Cliente cliente3 = new Cliente ();
734+ cliente3 .setNome ("Marcelo" );
735+ cliente3 .setCpf ("47852136582" );
736+ cliente3 .setEmail ("marcus@gmail.com" );
737+
738+ repository .saveAndFlush (cliente1 );
739+ repository .saveAndFlush (cliente2 );
740+ repository .saveAndFlush (cliente3 );
715741
742+ mvc .perform (get ("/buscarporemail" ).param ("email" , "marcus@gmail.com" )
743+ .param ("pagina" , "0" ).param ("itens" , "2" ).param ("ordenadoPor" , "id" ))
744+ .andExpect (status ().isOk ()).andExpect (jsonPath ("$.content[0].nome" ).value ("Marcus" ));
716745 }
717746
718747}
0 commit comments