ImageKeyHelper { public static String getImageUrl(String barcode, String imageName, String size) { String baseUrlString = BuildConfig.STATICURL+ "/images/products/"; String barcodePattern = barcode; if (barcodePattern.length() > 8) { barcodePattern = new StringBuilder(barcode) .insert(3, "/") .insert(7, "/") .insert(11, "/") .toString(); } return baseUrlString + barcodePattern + "/" + imageName + size + ".jpg"; } 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 getImageUrl_BarcodeShorter() { String barcode = "303371"; String imageName = "Image"; String size = "big"; final String expected = BuildConfig.STATICURL + "/images/products/303371/Imagebig.jpg"; assertThat(ImageKeyHelper.getImageUrl(barcode, imageName, size)).isEqualTo(expected); }
@Test public void getImageUrl_BarcodeLonger() { String barcode = "3033710001279"; String imageName = "Image"; String size = "big"; final String expected = BuildConfig.STATICURL + "/images/products/303/371/000/1279/Imagebig.jpg"; assertThat(ImageKeyHelper.getImageUrl(barcode, imageName, size)).isEqualTo(expected); }