@Test public void transformTestNotMatchingId() { final Long entityId = 10L; final String entityAcctName = "acctName"; final JSONObject jsonReq = new JSONObject(); jsonReq.accumulate("followedBy", entityAcctName); context.checking(new Expectations() { { oneOf(getPersonIdByAccountId).execute(entityAcctName); will(returnValue(entityId - 1L)); } }); GetAllFollowedByActivityIdsRequest result = (GetAllFollowedByActivityIdsRequest) sut.transform(jsonReq, entityId); List<Long> groups = result.getGroupStreamIds(); Assert.assertEquals(0, groups.size()); Assert.assertEquals((entityId - 1L), result.getUserId().longValue()); context.assertIsSatisfied(); }
@Override public Serializable transform(final JSONObject inRequest, final Long inUserEntityId) { String accountId = inRequest.getString("followedBy"); Long requestUserId = getPersonIdByAccountId.execute(accountId); ArrayList<Long> followedGroupStreamIds = new ArrayList<Long>(); if (inUserEntityId.equals(requestUserId)) { List<Long> groupIds = followedGroupsMapper.execute(requestUserId); List<DomainGroupModelView> groupList = groupMapper.execute(groupIds); for (DomainGroupModelView group : groupList) { followedGroupStreamIds.add(group.getStreamId()); } } return new GetAllFollowedByActivityIdsRequest(requestUserId, followedGroupStreamIds); }
AllFollowedByPersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { @Override public Serializable transform(final JSONObject inRequest, final Long inUserEntityId) { String accountId = inRequest.getString("followedBy"); Long requestUserId = getPersonIdByAccountId.execute(accountId); ArrayList<Long> followedGroupStreamIds = new ArrayList<Long>(); if (inUserEntityId.equals(requestUserId)) { List<Long> groupIds = followedGroupsMapper.execute(requestUserId); List<DomainGroupModelView> groupList = groupMapper.execute(groupIds); for (DomainGroupModelView group : groupList) { followedGroupStreamIds.add(group.getStreamId()); } } return new GetAllFollowedByActivityIdsRequest(requestUserId, followedGroupStreamIds); } }
AllFollowedByPersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { @Override public Serializable transform(final JSONObject inRequest, final Long inUserEntityId) { String accountId = inRequest.getString("followedBy"); Long requestUserId = getPersonIdByAccountId.execute(accountId); ArrayList<Long> followedGroupStreamIds = new ArrayList<Long>(); if (inUserEntityId.equals(requestUserId)) { List<Long> groupIds = followedGroupsMapper.execute(requestUserId); List<DomainGroupModelView> groupList = groupMapper.execute(groupIds); for (DomainGroupModelView group : groupList) { followedGroupStreamIds.add(group.getStreamId()); } } return new GetAllFollowedByActivityIdsRequest(requestUserId, followedGroupStreamIds); } AllFollowedByPersistenceRequestTransformer(final DomainMapper<String, Long> inGetPersonIdByAccountId,
            final DomainMapper<Long, List<Long>> inFolloweGroupsMapper,
            final DomainMapper<List<Long>, List<DomainGroupModelView>> inGroupMapper); }
AllFollowedByPersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { @Override public Serializable transform(final JSONObject inRequest, final Long inUserEntityId) { String accountId = inRequest.getString("followedBy"); Long requestUserId = getPersonIdByAccountId.execute(accountId); ArrayList<Long> followedGroupStreamIds = new ArrayList<Long>(); if (inUserEntityId.equals(requestUserId)) { List<Long> groupIds = followedGroupsMapper.execute(requestUserId); List<DomainGroupModelView> groupList = groupMapper.execute(groupIds); for (DomainGroupModelView group : groupList) { followedGroupStreamIds.add(group.getStreamId()); } } return new GetAllFollowedByActivityIdsRequest(requestUserId, followedGroupStreamIds); } AllFollowedByPersistenceRequestTransformer(final DomainMapper<String, Long> inGetPersonIdByAccountId,
            final DomainMapper<Long, List<Long>> inFolloweGroupsMapper,
            final DomainMapper<List<Long>, List<DomainGroupModelView>> inGroupMapper); @Override Serializable transform(final JSONObject inRequest, final Long inUserEntityId); }
AllFollowedByPersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { @Override public Serializable transform(final JSONObject inRequest, final Long inUserEntityId) { String accountId = inRequest.getString("followedBy"); Long requestUserId = getPersonIdByAccountId.execute(accountId); ArrayList<Long> followedGroupStreamIds = new ArrayList<Long>(); if (inUserEntityId.equals(requestUserId)) { List<Long> groupIds = followedGroupsMapper.execute(requestUserId); List<DomainGroupModelView> groupList = groupMapper.execute(groupIds); for (DomainGroupModelView group : groupList) { followedGroupStreamIds.add(group.getStreamId()); } } return new GetAllFollowedByActivityIdsRequest(requestUserId, followedGroupStreamIds); } AllFollowedByPersistenceRequestTransformer(final DomainMapper<String, Long> inGetPersonIdByAccountId,
            final DomainMapper<Long, List<Long>> inFolloweGroupsMapper,
            final DomainMapper<List<Long>, List<DomainGroupModelView>> inGroupMapper); @Override Serializable transform(final JSONObject inRequest, final Long inUserEntityId);  }