Search in sources :

Example 11 with OptionModel

use of org.apache.tapestry5.OptionModel in project tapestry-5 by apache.

the class EnumSelectModelTest method checkOption.

private void checkOption(final List<OptionModel> options, final int i, final String label, final Stooge value) {
    OptionModel model = options.get(i);
    assertEquals(model.getLabel(), label);
    assertFalse(model.isDisabled());
    assertSame(model.getValue(), value);
    assertNull(model.getAttributes());
}
Also used : OptionModel(org.apache.tapestry5.OptionModel)

Example 12 with OptionModel

use of org.apache.tapestry5.OptionModel in project tapestry-5 by apache.

the class LocalizationSetterImplTest method get_locale_model.

@Test
public void get_locale_model() {
    LocalizationSetter setter = new LocalizationSetterImpl(null, null, null, "en,fr");
    SelectModel model = setter.getSupportedLocalesModel();
    assertNull(model.getOptionGroups());
    List<OptionModel> options = model.getOptions();
    assertEquals(options.size(), 2);
    assertEquals(options.get(0).getLabel(), "English");
    // Note that the label is localized to the underlying locale, not the default locale.
    // That's why its "français" (i.e., as a French speaker would say it), not "French"
    // (like an English speaker).
    assertEquals(options.get(1).getLabel(), "fran\u00e7ais");
    assertEquals(options.get(0).getValue(), Locale.ENGLISH);
    assertEquals(options.get(1).getValue(), Locale.FRENCH);
}
Also used : OptionModel(org.apache.tapestry5.OptionModel) LocalizationSetter(org.apache.tapestry5.services.LocalizationSetter) SelectModel(org.apache.tapestry5.SelectModel) Test(org.testng.annotations.Test)

Example 13 with OptionModel

use of org.apache.tapestry5.OptionModel in project tapestry-5 by apache.

the class OptionGroupModelImplTest method strings_contructor_builds_map.

@Test
public void strings_contructor_builds_map() {
    List<OptionModel> options = Collections.emptyList();
    OptionGroupModel group = new OptionGroupModelImpl("Label", true, options, "fred", "flintstone", "barney", "rubble");
    Map<String, String> attributes = group.getAttributes();
    assertEquals(attributes.size(), 2);
    assertEquals(attributes.get("fred"), "flintstone");
    assertEquals(attributes.get("barney"), "rubble");
}
Also used : OptionGroupModel(org.apache.tapestry5.OptionGroupModel) OptionModel(org.apache.tapestry5.OptionModel) Test(org.testng.annotations.Test)

Example 14 with OptionModel

use of org.apache.tapestry5.OptionModel in project tapestry-5 by apache.

the class OptionGroupModelImplTest method map_contructor_retains_map.

@Test
public void map_contructor_retains_map() {
    List<OptionModel> options = Collections.emptyList();
    Map<String, String> attributes = Collections.emptyMap();
    OptionGroupModel group = new OptionGroupModelImpl("Label", true, options, attributes);
    assertSame(group.getAttributes(), attributes);
}
Also used : OptionGroupModel(org.apache.tapestry5.OptionGroupModel) OptionModel(org.apache.tapestry5.OptionModel) Test(org.testng.annotations.Test)

Example 15 with OptionModel

use of org.apache.tapestry5.OptionModel in project tapestry-5 by apache.

the class OptionGroupModelImplTest method basics.

@Test
public void basics() {
    List<OptionModel> options = Collections.emptyList();
    OptionGroupModel group = new OptionGroupModelImpl("Label", true, options);
    assertEquals(group.toString(), "OptionGroupModel[Label]");
    assertTrue(group.isDisabled());
    assertNull(group.getAttributes());
    assertSame(group.getOptions(), options);
}
Also used : OptionGroupModel(org.apache.tapestry5.OptionGroupModel) OptionModel(org.apache.tapestry5.OptionModel) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)15 OptionModel (org.apache.tapestry5.OptionModel)12 SelectModelImpl (org.apache.tapestry5.internal.SelectModelImpl)8 XMLMarkupModel (org.apache.tapestry5.dom.XMLMarkupModel)6 MarkupWriterImpl (org.apache.tapestry5.internal.services.MarkupWriterImpl)6 StringValueEncoder (org.apache.tapestry5.internal.services.StringValueEncoder)6 OptionModelImpl (org.apache.tapestry5.internal.OptionModelImpl)5 OptionGroupModel (org.apache.tapestry5.OptionGroupModel)4 SelectModel (org.apache.tapestry5.SelectModel)4 Messages (org.apache.tapestry5.commons.Messages)4 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)1 Request (org.apache.tapestry5.http.services.Request)1 Entity (org.apache.tapestry5.integration.app1.data.Entity)1 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)1 OptionGroupModelImpl (org.apache.tapestry5.internal.OptionGroupModelImpl)1 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)1 ValueEncoderSource (org.apache.tapestry5.services.ValueEncoderSource)1 AbstractSelectModel (org.apache.tapestry5.util.AbstractSelectModel)1