LoggerConverter implements Converter<Logger> { @Override public String convertTo(Logger logger) { if (logger == null) { throw new ParameterException("Couldn't convert \"null\" to string."); } return logger.getName(); }  @Override Logger convertFrom(String value); @Override String convertTo(Logger logger);  }
@Test public void convertTo() throws Exception { assertEquals("test", new LoggerConverter().convertTo(LoggerFactory.getLogger("test"))); }
@Test public void convertToWithNull() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("Couldn't convert \"null\" to string."); new LoggerConverter().convertTo(null); }