AssetMappingConverter implements IStringConverter<Map<String, String>> { @Override public Map<String, String> convert(String value) { Map<String, String> map = null; if (value != null) { try { map = Splitter.on(";").withKeyValueSeparator(":").split(value); } catch (IllegalArgumentException iae) { throw new ParameterException("Invalid asset mapping [" + value + "]"); } } return map; }  @Override Map<String, String> convert(String value);  }
@Test public void testConvertNull() { AssetMappingConverter assetMappingConverter = new AssetMappingConverter(); Map<String, String> convert = assetMappingConverter.convert(null); assertNull(convert); }
@Test public void testConvertValid() { AssetMappingConverter assetMappingConverter = new AssetMappingConverter(); Map<String, String> convert = assetMappingConverter.convert("1a:1b;2a:2b"); assertEquals("1b", convert.get("1a")); assertEquals("2b", convert.get("2a")); assertEquals(2, convert.size()); }
@Test(expected = ParameterException.class) public void testConvertInvalid() { AssetMappingConverter assetMappingConverter = new AssetMappingConverter(); Map<String, String> convert = assetMappingConverter.convert("dsafdsf"); assertEquals(0, convert.size()); }