Search in sources :

Example 1 with LocaleService

use of com.enonic.xp.i18n.LocaleService in project xp by enonic.

the class GetSupportedLocalesScriptTest method initialize.

@Override
protected void initialize() throws Exception {
    super.initialize();
    final LocaleService localeService = Mockito.mock(LocaleService.class);
    final Set<Locale> locales = new LinkedHashSet<>();
    locales.add(new Locale("en"));
    locales.add(new Locale("es"));
    locales.add(new Locale("ca"));
    Mockito.when(localeService.getLocales(any(ApplicationKey.class), any())).thenReturn(locales);
    addService(LocaleService.class, localeService);
    getPortalRequest().setSite(Site.create().name(ContentName.from("test")).parentPath(ContentPath.ROOT).language(Locale.ENGLISH).build());
}
Also used : Locale(java.util.Locale) LinkedHashSet(java.util.LinkedHashSet) ApplicationKey(com.enonic.xp.app.ApplicationKey) LocaleService(com.enonic.xp.i18n.LocaleService)

Example 2 with LocaleService

use of com.enonic.xp.i18n.LocaleService in project xp by enonic.

the class LocalizeNoHttpTest method initialize.

@Override
protected void initialize() throws Exception {
    super.initialize();
    final LocaleService localeService = Mockito.mock(LocaleService.class);
    final Set<Locale> locales = new LinkedHashSet<>();
    locales.add(new Locale("en"));
    Mockito.when(localeService.getLocales(eq(ApplicationKey.from("com.enonic.myapplication")), any())).thenReturn(locales);
    final MessageBundle bundle = Mockito.mock(MessageBundle.class, this::answer);
    Mockito.when(localeService.getBundle(eq(ApplicationKey.from("com.enonic.myapplication")), any(), any())).thenReturn(bundle);
    addService(LocaleService.class, localeService);
}
Also used : Locale(java.util.Locale) LinkedHashSet(java.util.LinkedHashSet) MessageBundle(com.enonic.xp.i18n.MessageBundle) LocaleService(com.enonic.xp.i18n.LocaleService)

Example 3 with LocaleService

use of com.enonic.xp.i18n.LocaleService in project xp by enonic.

the class I18NScriptTest method initialize.

@Override
protected void initialize() throws Exception {
    super.initialize();
    final LocaleService localeService = Mockito.mock(LocaleService.class);
    final Set<Locale> locales = new LinkedHashSet<>();
    locales.add(new Locale("en"));
    locales.add(new Locale("es"));
    locales.add(new Locale("ca"));
    Mockito.when(localeService.getLocales(any(ApplicationKey.class), any())).thenReturn(locales);
    final MessageBundle bundle = Mockito.mock(MessageBundle.class, this::answer);
    Mockito.when(localeService.getBundle(any(ApplicationKey.class), any(Locale.class), any())).thenReturn(bundle);
    addService(LocaleService.class, localeService);
    getPortalRequest().setSite(Site.create().name(ContentName.from("test")).parentPath(ContentPath.ROOT).language(Locale.ENGLISH).build());
}
Also used : Locale(java.util.Locale) LinkedHashSet(java.util.LinkedHashSet) MessageBundle(com.enonic.xp.i18n.MessageBundle) ApplicationKey(com.enonic.xp.app.ApplicationKey) LocaleService(com.enonic.xp.i18n.LocaleService)

Aggregations

LocaleService (com.enonic.xp.i18n.LocaleService)3 LinkedHashSet (java.util.LinkedHashSet)3 Locale (java.util.Locale)3 ApplicationKey (com.enonic.xp.app.ApplicationKey)2 MessageBundle (com.enonic.xp.i18n.MessageBundle)2