@Test(dataProvider = "renderings")
public void test_Render(String outcome, Boolean local)
{
IAutocompleteModel model = createModel();
ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
DataSqueezer ds = newMock(DataSqueezer.class);
ResponseBuilder resp = newMock(ResponseBuilder.class);
IRequestCycle cycle = newMock(IRequestCycle.class);
IForm form = newMock(IForm.class);
checkOrder(form, false);
MockDelegate delegate = new MockDelegate();
IEngineService engine = newEngineService();
ILink link = newLink();
IScript script = newMock(IScript.class);
SimpleBean match = new SimpleBean(new Integer(2), "Simple 2", 200);
Autocompleter component = newInstance(Autocompleter.class,
new Object[] {
"name", "fred", "model", model,
"directService", engine,
"script", script,
"validatableFieldSupport", vfs,
"value", match,
"dataSqueezer", ds, "local", local
});
expect(cycle.renderStackPush(component)).andReturn(component);
expect(form.getName()).andReturn("testform").anyTimes();
form.setFormFieldUpdating(true);
IMarkupWriter writer = newBufferWriter();
DirectServiceParameter dsp =
new DirectServiceParameter(component);
trainGetForm(cycle, form);
trainWasPrerendered(form, writer, component, false);
trainGetDelegate(form, delegate);
delegate.setFormComponent(component);
trainGetElementId(form, component, "fred");
trainIsRewinding(form, false);
expect(cycle.isRewinding()).andReturn(false).anyTimes();
delegate.setFormComponent(component);
expect(cycle.getResponseBuilder()).andReturn(resp).anyTimes();
expect(resp.isDynamic()).andReturn(false).anyTimes();
vfs.renderContributions(component, writer, cycle);
if (!local.booleanValue())
{
trainGetLinkCheckIgnoreParameter(engine, cycle, true, dsp, link);
trainGetURL(link, "urlstring");
}
else
{
expect(ds.squeeze(1)).andReturn("1p");
expect(ds.squeeze(2)).andReturn("2p");
expect(ds.squeeze(3)).andReturn("3p");
}
// for the default value
expect(ds.squeeze(2)).andReturn("2p");
PageRenderSupport prs = newPageRenderSupport();
trainGetPageRenderSupport(cycle, prs);
script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));