@@ -515,7 +515,7 @@ public void atualizarParcial_invalidIdUpdanting_returns400() throws Exception{
515515 .andExpect (content ().string ("O campo id não pode ser alterado." ));
516516 }
517517
518- @ Test @ Transactional
518+ @ Test @ Transactional @ DisplayName ( "Returns 409 when it tries to update client's CPF." )
519519 public void atualizarParcial_invalidCpfUpdating_returns409 () throws Exception {
520520 Cliente cliente1 = new Cliente ();
521521 cliente1 .setNome ("Marcus" );
@@ -530,6 +530,23 @@ public void atualizarParcial_invalidCpfUpdating_returns409() throws Exception{
530530 .content (mapper .writeValueAsString (updates ))).andExpect (status ().isConflict ())
531531 .andExpect (content ().string ("Alteração de CPF não permitida." ));
532532 }
533+
534+ @ ParameterizedTest @ NullAndEmptySource @ ValueSource (strings = " " ) @ Transactional
535+ @ DisplayName ("It tries to update client's name with an empty string and a null value." )
536+ public void atualizarParcial_invalidName_returns400 (String nome ) throws Exception {
537+ Cliente cliente1 = new Cliente ();
538+ cliente1 .setNome ("Marcus" );
539+ cliente1 .setCpf ("23501206586" );
540+ cliente1 .setEmail ("marcus@gmail.com" );
541+ repository .saveAndFlush (cliente1 );
542+
543+ Map <String , Object > updates = new HashMap <>();
544+ updates .put ("nome" , nome );
545+
546+ mvc .perform (patch ("/parcial/" +cliente1 .getId ()).contentType (MediaType .APPLICATION_JSON )
547+ .content (mapper .writeValueAsString (updates ))).andExpect (status ().isBadRequest ())
548+ .andExpect (content ().string ("Nome não pode ser vazio ou nulo." ));
549+ }
533550
534551}
535552
0 commit comments