@Test
public void doAddWidget() {
final String widgetUrl = "http://example.com/newwidget.xml";
final Model model = new ExtendedModelMap();
final WidgetImpl widget = new WidgetImpl();
widget.setId(1L);
widget.setTitle("Widget title");
widget.setUrl(widgetUrl);
widget.setType("OpenSocial");
widget.setDescription("Lorem ipsum");
final BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
expect(widgetService.registerNewWidget(widget)).andReturn(widget);
expect(widgetService.isRegisteredUrl(widgetUrl)).andReturn(false);
replay(widgetService);
String view = controller.viewAddWidgetResult(widget, errors, model,REFERRER_ID);
verify(widgetService);
assertEquals("redirect:/app/store/widget/" + widget.getId() + "?referringPageId=" + REFERRER_ID, view);
assertFalse("Valid widget data", errors.hasErrors());
}