Logo { @Nullable public static String getUriFromSvgUri(@Nullable String iconUrl, int width, int height) { if (iconUrl == null || iconUrl.isEmpty()) { return null; } final Matcher matcher = LOGOS_REGEX.matcher(iconUrl); if (!matcher.matches()) { return null; } final int maxSide = Math.max(width, height); final LogoSizes logoSize = LogoSizes.getSize(maxSide); return String.format(Locale.US, "%s/pngs/%s_%d.png", matcher.group(2), matcher.group(3), logoSize.size); }  @Nullable static String getUriFromSvgUri(@Nullable String iconUrl, int width, int height);  }
@Test public void getUrl() throws Exception { assertNull("Should retrun null when the SvgLogoUrl is null", Logo.getUriFromSvgUri(null, 150, 150)); assertNull("Should return null when the url doesn't contain $.svg", Logo.getUriFromSvgUri("abc", 150, 150)); final String inputUrl = "https: final String outputUrl = "https: assertEquals("It should generate the given url for the given input", Logo.getUriFromSvgUri(inputUrl, 180, 180), outputUrl); assertEquals("It should return the right url even if the input is inside a url(...)", Logo.getUriFromSvgUri("url(" + inputUrl + ")", 180, 180), outputUrl); }