### Question:
GroupsServiceImpl extends BaseApiService<CloudIdentity> implements GroupsService { @Override public ListenableFuture<Operation> createMembership(String groupId, Membership member) throws IOException { Memberships.Create create = service.groups().memberships().create(groupId, member); return batchRequest(create, retryPolicy, batchService); } 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 testCreateMemberships() throws Exception { String groupId = "groups/g1"; Memberships.Create request = mock(Memberships.Create.class); Membership toCreate = new Membership(); when(memberships.create(groupId, toCreate)).thenReturn(request); Operation operation = new Operation().setDone(true); doAnswer( invocation -> { AsyncRequest<Operation> input = invocation.getArgument(0); setAsyncRequestResponse(input, operation); return null; }) .when(batchRequestService) .add(any()); ListenableFuture<Operation> member = groupsService.createMembership(groupId, toCreate); assertEquals(operation, member.get()); }