### Question:
DefaultWidgetsResource implements WidgetsResource { @Override public Widget getWidget(String id) { org.apache.rave.model.Widget widget = getFromService(id); return new Widget(widget); }  @Override SearchResult<Widget> getWidgets(); @Override Widget getWidget(String id); @Override Widget updateWidget(String id, Widget widget); @Override Widget createWidget(Widget widget); @Inject void setWidgetService(WidgetService widgetService);  }### Answer:
@Test public void getById_exists() { expect(service.getWidget(w1.getId())).andReturn(w1); replay(service); org.apache.rave.rest.model.Widget widget = resource.getWidget(w1.getId()); validate(widget, w1); }
@Test(expected = ResourceNotFoundException.class) public void getById_notExists() { expect(service.getWidget(w1.getId())).andReturn(null); replay(service); org.apache.rave.rest.model.Widget widget = resource.getWidget(w1.getId()); }