Search in sources :

Example 6 with MutableComponentModel

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

the class MutableComponentModelImplTest method no_persistence_defined_for_field.

@Test
public void no_persistence_defined_for_field() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    try {
        model.getFieldPersistenceStrategy("someField");
        unreachable();
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "No field persistence strategy has been defined for field \'someField\'.");
    }
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 7 with MutableComponentModel

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

the class MutableComponentModelImplTest method get_persistent_field_names_reflects_parent_model.

@Test
public void get_persistent_field_names_reflects_parent_model() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel parent = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    assertEquals(parent.setFieldPersistenceStrategy("wilma", "session"), "wilma");
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, parent, false, null);
    assertEquals(model.setFieldPersistenceStrategy("fred", "session"), "fred");
    assertEquals(model.setFieldPersistenceStrategy("barney", "client"), "barney");
    assertEquals(model.getPersistentFieldNames(), Arrays.asList("barney", "fred", "wilma"));
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 8 with MutableComponentModel

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

the class MutableComponentModelImplTest method set_and_get_meta.

@Test
public void set_and_get_meta() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    model.setMeta("fred", "flintstone");
    model.setMeta("barney", "rubble");
    assertEquals(model.getMeta("fred"), "flintstone");
    assertEquals(model.getMeta("barney"), "rubble");
    // Ensure case insensitive:
    assertEquals(model.getMeta("FRED"), "flintstone");
    assertEquals(model.getMeta("BARNEY"), "rubble");
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 9 with MutableComponentModel

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

the class MutableComponentModelImplTest method handles_render_phase.

/**
 * @since 5.0.19
 */
@Test
public void handles_render_phase() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    model.addRenderPhase(BeginRender.class);
    assertTrue(model.getHandledRenderPhases().contains(BeginRender.class));
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) BeginRender(org.apache.tapestry5.annotations.BeginRender) Test(org.testng.annotations.Test)

Example 10 with MutableComponentModel

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

the class MutableComponentModelImplTest method get_persistent_field_names_are_sorted.

@Test
public void get_persistent_field_names_are_sorted() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    assertEquals(model.setFieldPersistenceStrategy("fred", "session"), "fred");
    assertEquals(model.setFieldPersistenceStrategy("barney", "client"), "barney");
    assertEquals(model.getPersistentFieldNames(), Arrays.asList("barney", "fred"));
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Aggregations

MutableComponentModel (org.apache.tapestry5.model.MutableComponentModel)42 Test (org.testng.annotations.Test)42 Resource (org.apache.tapestry5.commons.Resource)37 Logger (org.slf4j.Logger)37 MutableEmbeddedComponentModel (org.apache.tapestry5.model.MutableEmbeddedComponentModel)10 PlasticField (org.apache.tapestry5.plastic.PlasticField)7 PlasticClass (org.apache.tapestry5.plastic.PlasticClass)6 PlasticMethod (org.apache.tapestry5.plastic.PlasticMethod)4 BeginRender (org.apache.tapestry5.annotations.BeginRender)3 Location (org.apache.tapestry5.commons.Location)3 Annotation (java.lang.annotation.Annotation)2 PersistenceContext (javax.persistence.PersistenceContext)2 SneakyThrows (lombok.SneakyThrows)2 ComponentResources (org.apache.tapestry5.ComponentResources)2 Import (org.apache.tapestry5.annotations.Import)2 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)2 JSONArray (org.apache.tapestry5.json.JSONArray)2 InstanceContext (org.apache.tapestry5.plastic.InstanceContext)2 MethodAdvice (org.apache.tapestry5.plastic.MethodAdvice)2 SessionTracker (com.flowlogix.web.mixins.SessionTracker)1