|
2 | 2 |
|
3 | 3 | import static org.assertj.core.api.Assertions.assertThat; |
4 | 4 | import static org.hamcrest.CoreMatchers.containsString; |
| 5 | +import static org.mockito.Mockito.when; |
5 | 6 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; |
6 | 7 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
7 | 8 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
@@ -224,7 +225,7 @@ public void atualizarCliente_success_returns200() throws Exception{ |
224 | 225 | } |
225 | 226 |
|
226 | 227 | @Test @DisplayName("Tries to update and don't find client by ID, returns 404.") |
227 | | - public void atualizarCliente_clienteNaoEncontrado_retorno404() throws Exception{ |
| 228 | + public void atualizarCliente_clientNotFound_returns404() throws Exception{ |
228 | 229 | ClienteRequestDTO dto = new ClienteRequestDTO(); |
229 | 230 | dto.setNome("Marcus"); |
230 | 231 | dto.setCpf("23501206586"); |
@@ -252,6 +253,19 @@ public void atualizarCliente_changeCpf_returns409() throws Exception{ |
252 | 253 | .content(mapper.writeValueAsString(dto))).andExpect(status().isConflict()) |
253 | 254 | .andExpect(content().string("Alteração de CPF não permitida.")); |
254 | 255 | } |
| 256 | + |
| 257 | + @Test @Transactional @DisplayName("Finds client by CPF, returns 200.") |
| 258 | + public void encontrarClientePorCpf_success_returns200() throws Exception{ |
| 259 | + Cliente cliente1 = new Cliente(); |
| 260 | + cliente1.setNome("Marcus"); |
| 261 | + cliente1.setCpf("23501206586"); |
| 262 | + cliente1.setEmail("marcus@gmail.com"); |
| 263 | + repository.saveAndFlush(cliente1); |
| 264 | + |
| 265 | + mvc.perform(get("/clientecpf/23501206586")).andExpect(status().isOk()) |
| 266 | + .andExpect(jsonPath("$.nome").value("Marcus")).andExpect(jsonPath("$.cpf").value("23501206586")) |
| 267 | + .andExpect(jsonPath("$.email").value("marcus@gmail.com")); |
| 268 | + } |
255 | 269 | } |
256 | 270 |
|
257 | 271 |
|
|
0 commit comments