ImageKeyHelper { public static String getLanguageCodeFromUrl(ProductImageField field, String url) { if (StringUtils.isBlank(url) || field == null) { return null; } return StringUtils.substringBefore(StringUtils.substringAfterLast(url, field.toString() + "_"), "."); } private  ImageKeyHelper(); static String getImageStringKey(ProductImageField field, Product product); static String getImageStringKey(ProductImageField field, String language); static String getLanguageCodeFromUrl(ProductImageField field, String url); static Bundle createImageBundle(ProductImageField imageType, Product product, String language, String imageUrl); static int getResourceIdForEditAction(ProductImageField field); static int getResourceId(ProductImageField field); static String getImageUrl(String barcode, String imageName, String size); static final String IMAGE_URL; static final String IMAGE_FILE; static final String IMAGE_TYPE; static final String PRODUCT_BARCODE; static final String PRODUCT; static final String LANGUAGE; static final String IMAGE_STRING_ID; static final String IMG_ID; static final String IMAGE_EDIT_SIZE_FILE; }
@Test public void getLanguageCodeFromUrl_blankURL() { url = ""; assertThat(ImageKeyHelper.getLanguageCodeFromUrl(ProductImageField.INGREDIENTS, url)).isNull(); }
@Test public void getLanguageCodeFromUrl_returnsCorrectLanguage() { url = "https: assertThat(ImageKeyHelper.getLanguageCodeFromUrl(ProductImageField.INGREDIENTS, url)).isEqualTo("de"); }