}
@Test
public void registerNewWidget() {
final String widgetUrl = "http://example.com/newwidget.xml";
Widget widget = new Widget();
widget.setUrl(widgetUrl);
expect(widgetRepository.getByUrl(widgetUrl)).andReturn(null);
expect(widgetRepository.save(widget)).andReturn(widget);
replay(widgetRepository);
Widget savedWidget = widgetService.registerNewWidget(widget);
assertNotNull(savedWidget);
assertEquals(widget.getEntityId(), savedWidget.getEntityId());
verify(widgetRepository);
}