Search in sources :

Example 26 with MessageBundle

use of com.enonic.xp.i18n.MessageBundle 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

MessageBundle (com.enonic.xp.i18n.MessageBundle)26 Test (org.junit.jupiter.api.Test)22 Properties (java.util.Properties)6 Locale (java.util.Locale)3 ApplicationKey (com.enonic.xp.app.ApplicationKey)2 LocaleService (com.enonic.xp.i18n.LocaleService)2 LinkedHashSet (java.util.LinkedHashSet)2 Application (com.enonic.xp.app.Application)1 ResourceKeys (com.enonic.xp.resource.ResourceKeys)1 LocalDate (java.time.LocalDate)1 LocalTime (java.time.LocalTime)1