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