SVGParser { protected static Integer getHexAttr(String name, Attributes attributes) { String v = getStringAttr(name, attributes); if (v == null) { return null; } else { try { return Integer.parseInt(v.substring(1), 16); } catch (NumberFormatException nfe) { return null; } } }  static SVG getSVGFromInputStream(InputStream svgData); static SVG getSVGFromInputStream(InputStream svgData, int targetWidth, int targetHeight); static SVG getSVGFromResource(Resources resources, int resId); static SVG getSVGFromAsset(AssetManager assetMngr, String svgPath); static SVG getSVGFromInputStream(InputStream svgData, int searchColor, int replaceColor,
                                            int targetWidth, int targetHeight); static SVG getSVGFromString(String svgData, int searchColor, int replaceColor); static SVG getSVGFromResource(Resources resources, int resId, int searchColor, int replaceColor); static SVG getSVGFromAsset(AssetManager assetMngr, String svgPath, int searchColor, int replaceColor); static Path parsePath(String pathString);  }
@Test public void testGetHexAttr_null() { Integer res = SVGParser.getHexAttr("someColor", new AttributesMock()); assertThat(res, is(nullValue())); }
@Test public void testGetHexAttr() { Integer res = SVGParser.getHexAttr("someColor", new AttributesMock(new AttributesMock.Pair("someColor", "#ff0000"))); assertThat(res, is(16711680)); }
@Test public void testGetHexAttr_wrongFormat() { Integer res = SVGParser.getHexAttr("someColor", new AttributesMock(new AttributesMock.Pair("someColor", "#blabla"))); assertThat(res, is(nullValue())); }