Skip to content

Commit ee2cc9a

Browse files
committed
Integration test: deletarClientePorId, returns 404.
Deletes a client by a non-existing ID and returns 404.
1 parent 2bfb61b commit ee2cc9a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ public void deletarClientePorId_success_returns204() throws Exception {
197197
assertThat(repository.findById(cliente1.getId())).isNotPresent();
198198
}
199199

200+
@Test @Transactional
201+
@DisplayName("Deletes a client by a non-existing ID and returns 404")
202+
public void deletarClientePorId_clientNotFound_returns404() throws Exception{
203+
mvc.perform(delete("/deletarporid/999")).andExpect(status().isNotFound());
204+
205+
assertThat(repository.findById(999L)).isNotPresent();
206+
}
200207
}
201208

202209

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ public void deletarClientePorId_sucesso_retorno204() throws Exception {
294294
}
295295

296296
@Test
297+
@DisplayName("Deletes a client by a non-existing ID and returns 404")
297298
public void deletarClientePorId_clienteNaoEncontrado_retorno404() throws Exception{
298299
doThrow(new ClienteNotFoundException()).when(service).deletarClientePorId(anyLong());
299300

0 commit comments

Comments
 (0)