@Test public void performAction() throws Exception { final PluginDefinition plugin = context.mock(PluginDefinition.class); final Feed feed = context.mock(Feed.class); final Feed feed2 = context.mock(Feed.class, "f2"); final FeedSubscriber feedSub = context.mock(FeedSubscriber.class); final FeedSubscriber feedSub2 = context.mock(FeedSubscriber.class, "fs2"); final List<FeedSubscriber> feedSubs = new ArrayList<FeedSubscriber>(); feedSubs.add(feedSub); feedSubs.add(feedSub2); context.checking(new Expectations() { { allowing(ac).getPrincipal(); will(returnValue(principal)); allowing(ac).getParams(); will(returnValue("username1")); allowing(principal).getAccountId(); will(returnValue("user")); allowing(principal).getId(); will(returnValue(9L)); oneOf(getEntityId).getEntityId(with(any(HashMap.class))); oneOf(getAllPluginsMapper).execute(with(any(EmptyRequest.class))); oneOf(getFeedSubsMapper).execute(with(any(GetFeedSubscriberRequest.class))); will(returnValue(feedSubs)); allowing(feedSub).getFeed(); will(returnValue(feed)); allowing(feedSub2).getFeed(); will(returnValue(feed2)); allowing(plugin).getId(); oneOf(feed).getPlugin(); will(returnValue(plugin)); allowing(feed).getLastUpdated(); will(returnValue(0L)); oneOf(feed).setTimeAgo(with(any(String.class))); oneOf(feed2).getPlugin(); will(returnValue(plugin)); allowing(feed2).getLastUpdated(); will(returnValue(null)); oneOf(feed2).setTimeAgo(null); } }); PluginAndFeedSubscriptionsResponse response = (PluginAndFeedSubscriptionsResponse) sut.execute(ac); assertEquals(feedSubs, response.getFeedSubcribers()); context.assertIsSatisfied(); }
public PluginAndFeedSubscriptionsResponse execute(final PrincipalActionContext context) throws ExecutionException { HashMap<String, Serializable> values = new HashMap<String, Serializable>(); Principal principal = context.getPrincipal(); values.put("EUREKA:USER", principal.getAccountId()); values.put("EUREKA:GROUP", (String) context.getParams()); List<PluginDefinition> plugins = getAllPluginsMapper.execute(new EmptyRequest()); List<FeedSubscriber> feedSubs = getFeedSubsMapper.execute(new GetFeedSubscriberRequest(0L, getEntityId.getEntityId(values), type, principal.getId())); for (FeedSubscriber feedSub : feedSubs) { feedSub.getFeed().getPlugin().getId(); if (feedSub.getFeed().getLastUpdated() == null) { feedSub.getFeed().setTimeAgo(null); } else { DateFormatter dateFormatter = new DateFormatter(new Date()); feedSub.getFeed().setTimeAgo( dateFormatter.timeAgo(new Date(feedSub.getFeed().getLastUpdated() * MSINMIN))); } } return new PluginAndFeedSubscriptionsResponse(plugins, feedSubs); }
GetPluginsAndSubscriptionsForTabExecution implements ExecutionStrategy<PrincipalActionContext> { public PluginAndFeedSubscriptionsResponse execute(final PrincipalActionContext context) throws ExecutionException { HashMap<String, Serializable> values = new HashMap<String, Serializable>(); Principal principal = context.getPrincipal(); values.put("EUREKA:USER", principal.getAccountId()); values.put("EUREKA:GROUP", (String) context.getParams()); List<PluginDefinition> plugins = getAllPluginsMapper.execute(new EmptyRequest()); List<FeedSubscriber> feedSubs = getFeedSubsMapper.execute(new GetFeedSubscriberRequest(0L, getEntityId.getEntityId(values), type, principal.getId())); for (FeedSubscriber feedSub : feedSubs) { feedSub.getFeed().getPlugin().getId(); if (feedSub.getFeed().getLastUpdated() == null) { feedSub.getFeed().setTimeAgo(null); } else { DateFormatter dateFormatter = new DateFormatter(new Date()); feedSub.getFeed().setTimeAgo( dateFormatter.timeAgo(new Date(feedSub.getFeed().getLastUpdated() * MSINMIN))); } } return new PluginAndFeedSubscriptionsResponse(plugins, feedSubs); } }
GetPluginsAndSubscriptionsForTabExecution implements ExecutionStrategy<PrincipalActionContext> { public PluginAndFeedSubscriptionsResponse execute(final PrincipalActionContext context) throws ExecutionException { HashMap<String, Serializable> values = new HashMap<String, Serializable>(); Principal principal = context.getPrincipal(); values.put("EUREKA:USER", principal.getAccountId()); values.put("EUREKA:GROUP", (String) context.getParams()); List<PluginDefinition> plugins = getAllPluginsMapper.execute(new EmptyRequest()); List<FeedSubscriber> feedSubs = getFeedSubsMapper.execute(new GetFeedSubscriberRequest(0L, getEntityId.getEntityId(values), type, principal.getId())); for (FeedSubscriber feedSub : feedSubs) { feedSub.getFeed().getPlugin().getId(); if (feedSub.getFeed().getLastUpdated() == null) { feedSub.getFeed().setTimeAgo(null); } else { DateFormatter dateFormatter = new DateFormatter(new Date()); feedSub.getFeed().setTimeAgo( dateFormatter.timeAgo(new Date(feedSub.getFeed().getLastUpdated() * MSINMIN))); } } return new PluginAndFeedSubscriptionsResponse(plugins, feedSubs); } GetPluginsAndSubscriptionsForTabExecution(final GetAllPluginsMapper inGetAllPluginsMapper,
            final GetFeedSubscriptionsByEntity inGetFeedSubsMapper,
            final GetEntityIdForFeedSubscription inGetEntityId, final EntityType inType); }
