### Question:
GroupsServiceImpl extends BaseApiService<CloudIdentity> implements GroupsService { @Override public Iterable<Membership> listMembers(String groupId) throws IOException { validateGroupResourceName(groupId); return new ListMembersIterable(groupId); } private  GroupsServiceImpl(Builder builder); @Override ListenableFuture<Operation> createGroup(Group group); @Override ListenableFuture<Group> getGroup(String groupId); @Override ListenableFuture<Operation> deleteGroup(String groupId); @Override ListenableFuture<Operation> createMembership(String groupId, Membership member); @Override ListenableFuture<Membership> getMembership(String memberId); @Override ListenableFuture<Operation> deleteMembership(String memberId); @Override Iterable<Group> listGroups(String groupNamespace); @Override Iterable<Membership> listMembers(String groupId); static GroupsServiceImpl fromConfiguration(CredentialFactory credentialFactory);  }### Answer:
@Test public void testListMemberships() throws Exception { Memberships.List list1 = mock(Memberships.List.class); Membership member1 = new Membership().setName("groups/g1/memberships/m1"); ListMembershipsResponse page1 = new ListMembershipsResponse() .setMemberships(Collections.singletonList(member1)) .setNextPageToken("nextToken"); when(list1.execute()).thenReturn(page1); Memberships.List list2 = mock(Memberships.List.class); Membership member2 = new Membership().setName("groups/g1/memberships/m2"); ListMembershipsResponse page2 = new ListMembershipsResponse() .setMemberships(Collections.singletonList(member2)) .setNextPageToken(null); when(list2.execute()).thenReturn(page2); when(memberships.list("groups/g1")).thenReturn(list1, list2); ImmutableList<Membership> expected = ImmutableList.of(member1, member2); assertTrue(Iterables.elementsEqual(expected, groupsService.listMembers("groups/g1"))); verify(list1).setPageToken(null); verify(list2).setPageToken("nextToken"); }