Polymorphic Deserialization with Jackson

When serializing POJOs to JSON we lose a very valuable information about the polymorphic nature of the Java object. When we deserialize the same object from JSON we have to know the exact object type and we cannot deserialize to a supertype. Lucky for us, Jackson offers the option of polymorphic deserialization. The problem when deserializing JSON to POJO Let …

Log hierarchy in Logback

Log hierarchy in Logback is based on the log names. That is a characteristic that makes lots of interesting and handy features possible. The post looks into a couple of examples how that works. How named log hierarchy works According to the logger documentation, a logger is said to be an ancestor of another logger if its name followed by a …

Mock final classes with Mockito

One of the standard Mockito related questions I’ve come across is online is “Can we mock final classes with Mockito?”. The answer to this question since Mockito 2 was introduced is “Yes, we can.”. Example code This is the test I would like to be able to run: @ExtendWith(MockitoExtension.class) class PersonTest { @Mock PinProvider pinProvider; @Test public void shouldCreatePersonWithCorrectPin() { …