@Test public void testResolveRelativeInternalFileNamePath() { final LanguageService languageService = context.mock(LanguageService.class, "languageService"); context.checking(new Expectations() {{ allowing(languageService).getSupportedLanguages(); will(returnValue(Arrays.asList("en", "ru", "uk"))); }}); final MediaFileNameStrategy mediaFileNameStrategy = new AbstractMediaFileNameStrategyImpl("/root/img/", "root", languageService) { @Override public String resolveObjectCodeInternal(final String url) { return null; } }; assertEquals("file-name_CODE_a.jpeg", mediaFileNameStrategy.resolveFileName("file-name_CODE_a.jpeg")); assertEquals("file-name_CODE_a.jpeg", mediaFileNameStrategy.resolveFileName("somepath" + File.separator + "file-name_CODE_a.jpeg")); assertEquals("1261644759_627724_russkaya-magiya.jpg", mediaFileNameStrategy.resolveFileName("posts/2009-12/1261644759_627724_russkaya-magiya.jpg")); assertEquals("1261644759_627724_russkaya-magiya.jpg", mediaFileNameStrategy.resolveFileName("posts/2009-12/1261644759_627724_russkaya-magiya.jpg?w=10&h=4")); assertEquals("1261644759_627724_russkaya-magiya.jpg", mediaFileNameStrategy.resolveFileName("posts/2009-12/1261644759_627724_russkaya-magiya.jpg?w=10&h=4")); assertEquals("1261644759_627724_russkaya-magiya.jpg", mediaFileNameStrategy.resolveFileName("posts/2009-12/1261644759_627724_russkaya-magiya.jpg?w=10&h=4~!@#$%^&*()_+")); assertEquals("root" + File.separator + "file-name_CODE_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_CODE_a.jpeg", null, "en")); assertEquals("root" + File.separator + "file-name_CODE_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_CODE_a.jpeg", null, null)); assertEquals("root" + File.separator + "C" + File.separator + "CODE" + File.separator + "file-name_CODE_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_CODE_a.jpeg", "CODE", "en")); assertEquals("root" + File.separator + "C" + File.separator + "CODE" + File.separator + "file-name_CODE_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_CODE_a.jpeg", "CODE", null)); assertEquals("root" + File.separator + "10x30" + File.separator + "C" + File.separator + "CODE" + File.separator + "file-name_CODE_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_CODE_a.jpeg", "CODE", "en", "10", "30")); assertEquals("root" + File.separator + "10x30" + File.separator + "C" + File.separator + "CODE" + File.separator + "file-name_CODE_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_CODE_a.jpeg", "CODE", null, "10", "30")); assertEquals("root" + File.separator + "file-name_code_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_code_a.jpeg", null, "en")); assertEquals("root" + File.separator + "file-name_code_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_code_a.jpeg", null, null)); assertEquals("root" + File.separator + "C" + File.separator + "code" + File.separator + "file-name_code_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_code_a.jpeg", "code", "en")); assertEquals("root" + File.separator + "C" + File.separator + "code" + File.separator + "file-name_code_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_code_a.jpeg", "code", null)); assertEquals("root" + File.separator + "10x30" + File.separator + "C" + File.separator + "code" + File.separator + "file-name_code_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_code_a.jpeg", "code", "en", "10", "30")); assertEquals("root" + File.separator + "10x30" + File.separator + "C" + File.separator + "code" + File.separator + "file-name_code_a.jpeg", mediaFileNameStrategy.resolveRelativeInternalFileNamePath("file-name_code_a.jpeg", "code", null, "10", "30")); }
@Override public String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale) { return resolveRelativeInternalFileNamePath(fileName, code, locale, null, null); }
AbstractMediaFileNameStrategyImpl implements MediaFileNameStrategy { @Override public String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale) { return resolveRelativeInternalFileNamePath(fileName, code, locale, null, null); } }
AbstractMediaFileNameStrategyImpl implements MediaFileNameStrategy { @Override public String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale) { return resolveRelativeInternalFileNamePath(fileName, code, locale, null, null); } protected  AbstractMediaFileNameStrategyImpl(final String urlPath,
                                                final String relativeInternalRootDirectory,
                                                final LanguageService languageService); }
AbstractMediaFileNameStrategyImpl implements MediaFileNameStrategy { @Override public String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale) { return resolveRelativeInternalFileNamePath(fileName, code, locale, null, null); } protected  AbstractMediaFileNameStrategyImpl(final String urlPath,
                                                final String relativeInternalRootDirectory,
                                                final LanguageService languageService); @Override String getUrlPath(); @Override String getRelativeInternalRootDirectory(); @Override String resolveObjectCode(final String url); @Override String resolveLocale(final String url); @Override String resolveSuffix(final String url); @Override String resolveFileName(final String url); @Override String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale); @Override String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale, final String width, final String height); @Override String createRollingFileName(final String fullFileName, final String code, final String suffix, final String locale); void setAttributePrefix(final String attributePrefix); }
AbstractMediaFileNameStrategyImpl implements MediaFileNameStrategy { @Override public String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale) { return resolveRelativeInternalFileNamePath(fileName, code, locale, null, null); } protected  AbstractMediaFileNameStrategyImpl(final String urlPath,
                                                final String relativeInternalRootDirectory,
                                                final LanguageService languageService); @Override String getUrlPath(); @Override String getRelativeInternalRootDirectory(); @Override String resolveObjectCode(final String url); @Override String resolveLocale(final String url); @Override String resolveSuffix(final String url); @Override String resolveFileName(final String url); @Override String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale); @Override String resolveRelativeInternalFileNamePath(final String fileName, final String code, final String locale, final String width, final String height); @Override String createRollingFileName(final String fullFileName, final String code, final String suffix, final String locale); void setAttributePrefix(final String attributePrefix);  }