final String widgetUrl = "http://example.com/widget";
Widget widget = new Widget(123L, widgetUrl);
widget.setTitle("Widget title");
widget.setType("OpenSocial");
widget.setDescription("Lorem ipsum");
BindingResult errors = new BeanPropertyBindingResult(widget, "widget");
SessionStatus sessionStatus = createMock(SessionStatus.class);
ModelMap modelMap = new ExtendedModelMap();
expect(service.getWidgetByUrl(widgetUrl)).andReturn(widget);
service.updateWidget(widget);
sessionStatus.setComplete();
expectLastCall();
replay(service, sessionStatus);
String view = controller.updateWidgetDetail(widget, errors, validToken, validToken, modelMap, sessionStatus);
verify(service, sessionStatus);
assertFalse("No errors", errors.hasErrors());
assertEquals("redirect:/app/admin/widgets?action=update", view);
}