File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
src/test/java/com/sistemaclliente Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -499,6 +499,22 @@ public void atualizarParcial_success_return200() throws Exception {
499499 .andExpect (jsonPath ("$.email" ).value ("antonio@email.com" ));
500500 }
501501
502+ @ Test @ Transactional @ DisplayName ("Returns 400 when it tries to update client's ID." )
503+ public void atualizarParcial_updatingId_returns400 () throws Exception {
504+ Cliente cliente1 = new Cliente ();
505+ cliente1 .setNome ("Marcus" );
506+ cliente1 .setCpf ("23501206586" );
507+ cliente1 .setEmail ("marcus@gmail.com" );
508+ repository .saveAndFlush (cliente1 );
509+
510+ Map <String , Object > updates = new HashMap <>();
511+ updates .put ("id" , 2L );
512+
513+ mvc .perform (patch ("/parcial/" +cliente1 .getId ()).contentType (MediaType .APPLICATION_JSON )
514+ .content (mapper .writeValueAsString (updates ))).andExpect (status ().isBadRequest ())
515+ .andExpect (content ().string ("O campo id não pode ser alterado." ));
516+ }
517+
502518}
503519
504520
Original file line number Diff line number Diff line change @@ -719,7 +719,7 @@ public void atualizarParcial_sucesso_retorno200() throws Exception {
719719 verifyNoMoreInteractions (service );
720720 }
721721
722- @ Test
722+ @ Test @ DisplayName ( "Returns 400 when it tries to update client's ID." )
723723 public void atualizarParcial_presencaDoId_retorno400 () throws Exception {
724724 Map <String , Object > updates = new HashMap <>();
725725 updates .put ("id" , 2L );
You can’t perform that action at this time.
0 commit comments