Skip to content

Commit 44445fd

Browse files
committed
Integration test: atualizarParcial, returns 400.
Returns 400 when it tries to update client's ID.
1 parent 4cc6769 commit 44445fd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/test/java/com/sistemaclliente/ClienteControllerIntegrationTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/test/java/com/sistemaclliente/ClienteControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)