@Test public void testGetFollowersWithPersonDestinationStream() { ActivityDTO testActivity = new ActivityDTO(); testActivity.setId(1L); StreamEntityDTO testDestinationStream = new StreamEntityDTO(); testDestinationStream.setId(1L); testDestinationStream.setUniqueIdentifier("fordp"); testDestinationStream.setType(EntityType.PERSON); testActivity.setDestinationStream(testDestinationStream); PersonModelView testPersonModelView = new PersonModelView(); testPersonModelView.setEntityId(TEST_PERSON_ID); final Long fordpId = 42L; final List<Long> followerIds = new ArrayList<Long>(); followerIds.add(TEST_PERSON_ID); context.checking(new Expectations() { { oneOf(getPersonIdFromAccountIdMapper).execute("fordp"); will(returnValue(fordpId)); oneOf(personFollowersMapperMock).execute(with(any(Long.class))); will(returnValue(followerIds)); } }); List<Long> results = sut.execute(testActivity); Assert.assertEquals(1, results.size()); Assert.assertEquals(TEST_PERSON_ID, results.get(0)); context.assertIsSatisfied(); }
public List<Long> execute(final ActivityDTO activity) { StreamEntityDTO destinationStream = activity.getDestinationStream(); List<Long> followers = null; if (destinationStream.getType() == EntityType.PERSON) { long personId = getPersonIdFromAccountIdMapper.execute(destinationStream.getUniqueIdentifier()); followers = personFollowersMapper.execute(personId); } else if (destinationStream.getType() == EntityType.GROUP) { followers = new ArrayList<Long>(); } else { throw new IllegalArgumentException("This mapper does not support the destination stream type supplied."); } return followers; }
GetPersonIdsFollowingActivityDestinationStreamMapper implements DomainMapper<ActivityDTO, List<Long>> { public List<Long> execute(final ActivityDTO activity) { StreamEntityDTO destinationStream = activity.getDestinationStream(); List<Long> followers = null; if (destinationStream.getType() == EntityType.PERSON) { long personId = getPersonIdFromAccountIdMapper.execute(destinationStream.getUniqueIdentifier()); followers = personFollowersMapper.execute(personId); } else if (destinationStream.getType() == EntityType.GROUP) { followers = new ArrayList<Long>(); } else { throw new IllegalArgumentException("This mapper does not support the destination stream type supplied."); } return followers; } }
GetPersonIdsFollowingActivityDestinationStreamMapper implements DomainMapper<ActivityDTO, List<Long>> { public List<Long> execute(final ActivityDTO activity) { StreamEntityDTO destinationStream = activity.getDestinationStream(); List<Long> followers = null; if (destinationStream.getType() == EntityType.PERSON) { long personId = getPersonIdFromAccountIdMapper.execute(destinationStream.getUniqueIdentifier()); followers = personFollowersMapper.execute(personId); } else if (destinationStream.getType() == EntityType.GROUP) { followers = new ArrayList<Long>(); } else { throw new IllegalArgumentException("This mapper does not support the destination stream type supplied."); } return followers; } GetPersonIdsFollowingActivityDestinationStreamMapper(
            final DomainMapper<Long, List<Long>> inPersonFollowersMapper,
            final DomainMapper<String, Long> inGetPersonIdFromAccountIdMapper); }
GetPersonIdsFollowingActivityDestinationStreamMapper implements DomainMapper<ActivityDTO, List<Long>> { public List<Long> execute(final ActivityDTO activity) { StreamEntityDTO destinationStream = activity.getDestinationStream(); List<Long> followers = null; if (destinationStream.getType() == EntityType.PERSON) { long personId = getPersonIdFromAccountIdMapper.execute(destinationStream.getUniqueIdentifier()); followers = personFollowersMapper.execute(personId); } else if (destinationStream.getType() == EntityType.GROUP) { followers = new ArrayList<Long>(); } else { throw new IllegalArgumentException("This mapper does not support the destination stream type supplied."); } return followers; } GetPersonIdsFollowingActivityDestinationStreamMapper(
            final DomainMapper<Long, List<Long>> inPersonFollowersMapper,
            final DomainMapper<String, Long> inGetPersonIdFromAccountIdMapper); List<Long> execute(final ActivityDTO activity); }
GetPersonIdsFollowingActivityDestinationStreamMapper implements DomainMapper<ActivityDTO, List<Long>> { public List<Long> execute(final ActivityDTO activity) { StreamEntityDTO destinationStream = activity.getDestinationStream(); List<Long> followers = null; if (destinationStream.getType() == EntityType.PERSON) { long personId = getPersonIdFromAccountIdMapper.execute(destinationStream.getUniqueIdentifier()); followers = personFollowersMapper.execute(personId); } else if (destinationStream.getType() == EntityType.GROUP) { followers = new ArrayList<Long>(); } else { throw new IllegalArgumentException("This mapper does not support the destination stream type supplied."); } return followers; } GetPersonIdsFollowingActivityDestinationStreamMapper(
            final DomainMapper<Long, List<Long>> inPersonFollowersMapper,
            final DomainMapper<String, Long> inGetPersonIdFromAccountIdMapper); List<Long> execute(final ActivityDTO activity);  }