use of com.enonic.xp.resource.ResourceKeys in project xp by enonic.
the class LocaleServiceImplTest method getSupportedLocale_noPreferredFound.
@Test
public void getSupportedLocale_noPreferredFound() {
final ResourceKeys resourceKeys = ResourceKeys.from("myapplication:/site/i18n/myphrases.properties", "myapplication:/site/i18n/myphrases_en.properties", "myapplication:/site/i18n/myphrases_en_US.properties", "myapplication:/site/i18n/myphrases_en_US_1.properties", "myapplication:/site/i18n/myphrases_fr.properties", "myapplication:/site/i18n/myphrases_ca.properties");
when(resourceService.findFiles(any(), anyString())).thenReturn(resourceKeys);
List<Locale> preferredLocales = localeList("no");
Locale supportedLocale = localeService.getSupportedLocale(preferredLocales, ApplicationKey.from("myapplication"), "/myphrases");
assertNull(supportedLocale);
}
use of com.enonic.xp.resource.ResourceKeys in project xp by enonic.
the class LocaleServiceImplTest method getSupportedLocale_LanguagePreferredFound.
@Test
public void getSupportedLocale_LanguagePreferredFound() {
final ResourceKeys resourceKeys = ResourceKeys.from("myapplication:/site/i18n/myphrases.properties", "myapplication:/site/i18n/myphrases_en.properties", "myapplication:/site/i18n/myphrases_en_US.properties", "myapplication:/site/i18n/myphrases_en_US_1.properties", "myapplication:/site/i18n/myphrases_fr.properties", "myapplication:/site/i18n/myphrases_ca.properties");
when(resourceService.findFiles(any(), anyString())).thenReturn(resourceKeys);
List<Locale> preferredLocales = localeList("en-UK");
Locale supportedLocale = localeService.getSupportedLocale(preferredLocales, ApplicationKey.from("myapplication"), "/myphrases");
assertNotNull(supportedLocale);
assertEquals("en", supportedLocale.toLanguageTag());
}
use of com.enonic.xp.resource.ResourceKeys in project xp by enonic.
the class LocaleServiceImplTest method getSupportedLocale_nn_file_supports_no_locale.
@Test
public void getSupportedLocale_nn_file_supports_no_locale() {
final ResourceKeys resourceKeys = ResourceKeys.from("myapplication:/site/i18n/myphrases.properties", "myapplication:/site/i18n/myphrases_nn.properties");
when(resourceService.findFiles(any(), anyString())).thenReturn(resourceKeys);
List<Locale> preferredLocales = localeList("no");
Locale supportedLocale = localeService.getSupportedLocale(preferredLocales, ApplicationKey.from("myapplication"), "/myphrases");
assertNotNull(supportedLocale);
assertEquals("no", supportedLocale.toLanguageTag());
}
use of com.enonic.xp.resource.ResourceKeys in project xp by enonic.
the class LocaleServiceImplTest method getSupportedLocale_onePreferredFound.
@Test
public void getSupportedLocale_onePreferredFound() {
final ResourceKeys resourceKeys = ResourceKeys.from("myapplication:/site/i18n/myphrases.properties", "myapplication:/site/i18n/myphrases_en.properties", "myapplication:/site/i18n/myphrases_en_US.properties", "myapplication:/site/i18n/myphrases_en_US_1.properties", "myapplication:/site/i18n/myphrases_fr.properties", "myapplication:/site/i18n/myphrases_ca.properties");
when(resourceService.findFiles(any(), anyString())).thenReturn(resourceKeys);
List<Locale> preferredLocales = localeList("en-US");
Locale supportedLocale = localeService.getSupportedLocale(preferredLocales, ApplicationKey.from("myapplication"), "/myphrases");
assertNotNull(supportedLocale);
assertEquals("en-US", supportedLocale.toLanguageTag());
}
use of com.enonic.xp.resource.ResourceKeys in project xp by enonic.
the class ResourceServiceImplTest method testFindFiles.
@Test
void testFindFiles() throws Exception {
newFile("a.txt");
newFile("b/c.txt");
newFile("c/d/e.png");
final ResourceKeys keys1 = this.resourceService.findFiles(this.appKey, ".+");
assertEquals(3, keys1.getSize());
assertEquals("[myapp:/b/c.txt, myapp:/a.txt, myapp:/c/d/e.png]", keys1.toString());
final ResourceKeys keys2 = this.resourceService.findFiles(this.appKey, "b/c\\.txt");
assertEquals(1, keys2.getSize());
assertEquals("[myapp:/b/c.txt]", keys2.toString());
final ResourceKeys keys3 = this.resourceService.findFiles(this.appKey, ".+\\.txt");
assertEquals(2, keys3.getSize());
assertEquals("[myapp:/b/c.txt, myapp:/a.txt]", keys3.toString());
}
Aggregations