Search in sources :

Example 11 with SelectModel

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

the class EnumSelectModelTest method error_on_invalid_class.

@Test
public // TAP5-2495
void error_on_invalid_class() {
    Messages messages = mockMessages();
    replay();
    Class c = String.class;
    try {
        SelectModel model = new EnumSelectModel(c, messages);
        fail("should have thrown an exception");
    } catch (IllegalArgumentException e) {
        assertMessageContains(e, "not an enum class");
    }
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) SelectModel(org.apache.tapestry5.SelectModel) Test(org.testng.annotations.Test)

Example 12 with SelectModel

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

the class EnumSelectModelTest method unprefixed_name_in_message_catalog.

@Test
public void unprefixed_name_in_message_catalog() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    train_contains(messages, "MOE", true);
    train_get(messages, "MOE", "Sir Moe Howard");
    replay();
    SelectModel model = new EnumSelectModel(Stooge.class, messages);
    List<OptionModel> options = model.getOptions();
    assertEquals(options.size(), 3);
    checkOption(options, 0, "Sir Moe Howard", Stooge.MOE);
    checkOption(options, 1, "Larry", Stooge.LARRY);
    checkOption(options, 2, "Curly Joe", Stooge.CURLY_JOE);
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) OptionModel(org.apache.tapestry5.OptionModel) SelectModel(org.apache.tapestry5.SelectModel) Test(org.testng.annotations.Test)

Aggregations

OptionModel (org.apache.tapestry5.OptionModel)7 Test (org.testng.annotations.Test)7 SelectModel (org.apache.tapestry5.SelectModel)6 Messages (org.apache.tapestry5.commons.Messages)6 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)3 OptionModelImpl (org.apache.tapestry5.internal.OptionModelImpl)3 List (java.util.List)2 Request (org.apache.tapestry5.http.services.Request)2 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)2 SelectModelImpl (org.apache.tapestry5.internal.SelectModelImpl)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Date (java.util.Date)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1 Asset (org.apache.tapestry5.Asset)1 Block (org.apache.tapestry5.Block)1