### Question:
ChangeDatePropertyParser implements PropertyParser { @Override public Comparable<?> parseForSort(String value) { if (value != null) { try { long timeStamp = readTimeStamp(value); return timeStamp; } catch (IOException e) { LOG.error("Cannot parse '{}' as Change", value); LOG.error("Exception thrown", e); } } return null; } ChangeDatePropertyParser(); @Override String parse(String value); @Override Comparable<?> parseForSort(String value); static final Logger LOG; }### Answer:
@Test public void parseForSortReturnsTheTimestamp() throws JsonProcessingException { long timeStampOnJan20th2016 = 1453290593000L; Change change = new Change(timeStampOnJan20th2016, "user", "vre"); String changeString = new ObjectMapper().writeValueAsString(change); Object result = instance.parseForSort(changeString); assertThat(result, is(timeStampOnJan20th2016)); }
@Test public void parseForSortReturnsNullIfTheInputCannotBeParsed() { Object output = instance.parseForSort("notASerializedChange"); assertThat(output, is(nullValue())); }