### Question:
WookieWidgetMetadataResolver implements WidgetMetadataResolver { public Widget getMetadata(String url) { try { return widgetMetadataRepository.getWidgetMetadata(url); } catch (Exception e) { throw new IllegalArgumentException("Error occurred while processing response for Widget metadata call", e); } } @Autowired  WookieWidgetMetadataResolver(@Qualifier("wookieWidgetService") WidgetProviderService widgetService); String getSupportedContext(); Widget getMetadata(String url); @Override Widget[] getMetadataGroup(String url); @Override Widget publishRemote(String url);  }### Answer:
@Test public void getMetadata() throws IOException, WookieConnectorException { expect(wookieWidgetMetadataRepository.getWidgetMetadata(VALID_IDENTIFIER)).andReturn(TEST_WIDGET); replay(wookieWidgetMetadataRepository); expect(widgetService.getWidget(VALID_IDENTIFIER)).andReturn(TEST_WIDGET); replay(widgetService); Widget w = widgetMetadataResolver.getMetadata(VALID_IDENTIFIER); assertNotNull(w); assertEquals("freeder", w.getTitle()); assertEquals("http: assertEquals("An RSS reader widget optimised for small screens or desktop widgets.", w.getDescription()); assertEquals("http: assertEquals(TYPE, w.getType()); }
@Test public void getMetadata_noWidgetFound() throws WookieConnectorException { expect(wookieWidgetMetadataRepository.getWidgetMetadata(VALID_IDENTIFIER)).andReturn(null); replay(wookieWidgetMetadataRepository); expect(widgetService.getWidget(VALID_IDENTIFIER)).andReturn(null); replay(widgetService); Widget w = widgetMetadataResolver.getMetadata(VALID_IDENTIFIER); assertNull(w); }