Skip to content

Commit 6875d19

Browse files
committed
Integration test: atualizarEmail, invalid email format.
Attempts to update the client's email with an invalid email address. Returns 400.
1 parent 5586b68 commit 6875d19

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,19 @@ public void atualizarEmail_successfullEmailUpdating_returns200() throws Exceptio
674674
.andExpect(jsonPath("$.email").value("marcelo@gmail.com"));
675675
}
676676

677+
@ParameterizedTest @NullAndEmptySource @ValueSource(strings = {" ", "mar", "mar@mar@", "mar.com"})
678+
@DisplayName("Attempts to update the client's email with an invalid email address. Returns 400.")
679+
public void atualizarEmail_invalidEmail_returns400(String email) throws Exception{
680+
Cliente cliente1 = new Cliente();
681+
cliente1.setNome("Marcus");
682+
cliente1.setCpf("23501206586");
683+
cliente1.setEmail("marcus@gmail.com");
684+
repository.saveAndFlush(cliente1);
685+
686+
mvc.perform(patch("/atualizaremail/"+cliente1.getId()).param("email", email))
687+
.andExpect(status().isBadRequest()).andExpect(content().string(containsString("inválido")));
688+
}
689+
677690
}
678691

679692

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -931,9 +931,8 @@ public void atualizarEmail_sucesso_retorno200() throws Exception{
931931
verifyNoMoreInteractions(service);
932932
}
933933

934-
@ParameterizedTest
935-
@NullAndEmptySource
936-
@ValueSource(strings = {" ", "mar", "mar@mar@", "mar.com"})
934+
@ParameterizedTest @NullAndEmptySource @ValueSource(strings = {" ", "mar", "mar@mar@", "mar.com"})
935+
@DisplayName("Attempts to update the client's email with an invalid email address. Returns 400.")
937936
public void atualizarEmail_emailInvalido_retorno400(String email) throws Exception{
938937
when(service.atualizarEmail(1L, email))
939938
.thenThrow(new IllegalArgumentException("Formato do e-mail inválido."));

0 commit comments

Comments
 (0)