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