use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class MutableComponentModelImplTest method get_mixin_class_names_with_no_mixins.
@Test
public void get_mixin_class_names_with_no_mixins() {
Resource r = mockResource();
Logger logger = mockLogger();
replay();
ComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
assertTrue(model.getMixinClassNames().isEmpty());
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class AssetInjectionProvider method provideInjection.
public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) {
Path path = field.getAnnotation(Path.class);
if (path == null) {
return false;
}
final String assetPath = path.value();
final String libraryName = componentModel.getLibraryName();
ComputedValue<Asset> computedAsset = new ComputedValue<Asset>() {
public Asset get(InstanceContext context) {
ComponentResources resources = context.get(ComponentResources.class);
// a different library name than the subclass).
return assetSource.getComponentAsset(resources, assetPath, libraryName);
}
};
field.injectComputed(computedAsset);
return true;
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class PersistentFieldManagerImplTest method post_change_strategy_by_meta_data.
@Test
public void post_change_strategy_by_meta_data() {
String pageName = "foo.Bar";
String nestedId = "nested";
String fieldName = "field";
String strategyName = "foo";
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
PersistentFieldStrategy strat = newPersistentFieldStrategy();
MetaDataLocator locator = mockMetaDataLocator();
Object value = new Object();
Map<String, PersistentFieldStrategy> strategies = newMap();
strategies.put(strategyName, strat);
train_getComponentModel(resources, model);
train_getFieldPersistenceStrategy(model, fieldName, "");
train_findMeta(locator, SymbolConstants.PERSISTENCE_STRATEGY, resources, String.class, strategyName);
train_getNestedId(resources, nestedId);
strat.postChange(pageName, nestedId, fieldName, value);
replay();
PersistentFieldManager manager = new PersistentFieldManagerImpl(locator, strategies);
manager.postChange(pageName, resources, fieldName, value);
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class PersistentFieldManagerImplTest method post_change_with_ultimate_default_strategy.
@Test
public void post_change_with_ultimate_default_strategy() {
String pageName = "foo.Bar";
String nestedId = "nested";
String fieldName = "field";
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
MetaDataLocator locator = mockMetaDataLocator();
PersistentFieldStrategy strat = newPersistentFieldStrategy();
Object value = new Object();
Map<String, PersistentFieldStrategy> strategies = newMap();
strategies.put(PersistenceConstants.SESSION, strat);
train_getComponentModel(resources, model);
train_getFieldPersistenceStrategy(model, fieldName, "");
train_findMeta(locator, SymbolConstants.PERSISTENCE_STRATEGY, resources, String.class, PersistenceConstants.SESSION);
train_getNestedId(resources, nestedId);
strat.postChange(pageName, nestedId, fieldName, value);
replay();
PersistentFieldManager manager = new PersistentFieldManagerImpl(locator, strategies);
manager.postChange(pageName, resources, fieldName, value);
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class PersistentFieldManagerImplTest method post_change.
@Test
public void post_change() {
String pageName = "foo.Bar";
String nestedId = "nested";
String fieldName = "field";
String strategyName = "foo";
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
PersistentFieldStrategy strat = newPersistentFieldStrategy();
Object value = new Object();
Map<String, PersistentFieldStrategy> strategies = newMap();
strategies.put(strategyName, strat);
train_getComponentModel(resources, model);
train_getFieldPersistenceStrategy(model, fieldName, strategyName);
train_getNestedId(resources, nestedId);
strat.postChange(pageName, nestedId, fieldName, value);
replay();
PersistentFieldManager manager = new PersistentFieldManagerImpl(null, strategies);
manager.postChange(pageName, resources, fieldName, value);
verify();
}
Aggregations