Skip to content

Commit 8eaafb3

Browse files
committed
Integration test: atualizarParcial, updating CPF.
Returns 409.
1 parent 44445fd commit 8eaafb3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ public void atualizarParcial_success_return200() throws Exception {
500500
}
501501

502502
@Test @Transactional @DisplayName("Returns 400 when it tries to update client's ID.")
503-
public void atualizarParcial_updatingId_returns400() throws Exception{
503+
public void atualizarParcial_invalidIdUpdanting_returns400() throws Exception{
504504
Cliente cliente1 = new Cliente();
505505
cliente1.setNome("Marcus");
506506
cliente1.setCpf("23501206586");
@@ -515,6 +515,22 @@ public void atualizarParcial_updatingId_returns400() throws Exception{
515515
.andExpect(content().string("O campo id não pode ser alterado."));
516516
}
517517

518+
@Test @Transactional
519+
public void atualizarParcial_invalidCpfUpdating_returns409() throws Exception{
520+
Cliente cliente1 = new Cliente();
521+
cliente1.setNome("Marcus");
522+
cliente1.setCpf("23501206586");
523+
cliente1.setEmail("marcus@gmail.com");
524+
repository.saveAndFlush(cliente1);
525+
526+
Map<String, Object> updates = new HashMap<>();
527+
updates.put("cpf", "58652104789");
528+
529+
mvc.perform(patch("/parcial/"+cliente1.getId()).contentType(MediaType.APPLICATION_JSON)
530+
.content(mapper.writeValueAsString(updates))).andExpect(status().isConflict())
531+
.andExpect(content().string("Alteração de CPF não permitida."));
532+
}
533+
518534
}
519535

520536

0 commit comments

Comments
 (0)