JsonChatDeserializer extends JsonDeserializer<T> { protected String getAsTextOrNull(JsonNode node) { if (node == null) { return null; } else { return node.asText(); } }    }
@Test public void testGetAsTextOrNull() { assertNull(underTest.getAsTextOrNull(null)); JsonNode mockNode = mock(JsonNode.class); String returnValue = "test"; when(mockNode.asText()).thenReturn(returnValue); assertEquals(returnValue, underTest.getAsTextOrNull(mockNode)); }