OpenTsdbProtocolConverter implements Converter<OpenTsdbProtocol> { @Override public String convertTo(OpenTsdbProtocol value) { if (value == null) { throw new ParameterException("Couldn't convert \"null\" to string."); } return value.name(); }  @Override OpenTsdbProtocol convertFrom(String value); @Override String convertTo(OpenTsdbProtocol value);  }
@Test public void convertToWithNull() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("Couldn't convert \"null\" to string."); new OpenTsdbProtocolConverter().convertTo(null); }
@Test public void convertToWithValidOpenTsdbProtocol() throws Exception { final String s = new OpenTsdbProtocolConverter().convertTo(OpenTsdbProtocol.HTTP); assertEquals("HTTP", s); }