Search in sources :

Example 1 with MutableEmbeddedComponentModel

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

the class MutableComponentModelImplTest method add_duplicate_parameters_to_embedded.

@Test
public void add_duplicate_parameters_to_embedded() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    MutableEmbeddedComponentModel fred = model.addEmbeddedComponent("fred", "Fred", COMPONENT_CLASS_NAME, false, null);
    fred.addParameter("city", "bedrock");
    try {
        fred.addParameter("city", "slateville");
        unreachable();
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "A value for parameter 'city' of embedded component fred (of component class org.example.components.Foo) has already been provided.");
    }
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) MutableEmbeddedComponentModel(org.apache.tapestry5.model.MutableEmbeddedComponentModel) Test(org.testng.annotations.Test)

Example 2 with MutableEmbeddedComponentModel

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

the class MutableComponentModelImplTest method mixin_order_remembered.

@Test
public void mixin_order_remembered() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    MutableEmbeddedComponentModel fred = model.addEmbeddedComponent("fred", "Fred", COMPONENT_CLASS_NAME, false, null);
    fred.addMixin("zip.zop.Zoom", "before:*", "after:foo.bar.Baz");
    fred.addMixin("foo.bar.Baz");
    assertEquals(fred.getConstraintsForMixin("zip.zop.Zoom"), new String[] { "before:*", "after:foo.bar.Baz" });
    assertEquals(fred.getConstraintsForMixin("foo.bar.Baz"), new String[0]);
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) MutableEmbeddedComponentModel(org.apache.tapestry5.model.MutableEmbeddedComponentModel) Test(org.testng.annotations.Test)

Example 3 with MutableEmbeddedComponentModel

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

the class MutableComponentModelImplTest method add_parameters_to_embedded.

@Test
public void add_parameters_to_embedded() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    MutableEmbeddedComponentModel fred = model.addEmbeddedComponent("fred", "Fred", COMPONENT_CLASS_NAME, false, null);
    assertTrue(fred.getParameterNames().isEmpty());
    fred.addParameter("city", "bedrock");
    fred.addParameter("job", "crane operator");
    assertEquals(fred.getParameterNames(), Arrays.asList("city", "job"));
    assertEquals(fred.getParameterValue("city"), "bedrock");
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) MutableEmbeddedComponentModel(org.apache.tapestry5.model.MutableEmbeddedComponentModel) Test(org.testng.annotations.Test)

Example 4 with MutableEmbeddedComponentModel

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

the class MutableComponentModelImplTest method mixin_names_is_initially_empty_list.

@Test
public void mixin_names_is_initially_empty_list() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    MutableEmbeddedComponentModel fred = model.addEmbeddedComponent("fred", "Fred", COMPONENT_CLASS_NAME, false, null);
    assertTrue(fred.getMixinClassNames().isEmpty());
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) MutableEmbeddedComponentModel(org.apache.tapestry5.model.MutableEmbeddedComponentModel) Test(org.testng.annotations.Test)

Example 5 with MutableEmbeddedComponentModel

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

the class MutableComponentModelImplTest method mixin_class_names_remembered_in_order_added.

@Test
public void mixin_class_names_remembered_in_order_added() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    MutableEmbeddedComponentModel fred = model.addEmbeddedComponent("fred", "Fred", COMPONENT_CLASS_NAME, false, null);
    fred.addMixin("zip.zop.Zoom");
    fred.addMixin("foo.bar.Baz");
    assertEquals(fred.getMixinClassNames(), Arrays.asList("zip.zop.Zoom", "foo.bar.Baz"));
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) MutableEmbeddedComponentModel(org.apache.tapestry5.model.MutableEmbeddedComponentModel) Test(org.testng.annotations.Test)

Aggregations

MutableEmbeddedComponentModel (org.apache.tapestry5.model.MutableEmbeddedComponentModel)9 Resource (org.apache.tapestry5.commons.Resource)8 MutableComponentModel (org.apache.tapestry5.model.MutableComponentModel)8 Logger (org.slf4j.Logger)8 Test (org.testng.annotations.Test)8 Location (org.apache.tapestry5.commons.Location)3 Component (org.apache.tapestry5.annotations.Component)1 MixinClasses (org.apache.tapestry5.annotations.MixinClasses)1 Mixins (org.apache.tapestry5.annotations.Mixins)1 StringLocation (org.apache.tapestry5.commons.internal.services.StringLocation)1 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)1 KeyValue (org.apache.tapestry5.internal.KeyValue)1