Package org.apache.tapestry

Examples of org.apache.tapestry.OptionModel


        verify();
    }

    private void checkOption(List<OptionModel> options, int i, String label, Stooge value)
    {
        OptionModel model = options.get(i);

        assertEquals(model.getLabel(), label);
        assertFalse(model.isDisabled());
        assertSame(model.getValue(), value);
        assertNull(model.getAttributes());
    }
View Full Code Here


    @Test
    public void object_to_option_model()
    {
        Object object = new Integer(27);
        OptionModel model = TapestryInternalUtils.toOptionModel(object);

        assertEquals(model.getLabel(), "27");
        assertEquals(model.getValue(), object);
    }
View Full Code Here

public class OptionModelImplTest extends Assert
{
    @Test
    public void basics()
    {
        OptionModel model = new OptionModelImpl("Label", false, this);

        assertEquals(model.getLabel(), "Label");
        assertFalse(model.isDisabled());
        assertSame(model.getValue(), this);
        assertNull(model.getAttributes());

        model = new OptionModelImpl("Fred", true, "fred");

        assertEquals(model.getLabel(), "Fred");
        assertTrue(model.isDisabled());

        assertEquals(model.toString(), "OptionModel[Fred fred]");
    }
View Full Code Here

    }

    @Test
    public void attributes_as_extra_parameters()
    {
        OptionModel model = new OptionModelImpl("Label", false, this, "fred", "flintstone",
                                                "barney", "rubble");

        Map<String, String> attributes = model.getAttributes();

        assertEquals(attributes.size(), 2);
        assertEquals(attributes.get("fred"), "flintstone");
        assertEquals(attributes.get("barney"), "rubble");
    }
View Full Code Here

    @Test
    public void attributes_as_map_are_retained()
    {
        Map<String, String> attributes = Collections.emptyMap();

        OptionModel model = new OptionModelImpl("Label", false, this, attributes);

        assertSame(model.getAttributes(), attributes);
    }
View Full Code Here

    }

    @Test
    public void string_to_option_model_just_label()
    {
        OptionModel model = TapestryInternalUtils.toOptionModel("Just A Label");

        assertEquals(model.getLabel(), "Just A Label");
        assertEquals(model.getValue(), "Just A Label");
    }
View Full Code Here

    }

    @Test
    public void string_to_option_model()
    {
        OptionModel model = TapestryInternalUtils.toOptionModel("my-value=Some Label");

        assertEquals(model.getLabel(), "Some Label");
        assertEquals(model.getValue(), "my-value");
    }
View Full Code Here

    @Test
    public void map_entry_to_option_model()
    {
        Map<String, String> map = Collections.singletonMap("key", "value");
        Map.Entry entry = map.entrySet().iterator().next();
        OptionModel model = TapestryInternalUtils.toOptionModel(entry);

        assertEquals(model.getLabel(), "value");
        assertEquals(model.getValue(), "key");
    }
View Full Code Here

    @Test
    public void object_to_option_model()
    {
        Object object = new Integer(27);
        OptionModel model = TapestryInternalUtils.toOptionModel(object);

        assertEquals(model.getLabel(), "27");
        assertEquals(model.getValue(), "27");
    }
View Full Code Here

public class OptionModelImplTest extends Assert
{
    @Test
    public void basics()
    {
        OptionModel model = new OptionModelImpl("Label", false, this);

        assertEquals(model.getLabel(), "Label");
        assertFalse(model.isDisabled());
        assertSame(model.getValue(), this);
        assertNull(model.getAttributes());

        model = new OptionModelImpl("Fred", true, "fred");

        assertEquals(model.getLabel(), "Fred");
        assertTrue(model.isDisabled());

        assertEquals(model.toString(), "OptionModel[Fred fred]");
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.OptionModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.