public void testRefreshFeedMessagesIncludesFeedEntryDetails() throws Exception {
final List<FeedEntryDetails> feedEntryDetailList = Lists.newArrayList();
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
FeedEntryDetails feedEntryDetails = (FeedEntryDetails) invocation.getArguments()[3];
feedEntryDetailList.add(feedEntryDetails);
return null;
}
}).when(mockMessageService).sendActivityMessage(any(Event.class),
any(Connection.class),
anyLong(),
any(SobaMessageDetails.class));
inventoryService.eventService = mock(EventService.class);
ReflectionTestUtils.setField(inventoryService, "messageService", mockMessageService);
inventoryService.pullInventoryItemActivity(sampleFeedConnection);
assertEquals(2, feedEntryDetailList.size());
FeedEntryDetails degradedPerformanceDetails = feedEntryDetailList.get(0);
assertEquals("Informational message: Investigating degraded performance of EBS volumes", degradedPerformanceDetails.getTitle());
assertEquals("http://status.aws.amazon.com/#EC2_1330560778", degradedPerformanceDetails.getUrl());
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
assertEquals(sdf.parse("Wed, 29 Feb 2012 16:12:58 PST"), degradedPerformanceDetails.getPublishedDate());
assertTrue(degradedPerformanceDetails.getDescription().startsWith("We are investigating"));
}