Search in sources :

Example 1 with PersistentFieldBundle

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

the class PersistentFieldBundleImplTest method get_nested_component_value.

@Test
public void get_nested_component_value() {
    String value = "FIELD-VALUE";
    PersistentFieldChange change = new PersistentFieldChangeImpl("foo.bar", "field", value);
    Collection<PersistentFieldChange> changes = Arrays.asList(change);
    PersistentFieldBundle bundle = new PersistentFieldBundleImpl(changes);
    assertTrue(bundle.containsValue("foo.bar", "field"));
    assertSame(bundle.getValue("foo.bar", "field"), value);
    assertFalse(bundle.containsValue("foo.bar", "other"));
}
Also used : PersistentFieldBundle(org.apache.tapestry5.services.PersistentFieldBundle) PersistentFieldChange(org.apache.tapestry5.services.PersistentFieldChange) Test(org.testng.annotations.Test)

Example 2 with PersistentFieldBundle

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

the class PersistentFieldBundleImplTest method get_root_component_value.

@Test
public void get_root_component_value() {
    String value = "FIELD-VALUE";
    PersistentFieldChange change = new PersistentFieldChangeImpl("", "field", value);
    Collection<PersistentFieldChange> changes = Arrays.asList(change);
    PersistentFieldBundle bundle = new PersistentFieldBundleImpl(changes);
    assertTrue(bundle.containsValue("", "field"));
    assertTrue(bundle.containsValue(null, "field"));
    assertSame(bundle.getValue("", "field"), value);
    assertSame(bundle.getValue(null, "field"), value);
    assertFalse(bundle.containsValue("", "other"));
    assertFalse(bundle.containsValue(null, "other"));
}
Also used : PersistentFieldBundle(org.apache.tapestry5.services.PersistentFieldBundle) PersistentFieldChange(org.apache.tapestry5.services.PersistentFieldChange) Test(org.testng.annotations.Test)

Example 3 with PersistentFieldBundle

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

the class PersistentFieldManagerImplTest method gather_changes.

@Test
public void gather_changes() {
    Object value1 = new Object();
    Object value2 = new Object();
    PersistentFieldStrategy strat1 = newPersistentFieldStrategy();
    Collection<PersistentFieldChange> changes1 = newList();
    changes1.add(new PersistentFieldChangeImpl("component", "field1", value1));
    PersistentFieldStrategy strat2 = newPersistentFieldStrategy();
    Collection<PersistentFieldChange> changes2 = newList();
    changes2.add(new PersistentFieldChangeImpl("component", "field2", value2));
    // We don't know the exact order the strategies will be ordered in the map,
    // so we can't guarantee the order the strategies will be invoked.
    getMocksControl().checkOrder(false);
    expect(strat1.gatherFieldChanges("foo.Bar")).andReturn(changes1);
    expect(strat2.gatherFieldChanges("foo.Bar")).andReturn(changes2);
    replay();
    Map<String, PersistentFieldStrategy> strategies = newMap();
    strategies.put("alpha", strat1);
    strategies.put("beta", strat2);
    PersistentFieldManager manager = new PersistentFieldManagerImpl(null, strategies);
    PersistentFieldBundle bundle = manager.gatherChanges("foo.Bar");
    assertSame(bundle.getValue("component", "field1"), value1);
    assertSame(bundle.getValue("component", "field2"), value2);
    verify();
}
Also used : PersistentFieldStrategy(org.apache.tapestry5.services.PersistentFieldStrategy) PersistentFieldBundle(org.apache.tapestry5.services.PersistentFieldBundle) PersistentFieldChange(org.apache.tapestry5.services.PersistentFieldChange) Test(org.testng.annotations.Test)

Aggregations

PersistentFieldBundle (org.apache.tapestry5.services.PersistentFieldBundle)3 PersistentFieldChange (org.apache.tapestry5.services.PersistentFieldChange)3 Test (org.testng.annotations.Test)3 PersistentFieldStrategy (org.apache.tapestry5.services.PersistentFieldStrategy)1