* Test execute when the SharedResource is NOT found.
*/
@Test
public void testExecuteWhenNotFound()
{
final SharedResourceDTO dto = new SharedResourceDTO();
dto.setLikerPersonIds(new ArrayList<Long>());
dto.setSharerPersonIds(new ArrayList<Long>());
dto.getLikerPersonIds().add(1L);
dto.getLikerPersonIds().add(2L);
dto.getLikerPersonIds().add(3L);
dto.getLikerPersonIds().add(4L);
dto.getLikerPersonIds().add(5L);
dto.getLikerPersonIds().add(8L);
dto.getSharerPersonIds().add(1L);
dto.getSharerPersonIds().add(3L);
dto.getSharerPersonIds().add(5L);
dto.getSharerPersonIds().add(6L);
final List<PersonModelView> people = new ArrayList<PersonModelView>();
PersonModelView mv1 = new PersonModelView();
mv1.setEntityId(1L);
people.add(mv1);
PersonModelView mv2 = new PersonModelView();
mv2.setEntityId(2L);
people.add(mv2);
PersonModelView mv3 = new PersonModelView();
mv3.setEntityId(3L);
people.add(mv3);
PersonModelView mv4 = new PersonModelView();
mv4.setEntityId(4L);
people.add(mv4);
PersonModelView mv5 = new PersonModelView();
mv5.setEntityId(5L);
people.add(mv5);
PersonModelView mv6 = new PersonModelView();
mv6.setEntityId(6L);
people.add(mv6);
final List<Long> peopleIds = new ArrayList<Long>();
peopleIds.add(1L);
peopleIds.add(3L);
peopleIds.add(5L);
peopleIds.add(6L);
peopleIds.add(2L);
peopleIds.add(4L);
getPeopleModelViewsByIdsMapper.setResponse(people);
context.checking(new Expectations()
{
{
oneOf(mapper).execute(request);
will(returnValue(dto));
}
});
sut.execute(actionContext);
// make sure the right people ids were passed into the getpeoplebyids
Assert.assertEquals(6, getPeopleModelViewsByIdsMapper.getRequest().size());
Assert.assertTrue(getPeopleModelViewsByIdsMapper.getRequest().contains(1L));
Assert.assertTrue(getPeopleModelViewsByIdsMapper.getRequest().contains(2L));
Assert.assertTrue(getPeopleModelViewsByIdsMapper.getRequest().contains(5L));
Assert.assertTrue(getPeopleModelViewsByIdsMapper.getRequest().contains(6L));
Assert.assertTrue(getPeopleModelViewsByIdsMapper.getRequest().contains(2L));
Assert.assertTrue(getPeopleModelViewsByIdsMapper.getRequest().contains(4L));
Assert.assertEquals(6, dto.getLikerPersonIds().size());
Assert.assertEquals(4, dto.getSharerPersonIds().size());
Assert.assertEquals(4, dto.getLikersSample().size());
Assert.assertEquals(4, dto.getSharersSample().size());
Assert.assertTrue(dto.getLikersSample().contains(mv1));
Assert.assertTrue(dto.getLikersSample().contains(mv2));
Assert.assertTrue(dto.getLikersSample().contains(mv3));
Assert.assertTrue(dto.getLikersSample().contains(mv4));
Assert.assertTrue(dto.getSharersSample().contains(mv1));
Assert.assertTrue(dto.getSharersSample().contains(mv3));
Assert.assertTrue(dto.getSharersSample().contains(mv5));
Assert.assertTrue(dto.getSharersSample().contains(mv6));
Assert.assertTrue(dto.isLiked());
context.assertIsSatisfied();
}