@Test
public void testExecuteWhenSharedExists()
{
final String uniqueKey = "http://foo.com";
final StreamScope sharedResourceStreamScope = context.mock(StreamScope.class);
final SharedResourceRequest request = new SharedResourceRequest(uniqueKey, null);
final List<Long> sharerIds = new ArrayList<Long>();
final List<Long> likerIds = new ArrayList<Long>();
final List<PersonModelView> people = new ArrayList<PersonModelView>();
final Long streamScopeId = 282834L;
final Long sharedResourceId = 83348L;
people.add(buildPersonModelView(1L));
people.add(buildPersonModelView(2L));
people.add(buildPersonModelView(3L));
people.add(buildPersonModelView(4L));
people.add(buildPersonModelView(5L));
people.add(buildPersonModelView(6L));
people.add(buildPersonModelView(7L));
// 6 share
sharerIds.add(1L); // will be included
sharerIds.add(2L); // will be included
sharerIds.add(3L); // will be included
sharerIds.add(4L); // will be included
sharerIds.add(5L);
sharerIds.add(6L);
// 5 likes
likerIds.add(4L); // will be included
likerIds.add(5L); // will be included
likerIds.add(6L); // will be included
likerIds.add(7L); // will be included
likerIds.add(8L);
context.checking(new Expectations()
{
{
oneOf(sharedResourceStreamScope).getId();
will(returnValue(streamScopeId));
oneOf(sharedResourceStreamScope).getDestinationEntityId();
will(returnValue(sharedResourceId));
oneOf(getResourceStreamScopeByKeyMapper).execute(with(uniqueKey));
will(returnValue(sharedResourceStreamScope));
oneOf(getPeopleThatSharedResourceMapper).execute(with(request));
will(returnValue(sharerIds));
oneOf(getPeopleThatLikedResourceMapper).execute(with(request));
will(returnValue(likerIds));
}
});
// execute sut
SharedResourceDTO result = sut.execute(request);
// make sure the request was updated with the shared resource id
assertEquals(sharedResourceId, request.getSharedResourceId());
// make sure the top-level properties look right
assertEquals(streamScopeId, result.getStreamScopeId());
assertEquals(5, result.getLikeCount());
assertEquals(6, result.getShareCount());