final Model model = new ExtendedModelMap();
final Widget widget = new Widget();
widget.setTitle("Widget title");
widget.setUrl(widgetUrl);
widget.setType("OpenSocial");
final BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
expect(widgetService.registerNewWidget(widget)).andReturn(widget);
replay(widgetService);
String view = controller.viewAddWidgetResult(widget, errors, model);
verify(widgetService);
assertEquals(ViewNames.WIDGET, view);
assertFalse("Valid widget data", errors.hasErrors());
final Widget fromModel = (Widget) model.asMap().get(ModelKeys.WIDGET);
assertEquals(widget, fromModel);
assertEquals("New widget has state preview", WidgetStatus.PREVIEW, fromModel.getWidgetStatus());
}