DatadogTransportConverter implements Converter<DatadogTransport> { @Override public DatadogTransport convertFrom(String value) { try { return DatadogTransport.valueOf(Strings.nullToEmpty(value).toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new ParameterException("Couldn't convert value \"" + value + "\" to Datadog transport.", e); } }  @Override DatadogTransport convertFrom(String value); @Override String convertTo(DatadogTransport value);  }
@Test public void convertFromValidString() throws Exception { Assert.assertEquals(DatadogTransport.UDP, new DatadogTransportConverter().convertFrom("UDP")); }
@Test public void convertFromValidLowerCaseString() throws Exception { assertEquals(DatadogTransport.HTTP, new DatadogTransportConverter().convertFrom("http")); }
@Test public void convertFromInvalidString() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("Couldn't convert value \"Foobar\" to Datadog transport."); new DatadogTransportConverter().convertFrom("Foobar"); }
@Test public void convertFromNull() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("Couldn't convert value \"null\" to Datadog transport."); new DatadogTransportConverter().convertFrom(null); }