Might be a strange question but indeed I would like to achieve a a bit more coverage on my tests and although I coded against a JsonProcessingException
I can\'t
You could use something like this:
private static class ClassThatJacksonCannotSerialize {
private final ClassThatJacksonCannotSerialize self = this;
@Override
public String toString() {
return self.getClass().getName();
}
}
Which results in a JsonProcessingException
with message Direct self-reference leading to cycle (through reference chain: ClassThatJacksonCannotSerialize["self"])