ValueContext implements Serializable { public Optional<Locale> getLocale() { return Optional.ofNullable(locale); } ValueContext();  ValueContext(Locale locale);  ValueContext(Component component);  ValueContext(Component component, HasValue<?, ?> hasValue);  ValueContext(Component component, HasValue<?, ?> hasValue,
            Locale locale); Optional<Component> getComponent(); Optional<Locale> getLocale(); @SuppressWarnings("unused") Optional<HasValue<?, ?>> getHasValue();  }
@Test public void locale_from_component() { setLocale(COMPONENT_LOCALE); ValueContext fromComponent = new ValueContext(textField); Locale locale = fromComponent.getLocale().orElse(null); Objects.requireNonNull(locale); Assert.assertEquals("Unexpected locale from component", COMPONENT_LOCALE, locale); }
@Test public void locale_from_ui() { ValueContext fromComponent = new ValueContext(textField); Locale locale = fromComponent.getLocale().orElse(null); Objects.requireNonNull(locale); Assert.assertEquals("Unexpected locale from component", UI_LOCALE, locale); }
@Test public void default_locale() { setLocale(Locale.getDefault()); ValueContext fromComponent = new ValueContext(textField); Locale locale = fromComponent.getLocale().orElse(null); Objects.requireNonNull(locale); Assert.assertEquals("Unexpected locale from component", Locale.getDefault(), locale); }
@Test public void getLocale_localeComesFromComponentUI() { UI.setCurrent(null); UI ui = new UI(); ui.setLocale(Locale.GERMAN); Text text = new Text(""); ui.add(text); ValueContext context = new ValueContext(text); Assert.assertEquals(Locale.GERMAN, context.getLocale().get()); }