use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class ComponentTemplateSourceImplTest method child_component_inherits_parent_template.
@Test
public void child_component_inherits_parent_template() {
TemplateParser parser = mockTemplateParser();
ComponentTemplate template = mockComponentTemplate();
ComponentModel model = mockComponentModel();
ComponentModel parentModel = mockComponentModel();
Resource resource = mockResource();
ComponentResourceLocator locator = mockLocator(model, english, null);
train_getComponentClassName(model, "foo.Bar");
train_getParentModel(model, parentModel);
expect(locator.locateTemplate(parentModel, english)).andReturn(resource).once();
expect(resource.exists()).andReturn(true);
expect(resource.toURL()).andReturn(null);
train_parseTemplate(parser, resource, template);
replay();
ComponentTemplateSource source = new ComponentTemplateSourceImpl(true, parser, locator, converter, componentRequestSelectorAnalyzer, threadLocale);
assertSame(source.getTemplate(model, english), template);
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class MetaDataLocatorImplTest method not_found_by_page_name_but_found_in_configuration.
@Test
public void not_found_by_page_name_but_found_in_configuration() {
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
String pageName = "gnip/Gnop";
expect(modelSource.getPageModel(pageName)).andReturn(model);
train_getMeta(model, key, null);
train_expandSymbols(symbolSource, value, "*expanded*");
replay();
Map<String, String> configuration = CollectionFactory.newMap();
configuration.put("gnip:foo.bar", value);
MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, pageName, String.class), "*expanded*");
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class MetaDataLocatorImplTest method find_by_page_name.
@Test
public void find_by_page_name() {
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
String pageName = "foo/Bar";
expect(modelSource.getPageModel(pageName)).andReturn(model);
train_getMeta(model, key, value);
train_expandSymbols(symbolSource, value, "*expanded*");
replay();
Map<String, String> configuration = Collections.emptyMap();
MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, pageName, String.class), "*expanded*");
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class MetaDataLocatorImplTest method default_to_symbol_source.
@Test
public void default_to_symbol_source() {
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
String completeId = "foo/Bar:baz";
train_getCompleteId(resources, completeId);
train_getComponentModel(resources, model);
train_getMeta(model, key, null);
train_getContainerResources(resources, null);
train_getPageName(resources, "foo/Bar");
train_valueForSymbol(symbolSource, key, value);
replay();
Map<String, String> configuration = Collections.emptyMap();
MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, resources, String.class), value);
verify();
// And check that it's cached:
train_getCompleteId(resources, completeId);
replay();
assertSame(locator.findMeta(key, resources, String.class), value);
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class ComponentAssemblerImpl method addRootComponentMixins.
private void addRootComponentMixins(PageAssembly assembly, ComponentPageElement element) {
for (String className : instantiator.getModel().getMixinClassNames()) {
assembly.weight++;
Instantiator mixinInstantiator = instantiatorSource.getInstantiator(className);
ComponentModel model = instantiator.getModel();
element.addMixin(InternalUtils.lastTerm(className), mixinInstantiator, model.getOrderForMixin(className));
}
}
Aggregations