@Test public void testExecute() { Principal principal = context.mock(Principal.class); final Long personId = 293842L; final String personAccountId = "sldkfjsd"; final PersonModelView person = context.mock(PersonModelView.class); final List<PersonModelView> people = new ArrayList<PersonModelView>(); people.add(person); context.checking(new Expectations() { { oneOf(getPeopleByIdsMapper).execute(with(any(List.class))); will(returnValue(people)); oneOf(person).getAccountId(); will(returnValue(personAccountId)); } }); List<UserActionRequest> userActionRequests = sut.getUpdateCacheRequests(principal, personId); assertEquals(2, userActionRequests.size()); UserActionRequest actionRequest = userActionRequests.get(0); assertEquals("personDisplayNameUpdaterAsyncAction", actionRequest.getActionKey()); assertNull(actionRequest.getUser()); assertEquals(personId, actionRequest.getParams()); actionRequest = userActionRequests.get(1); assertEquals("activityRecipientPersonNameUpdaterAsyncAction", actionRequest.getActionKey()); assertNull(actionRequest.getUser()); assertEquals(personAccountId, actionRequest.getParams()); context.assertIsSatisfied(); }
@Override public List<UserActionRequest> getUpdateCacheRequests(final Principal inUser, final Long inPersonId) { List<UserActionRequest> results = new ArrayList<UserActionRequest>(3); results.add(new UserActionRequest(ASYNC_ACTION_NAME, null, inPersonId)); List<Long> peopleIds = new ArrayList<Long>(); peopleIds.add(inPersonId); List<PersonModelView> people = getPeopleByIdsMapper.execute(peopleIds); results.add(new UserActionRequest(ASYNC_PERSONAL_STREAM_POSTS_ACTION_NAME, null, people.get(0).getAccountId())); return results; }
UpdatePersonDisplayNameCaches implements CacheUpdater { @Override public List<UserActionRequest> getUpdateCacheRequests(final Principal inUser, final Long inPersonId) { List<UserActionRequest> results = new ArrayList<UserActionRequest>(3); results.add(new UserActionRequest(ASYNC_ACTION_NAME, null, inPersonId)); List<Long> peopleIds = new ArrayList<Long>(); peopleIds.add(inPersonId); List<PersonModelView> people = getPeopleByIdsMapper.execute(peopleIds); results.add(new UserActionRequest(ASYNC_PERSONAL_STREAM_POSTS_ACTION_NAME, null, people.get(0).getAccountId())); return results; } }
UpdatePersonDisplayNameCaches implements CacheUpdater { @Override public List<UserActionRequest> getUpdateCacheRequests(final Principal inUser, final Long inPersonId) { List<UserActionRequest> results = new ArrayList<UserActionRequest>(3); results.add(new UserActionRequest(ASYNC_ACTION_NAME, null, inPersonId)); List<Long> peopleIds = new ArrayList<Long>(); peopleIds.add(inPersonId); List<PersonModelView> people = getPeopleByIdsMapper.execute(peopleIds); results.add(new UserActionRequest(ASYNC_PERSONAL_STREAM_POSTS_ACTION_NAME, null, people.get(0).getAccountId())); return results; } UpdatePersonDisplayNameCaches(final DomainMapper<List<Long>, List<PersonModelView>> inGetPeopleByIdsMapper); }
UpdatePersonDisplayNameCaches implements CacheUpdater { @Override public List<UserActionRequest> getUpdateCacheRequests(final Principal inUser, final Long inPersonId) { List<UserActionRequest> results = new ArrayList<UserActionRequest>(3); results.add(new UserActionRequest(ASYNC_ACTION_NAME, null, inPersonId)); List<Long> peopleIds = new ArrayList<Long>(); peopleIds.add(inPersonId); List<PersonModelView> people = getPeopleByIdsMapper.execute(peopleIds); results.add(new UserActionRequest(ASYNC_PERSONAL_STREAM_POSTS_ACTION_NAME, null, people.get(0).getAccountId())); return results; } UpdatePersonDisplayNameCaches(final DomainMapper<List<Long>, List<PersonModelView>> inGetPeopleByIdsMapper); @Override List<UserActionRequest> getUpdateCacheRequests(final Principal inUser, final Long inPersonId); }
UpdatePersonDisplayNameCaches implements CacheUpdater { @Override public List<UserActionRequest> getUpdateCacheRequests(final Principal inUser, final Long inPersonId) { List<UserActionRequest> results = new ArrayList<UserActionRequest>(3); results.add(new UserActionRequest(ASYNC_ACTION_NAME, null, inPersonId)); List<Long> peopleIds = new ArrayList<Long>(); peopleIds.add(inPersonId); List<PersonModelView> people = getPeopleByIdsMapper.execute(peopleIds); results.add(new UserActionRequest(ASYNC_PERSONAL_STREAM_POSTS_ACTION_NAME, null, people.get(0).getAccountId())); return results; } UpdatePersonDisplayNameCaches(final DomainMapper<List<Long>, List<PersonModelView>> inGetPeopleByIdsMapper); @Override List<UserActionRequest> getUpdateCacheRequests(final Principal inUser, final Long inPersonId);  }