Skip to content

Commit b116da8

Browse files
committed
Integrations test: atualizarParcial, invalid e-mail.
It tries to update partial information of the client with an invalid e-mail address and returns 400.
1 parent 4693426 commit b116da8

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public void atualizarParcial_invalidCpfUpdating_returns409() throws Exception{
531531
.andExpect(content().string("Alteração de CPF não permitida."));
532532
}
533533

534-
@ParameterizedTest @NullAndEmptySource @ValueSource(strings = " ") @Transactional
534+
@ParameterizedTest @NullAndEmptySource @Transactional @ValueSource(strings = " ")
535535
@DisplayName("It tries to update client's name with an empty string and a null value.")
536536
public void atualizarParcial_invalidName_returns400(String nome) throws Exception{
537537
Cliente cliente1 = new Cliente();
@@ -547,6 +547,27 @@ public void atualizarParcial_invalidName_returns400(String nome) throws Exceptio
547547
.content(mapper.writeValueAsString(updates))).andExpect(status().isBadRequest())
548548
.andExpect(content().string("Nome não pode ser vazio ou nulo."));
549549
}
550+
551+
@ParameterizedTest @NullAndEmptySource @Transactional
552+
@ValueSource(strings = {" ", "marcus@marcus@marcus", "marcus.com", "@marcus.com", "marcus@"})
553+
@DisplayName("It tries to update partial information of the client with an invalid e-mail address and"
554+
+ "returns 400.")
555+
public void atualizarParcial_invalidEmailAdress_returns400(String email) throws Exception{
556+
Cliente cliente1 = new Cliente();
557+
cliente1.setNome("Marcus");
558+
cliente1.setCpf("23501206586");
559+
cliente1.setEmail("marcus@gmail.com");
560+
repository.saveAndFlush(cliente1);
561+
562+
Map<String, Object> updates = new HashMap<>();
563+
updates.put("email", email);
564+
565+
mvc.perform(patch("/parcial/"+cliente1.getId()).contentType(MediaType.APPLICATION_JSON)
566+
.content(mapper.writeValueAsString(updates))).andExpect(status().isBadRequest())
567+
.andExpect(content().string(containsString("inválido")));
568+
}
569+
570+
550571

551572
}
552573

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,10 @@ public void atualizarParcial_nomeNuloVazio_retorno400(String nome) throws Except
768768
verifyNoMoreInteractions(service);
769769
}
770770

771-
@ParameterizedTest
772-
@NullAndEmptySource
771+
@ParameterizedTest @NullAndEmptySource
773772
@ValueSource(strings = {" ", "marcus@marcus@marcus", "marcus.com", "@marcus.com", "marcus@"})
773+
@DisplayName("It tries to update partial information of the client with an invalid e-mail address and"
774+
+ "returns 400.")
774775
public void atualizarParcial_emailInvalido_retorno400(String email) throws Exception{
775776
Map<String, Object> updates = new HashMap<>();
776777
updates.put("email", email);

0 commit comments

Comments
 (0)