@Override public void execute(OperationRequest operation, OperationContext context, ParticipantId participant) throws InvalidRequestException { FetchProfilesRequest request = OperationUtil.getRequiredParameter(operation, ParamsProperty.FETCH_PROFILES_REQUEST); List<String> requestAddresses = request.getParticipantIds(); List<ParticipantProfile> profiles = Lists.newArrayListWithCapacity(requestAddresses.size()); for (String address : requestAddresses) { ParticipantProfile participantProfile = profilesFetcher.fetchProfile(address); profiles.add(participantProfile); } FetchProfilesResult result = new FetchProfilesResult(profiles); Map<ParamsProperty, Object> data = ImmutableMap.<ParamsProperty, Object> of(ParamsProperty.FETCH_PROFILES_RESULT, result); context.constructResponse(operation, data); } }
@Override protected void setUp() { MockitoAnnotations.initMocks(this); FetchProfilesRequest request = new FetchProfilesRequest(Lists.newArrayList(ADDRESS)); when(operation.getParameter(ParamsProperty.FETCH_PROFILES_REQUEST)).thenReturn(request); when(fakeProfilesFetcher.fetchProfile(ADDRESS)).thenReturn( new ParticipantProfile(ADDRESS, NAME, IMAGE_URL, PROFILE_URL)); service = new FetchProfilesService(fakeProfilesFetcher); }
@Override protected void setUp() { MockitoAnnotations.initMocks(this); FetchProfilesRequest request = new FetchProfilesRequest(Lists.newArrayList(ADDRESS)); when(operation.getParameter(ParamsProperty.FETCH_PROFILES_REQUEST)).thenReturn(request); when(fakeProfilesFetcher.fetchProfile(ADDRESS)).thenReturn( new ParticipantProfile(ADDRESS, NAME, IMAGE_URL, PROFILE_URL)); service = new FetchProfilesService(fakeProfilesFetcher); }
@Override public ParticipantProfile fetchProfile(String email) { ParticipantProfile pTemp; pTemp = ProfilesFetcher.SIMPLE_PROFILES_FETCHER.fetchProfile(email); return new ParticipantProfile(email, pTemp.getName(), getImageUrl(email), pTemp.getProfileUrl()); } }
@Override public ParticipantProfile fetchProfile(String email) { ParticipantProfile pTemp = null; pTemp = ProfilesFetcher.SIMPLE_PROFILES_FETCHER.fetchProfile(email); ParticipantProfile profile = new ParticipantProfile(email, pTemp.getName(), getImageUrl(email), pTemp.getProfileUrl()); return profile; } }