@Test public void testExecutePartil() { final List<Long> list = Arrays.asList(0L, 0L, 0L, 0L, 0L, 8L, 7L, 6L); final List<FollowerStatusable> resultList = new ArrayList<FollowerStatusable>(); final AnonymousClassInterceptor<List<Long>> parmCatch = new AnonymousClassInterceptor<List<Long>>(resultList); context.checking(new Expectations() { { allowing(idsMapper).execute(USER_ID); will(returnValue(list)); allowing(bulkModelViewMapper).execute(with(any(List.class))); will(parmCatch); oneOf(followerStatusPopulator).execute(with(CURRENT_USER_ID), with(resultList), with(FollowerStatus.NOTSPECIFIED)); } }); PagedSet<FollowerStatusable> results = sut.execute(actionContext); context.assertIsSatisfied(); assertEquals(START_INDEX, results.getFromIndex()); assertEquals(START_INDEX + 2, results.getToIndex()); assertEquals(8, results.getTotal()); List<Long> idList = parmCatch.getObject(); assertEquals(3, idList.size()); assertEquals((Long) 8L, idList.get(0)); assertEquals((Long) 7L, idList.get(1)); assertEquals((Long) 6L, idList.get(2)); }
@Override public PagedSet<FollowerStatusable> execute(final PrincipalActionContext inActionContext) { GetFollowersFollowingRequest inRequest = (GetFollowersFollowingRequest) inActionContext.getParams(); final String entityUniqueId = inRequest.getEntityId(); final long currentUserId = inActionContext.getPrincipal().getId(); Long entityId = getPersonIdByAccountIdMapper.execute(entityUniqueId); List<Long> allIds = idsMapper.execute(entityId); int startIndex = (inRequest.getStartIndex()).intValue(); int endIndex = (inRequest.getEndIndex()).intValue(); PagedSet<FollowerStatusable> pagedSet; if (allIds.isEmpty()) { pagedSet = new PagedSet<FollowerStatusable>(); } else if (startIndex >= allIds.size()) { pagedSet = new PagedSet<FollowerStatusable>(); pagedSet.setTotal(allIds.size()); } else { if (endIndex >= allIds.size()) { endIndex = allIds.size() - 1; } List<Long> pageIds = allIds.subList(startIndex, endIndex + 1); List<FollowerStatusable> list = bulkModelViewMapper.execute(pageIds); followerStatusPopulator.execute(currentUserId, list, FollowerStatus.NOTSPECIFIED); pagedSet = new PagedSet<FollowerStatusable>(startIndex, endIndex, allIds.size(), list); } if (log.isTraceEnabled()) { log.trace("Retrieved " + pagedSet.getFromIndex() + " to " + pagedSet.getToIndex() + " of " + pagedSet.getTotal() + " following for person " + entityUniqueId); } return pagedSet; }
GetFollowingExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public PagedSet<FollowerStatusable> execute(final PrincipalActionContext inActionContext) { GetFollowersFollowingRequest inRequest = (GetFollowersFollowingRequest) inActionContext.getParams(); final String entityUniqueId = inRequest.getEntityId(); final long currentUserId = inActionContext.getPrincipal().getId(); Long entityId = getPersonIdByAccountIdMapper.execute(entityUniqueId); List<Long> allIds = idsMapper.execute(entityId); int startIndex = (inRequest.getStartIndex()).intValue(); int endIndex = (inRequest.getEndIndex()).intValue(); PagedSet<FollowerStatusable> pagedSet; if (allIds.isEmpty()) { pagedSet = new PagedSet<FollowerStatusable>(); } else if (startIndex >= allIds.size()) { pagedSet = new PagedSet<FollowerStatusable>(); pagedSet.setTotal(allIds.size()); } else { if (endIndex >= allIds.size()) { endIndex = allIds.size() - 1; } List<Long> pageIds = allIds.subList(startIndex, endIndex + 1); List<FollowerStatusable> list = bulkModelViewMapper.execute(pageIds); followerStatusPopulator.execute(currentUserId, list, FollowerStatus.NOTSPECIFIED); pagedSet = new PagedSet<FollowerStatusable>(startIndex, endIndex, allIds.size(), list); } if (log.isTraceEnabled()) { log.trace("Retrieved " + pagedSet.getFromIndex() + " to " + pagedSet.getToIndex() + " of " + pagedSet.getTotal() + " following for person " + entityUniqueId); } return pagedSet; } }
GetFollowingExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public PagedSet<FollowerStatusable> execute(final PrincipalActionContext inActionContext) { GetFollowersFollowingRequest inRequest = (GetFollowersFollowingRequest) inActionContext.getParams(); final String entityUniqueId = inRequest.getEntityId(); final long currentUserId = inActionContext.getPrincipal().getId(); Long entityId = getPersonIdByAccountIdMapper.execute(entityUniqueId); List<Long> allIds = idsMapper.execute(entityId); int startIndex = (inRequest.getStartIndex()).intValue(); int endIndex = (inRequest.getEndIndex()).intValue(); PagedSet<FollowerStatusable> pagedSet; if (allIds.isEmpty()) { pagedSet = new PagedSet<FollowerStatusable>(); } else if (startIndex >= allIds.size()) { pagedSet = new PagedSet<FollowerStatusable>(); pagedSet.setTotal(allIds.size()); } else { if (endIndex >= allIds.size()) { endIndex = allIds.size() - 1; } List<Long> pageIds = allIds.subList(startIndex, endIndex + 1); List<FollowerStatusable> list = bulkModelViewMapper.execute(pageIds); followerStatusPopulator.execute(currentUserId, list, FollowerStatus.NOTSPECIFIED); pagedSet = new PagedSet<FollowerStatusable>(startIndex, endIndex, allIds.size(), list); } if (log.isTraceEnabled()) { log.trace("Retrieved " + pagedSet.getFromIndex() + " to " + pagedSet.getToIndex() + " of " + pagedSet.getTotal() + " following for person " + entityUniqueId); } return pagedSet; } GetFollowingExecution(final DomainMapper<String, Long> inGetPersonIdByAccountIdMapper,
            final DomainMapper<Long, List<Long>> inIdsMapper,
            final DomainMapper<List<Long>, List<FollowerStatusable>> inBulkModelViewMapper,
            final FollowerStatusPopulator<FollowerStatusable> inFollowerStatusPopulator); }
GetFollowingExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public PagedSet<FollowerStatusable> execute(final PrincipalActionContext inActionContext) { GetFollowersFollowingRequest inRequest = (GetFollowersFollowingRequest) inActionContext.getParams(); final String entityUniqueId = inRequest.getEntityId(); final long currentUserId = inActionContext.getPrincipal().getId(); Long entityId = getPersonIdByAccountIdMapper.execute(entityUniqueId); List<Long> allIds = idsMapper.execute(entityId); int startIndex = (inRequest.getStartIndex()).intValue(); int endIndex = (inRequest.getEndIndex()).intValue(); PagedSet<FollowerStatusable> pagedSet; if (allIds.isEmpty()) { pagedSet = new PagedSet<FollowerStatusable>(); } else if (startIndex >= allIds.size()) { pagedSet = new PagedSet<FollowerStatusable>(); pagedSet.setTotal(allIds.size()); } else { if (endIndex >= allIds.size()) { endIndex = allIds.size() - 1; } List<Long> pageIds = allIds.subList(startIndex, endIndex + 1); List<FollowerStatusable> list = bulkModelViewMapper.execute(pageIds); followerStatusPopulator.execute(currentUserId, list, FollowerStatus.NOTSPECIFIED); pagedSet = new PagedSet<FollowerStatusable>(startIndex, endIndex, allIds.size(), list); } if (log.isTraceEnabled()) { log.trace("Retrieved " + pagedSet.getFromIndex() + " to " + pagedSet.getToIndex() + " of " + pagedSet.getTotal() + " following for person " + entityUniqueId); } return pagedSet; } GetFollowingExecution(final DomainMapper<String, Long> inGetPersonIdByAccountIdMapper,
            final DomainMapper<Long, List<Long>> inIdsMapper,
            final DomainMapper<List<Long>, List<FollowerStatusable>> inBulkModelViewMapper,
            final FollowerStatusPopulator<FollowerStatusable> inFollowerStatusPopulator); @Override PagedSet<FollowerStatusable> execute(final PrincipalActionContext inActionContext); }
GetFollowingExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public PagedSet<FollowerStatusable> execute(final PrincipalActionContext inActionContext) { GetFollowersFollowingRequest inRequest = (GetFollowersFollowingRequest) inActionContext.getParams(); final String entityUniqueId = inRequest.getEntityId(); final long currentUserId = inActionContext.getPrincipal().getId(); Long entityId = getPersonIdByAccountIdMapper.execute(entityUniqueId); List<Long> allIds = idsMapper.execute(entityId); int startIndex = (inRequest.getStartIndex()).intValue(); int endIndex = (inRequest.getEndIndex()).intValue(); PagedSet<FollowerStatusable> pagedSet; if (allIds.isEmpty()) { pagedSet = new PagedSet<FollowerStatusable>(); } else if (startIndex >= allIds.size()) { pagedSet = new PagedSet<FollowerStatusable>(); pagedSet.setTotal(allIds.size()); } else { if (endIndex >= allIds.size()) { endIndex = allIds.size() - 1; } List<Long> pageIds = allIds.subList(startIndex, endIndex + 1); List<FollowerStatusable> list = bulkModelViewMapper.execute(pageIds); followerStatusPopulator.execute(currentUserId, list, FollowerStatus.NOTSPECIFIED); pagedSet = new PagedSet<FollowerStatusable>(startIndex, endIndex, allIds.size(), list); } if (log.isTraceEnabled()) { log.trace("Retrieved " + pagedSet.getFromIndex() + " to " + pagedSet.getToIndex() + " of " + pagedSet.getTotal() + " following for person " + entityUniqueId); } return pagedSet; } GetFollowingExecution(final DomainMapper<String, Long> inGetPersonIdByAccountIdMapper,
            final DomainMapper<Long, List<Long>> inIdsMapper,
            final DomainMapper<List<Long>, List<FollowerStatusable>> inBulkModelViewMapper,
            final FollowerStatusPopulator<FollowerStatusable> inFollowerStatusPopulator); @Override PagedSet<FollowerStatusable> execute(final PrincipalActionContext inActionContext);  }