Skip to content

Commit d32fb9e

Browse files
committed
Integration test: encontrarClientePorCpf, returns 404
Tries to find client by CPF but fails. Returns 404.
1 parent ac263a1 commit d32fb9e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ public void encontrarClientePorCpf_success_returns200() throws Exception{
266266
.andExpect(jsonPath("$.nome").value("Marcus")).andExpect(jsonPath("$.cpf").value("23501206586"))
267267
.andExpect(jsonPath("$.email").value("marcus@gmail.com"));
268268
}
269+
270+
@Test @Transactional @DisplayName("Tries to find client by CPF but fails. Returns 404")
271+
public void encontrarClientePorCpf_clientNotFound_returns404() throws Exception{
272+
mvc.perform(get("/clientecpf/23501206586")).andExpect(status().isNotFound())
273+
.andExpect(content().string("Cliente com o CPF = 23501206586 não encontrado."));
274+
275+
assertThat(repository.findByCpf("23501206586")).isNotPresent();
276+
}
269277
}
270278

271279

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public void encontrarClientePorCpf_sucesso_retorno200() throws Exception{
403403
verifyNoMoreInteractions(service);
404404
}
405405

406-
@Test
406+
@Test @DisplayName("Tries to find client by CPF but fails. Returns 404")
407407
public void encontrarClientePorCpf_clienteNotFound_retorno404() throws Exception{
408408
when(service.encontrarPorCpf("23501206586"))
409409
.thenThrow(new ClienteNotFoundException("23501206586"));

0 commit comments

Comments
 (0)