int offset = 0;
int pageSize = 10;
String categoryText = "Social";
Widget w = new Widget();
List<Category> categories = new ArrayList<Category>();
Category c = new Category();
List<Widget> widgets = new ArrayList<Widget>();
widgets.add(w);
c.setWidgets(widgets);
c.setEntityId(id);
c.setText(categoryText);
categories.add(c);
w.setCategories(categories);
expect(categoryRepository.get(id)).andReturn(c);
replay(categoryRepository);
SearchResult<Widget> result = widgetService.getWidgetsByCategory(id,offset,pageSize);
verify(categoryRepository);
assertEquals("number of widgets", 1, result.getTotalResults());
assertSame(w, result.getResultSet().get(0));
assertEquals(c.getEntityId(), result.getResultSet().get(0).getCategories().get(0).getEntityId());
}