I'm working on a Spring Boot MVC project and I'm getting the following error when unit testing my CRUD controllers :
java.lang.StackOverflowError
at java.base/java.lang.Throwable.getOurStackTrace(Throwable.java:840)
at java.base/java.lang.Throwable.getStackTrace(Throwable.java:832)
at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:55)
at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:60)
java.lang.StackOverflowError
at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:834)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:247)
at ch.qos.logback.classic.pattern.ThrowableProxyConverter.subjoinSTEPArray(ThrowableProxyConverter.java:216)
at ch.qos.logback.classic.pattern.ThrowableProxyConverter.recursiveAppend(ThrowableProxyConverter.java:161)
at ch.qos.logback.classic.pattern.ThrowableProxyConverter.recursiveAppend(ThrowableProxyConverter.java:168)
Here's one of the controllers unit test, the others follow the same logic.
@Autowired
private MockMvc mockMvc;
@MockBean
private PessoaRepository pessoaRepository;
@Test
public void deletarPessoa_quandoDelete() throws Exception {
Pessoa pessoa = new Pessoa();
pessoa.setNome("Test Nome");
pessoa.setId(89L);
doNothing().when(pessoaRepository).delete(pessoa);
mockMvc.perform(delete("/pessoas/" + pessoa.getId().toString())
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isNoContent());
}
What could this be? I have no idea why I'm getting this error.
EDIT : here's the controller, it basically calls for the repo to delete a Pessoa object
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deletar(@ApiParam(value = "ID", example = "1") @PathVariable Long id) {
Pessoa pessoaDeletada = pessoaRepository.getOne(id);
pessoaRepository.delete(pessoaDeletada);
}
Aucun commentaire:
Enregistrer un commentaire