GetPluginsAndSubscriptionsForTabExecution implements ExecutionStrategy<PrincipalActionContext> { public PluginAndFeedSubscriptionsResponse execute(final PrincipalActionContext context) throws ExecutionException { HashMap<String, Serializable> values = new HashMap<String, Serializable>(); Principal principal = context.getPrincipal(); values.put("EUREKA:USER", principal.getAccountId()); values.put("EUREKA:GROUP", (String) context.getParams()); List<PluginDefinition> plugins = getAllPluginsMapper.execute(new EmptyRequest()); List<FeedSubscriber> feedSubs = getFeedSubsMapper.execute(new GetFeedSubscriberRequest(0L, getEntityId.getEntityId(values), type, principal.getId())); for (FeedSubscriber feedSub : feedSubs) { feedSub.getFeed().getPlugin().getId(); if (feedSub.getFeed().getLastUpdated() == null) { feedSub.getFeed().setTimeAgo(null); } else { DateFormatter dateFormatter = new DateFormatter(new Date()); feedSub.getFeed().setTimeAgo( dateFormatter.timeAgo(new Date(feedSub.getFeed().getLastUpdated() * MSINMIN))); } } return new PluginAndFeedSubscriptionsResponse(plugins, feedSubs); } GetPluginsAndSubscriptionsForTabExecution(final GetAllPluginsMapper inGetAllPluginsMapper,
            final GetFeedSubscriptionsByEntity inGetFeedSubsMapper,
            final GetEntityIdForFeedSubscription inGetEntityId, final EntityType inType); PluginAndFeedSubscriptionsResponse execute(final PrincipalActionContext context); }
GetPluginsAndSubscriptionsForTabExecution implements ExecutionStrategy<PrincipalActionContext> { public PluginAndFeedSubscriptionsResponse execute(final PrincipalActionContext context) throws ExecutionException { HashMap<String, Serializable> values = new HashMap<String, Serializable>(); Principal principal = context.getPrincipal(); values.put("EUREKA:USER", principal.getAccountId()); values.put("EUREKA:GROUP", (String) context.getParams()); List<PluginDefinition> plugins = getAllPluginsMapper.execute(new EmptyRequest()); List<FeedSubscriber> feedSubs = getFeedSubsMapper.execute(new GetFeedSubscriberRequest(0L, getEntityId.getEntityId(values), type, principal.getId())); for (FeedSubscriber feedSub : feedSubs) { feedSub.getFeed().getPlugin().getId(); if (feedSub.getFeed().getLastUpdated() == null) { feedSub.getFeed().setTimeAgo(null); } else { DateFormatter dateFormatter = new DateFormatter(new Date()); feedSub.getFeed().setTimeAgo( dateFormatter.timeAgo(new Date(feedSub.getFeed().getLastUpdated() * MSINMIN))); } } return new PluginAndFeedSubscriptionsResponse(plugins, feedSubs); } GetPluginsAndSubscriptionsForTabExecution(final GetAllPluginsMapper inGetAllPluginsMapper,
            final GetFeedSubscriptionsByEntity inGetFeedSubsMapper,
            final GetEntityIdForFeedSubscription inGetEntityId, final EntityType inType); PluginAndFeedSubscriptionsResponse execute(final PrincipalActionContext context);  }