@Test(expected = ExecutionException.class) public void performActionWithException() throws Exception { context.checking(new Expectations() { { oneOf(feedFetcherFactory).getSyndicatedFeed(with(equal(FEED_URL)), (List<String>) with(org.hamcrest.Matchers.hasItem(USER))); will(throwException(new Exception())); } }); sut.execute(ac); context.assertIsSatisfied(); }
@Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String feedUrlText = (String) inActionContext.getParams(); try { new URL(feedUrlText); } catch (MalformedURLException e) { logger.error("Error fetching feed"); throw new ExecutionException(e); } SyndFeed syndFeed; try { Map<String, SyndFeed> synFeeds = feedFetcherFactory.getSyndicatedFeed(feedUrlText, Collections.singletonList(inActionContext .getPrincipal().getAccountId())); syndFeed = synFeeds.values().iterator().next(); } catch (Exception e) { throw new ExecutionException(e); } for (Object entryObject : syndFeed.getEntries()) { SyndEntry entry = (SyndEntry) entryObject; if (entry.getUri() == null || entry.getUri().trim().isEmpty()) { throw new ValidationException("Invalid feed. Every feed entry must contain a URI."); } } return syndFeed.getTitle(); }
GetTitleFromFeedExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String feedUrlText = (String) inActionContext.getParams(); try { new URL(feedUrlText); } catch (MalformedURLException e) { logger.error("Error fetching feed"); throw new ExecutionException(e); } SyndFeed syndFeed; try { Map<String, SyndFeed> synFeeds = feedFetcherFactory.getSyndicatedFeed(feedUrlText, Collections.singletonList(inActionContext .getPrincipal().getAccountId())); syndFeed = synFeeds.values().iterator().next(); } catch (Exception e) { throw new ExecutionException(e); } for (Object entryObject : syndFeed.getEntries()) { SyndEntry entry = (SyndEntry) entryObject; if (entry.getUri() == null || entry.getUri().trim().isEmpty()) { throw new ValidationException("Invalid feed. Every feed entry must contain a URI."); } } return syndFeed.getTitle(); } }
GetTitleFromFeedExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String feedUrlText = (String) inActionContext.getParams(); try { new URL(feedUrlText); } catch (MalformedURLException e) { logger.error("Error fetching feed"); throw new ExecutionException(e); } SyndFeed syndFeed; try { Map<String, SyndFeed> synFeeds = feedFetcherFactory.getSyndicatedFeed(feedUrlText, Collections.singletonList(inActionContext .getPrincipal().getAccountId())); syndFeed = synFeeds.values().iterator().next(); } catch (Exception e) { throw new ExecutionException(e); } for (Object entryObject : syndFeed.getEntries()) { SyndEntry entry = (SyndEntry) entryObject; if (entry.getUri() == null || entry.getUri().trim().isEmpty()) { throw new ValidationException("Invalid feed. Every feed entry must contain a URI."); } } return syndFeed.getTitle(); } GetTitleFromFeedExecution(final FeedFactory inFeedFetcherFactory); }
GetTitleFromFeedExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String feedUrlText = (String) inActionContext.getParams(); try { new URL(feedUrlText); } catch (MalformedURLException e) { logger.error("Error fetching feed"); throw new ExecutionException(e); } SyndFeed syndFeed; try { Map<String, SyndFeed> synFeeds = feedFetcherFactory.getSyndicatedFeed(feedUrlText, Collections.singletonList(inActionContext .getPrincipal().getAccountId())); syndFeed = synFeeds.values().iterator().next(); } catch (Exception e) { throw new ExecutionException(e); } for (Object entryObject : syndFeed.getEntries()) { SyndEntry entry = (SyndEntry) entryObject; if (entry.getUri() == null || entry.getUri().trim().isEmpty()) { throw new ValidationException("Invalid feed. Every feed entry must contain a URI."); } } return syndFeed.getTitle(); } GetTitleFromFeedExecution(final FeedFactory inFeedFetcherFactory); @Override Serializable execute(final PrincipalActionContext inActionContext); }
GetTitleFromFeedExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String feedUrlText = (String) inActionContext.getParams(); try { new URL(feedUrlText); } catch (MalformedURLException e) { logger.error("Error fetching feed"); throw new ExecutionException(e); } SyndFeed syndFeed; try { Map<String, SyndFeed> synFeeds = feedFetcherFactory.getSyndicatedFeed(feedUrlText, Collections.singletonList(inActionContext .getPrincipal().getAccountId())); syndFeed = synFeeds.values().iterator().next(); } catch (Exception e) { throw new ExecutionException(e); } for (Object entryObject : syndFeed.getEntries()) { SyndEntry entry = (SyndEntry) entryObject; if (entry.getUri() == null || entry.getUri().trim().isEmpty()) { throw new ValidationException("Invalid feed. Every feed entry must contain a URI."); } } return syndFeed.getTitle(); } GetTitleFromFeedExecution(final FeedFactory inFeedFetcherFactory); @Override Serializable execute(final PrincipalActionContext inActionContext);  }