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