@Test public void transformTestMatchingId() { final Long entityId = 10L; final String entityAcctName = "acctName"; final JSONObject jsonReq = new JSONObject(); jsonReq.accumulate("followedBy", entityAcctName); final List<Long> followedGroups = Arrays.asList(1L, 2L, 3L); DomainGroupModelView group1 = new DomainGroupModelView(); group1.setEntityId(1L); group1.setStreamId(4L); DomainGroupModelView group2 = new DomainGroupModelView(); group2.setEntityId(2L); group2.setStreamId(5L); DomainGroupModelView group3 = new DomainGroupModelView(); group3.setEntityId(3L); group3.setStreamId(6L); final List<DomainGroupModelView> groups = Arrays.asList(group1, group2, group3); context.checking(new Expectations() { { oneOf(getPersonIdByAccountId).execute(entityAcctName); will(returnValue(entityId)); oneOf(followeGroupsMapper).execute(entityId); will(returnValue(followedGroups)); oneOf(groupMapper).execute(followedGroups); will(returnValue(groups)); } }); GetAllFollowedByActivityIdsRequest result = (GetAllFollowedByActivityIdsRequest) sut.transform(jsonReq, entityId); Assert.assertEquals(Arrays.asList(group1.getStreamId(), group2.getStreamId(), group3.getStreamId()), result .getGroupStreamIds()); Assert.assertEquals(entityId, result.getUserId()); 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);  }