### Question:
UsersServiceImpl extends BaseApiService<Directory> implements UsersService { @Override public ListenableFuture<User> updateUserMapping( String userId, String schemaName, String attributeName, Optional<String> value) throws IOException { Update update = service .users() .update( userId, new User() .setCustomSchemas( Collections.singletonMap( schemaName, Collections.singletonMap(attributeName, value.orElse(""))))); return batchRequest(update, retryPolicy, batchService); } private  UsersServiceImpl(Builder builder); static UsersServiceImpl fromConfiguration(CredentialFactory credentialFactory); @Override ListenableFuture<User> getUserMapping(String userId); @Override ListenableFuture<User> updateUserMapping(
      String userId, String schemaName, String attributeName, Optional<String> value); @Override Iterable<User> listUsers(String schemaName);  }### Answer:
@Test public void testUpdateUserMappingWithValue() throws Exception { String userId = "user1@mydomain.com"; Users.Update updateRequest = mock(Users.Update.class); Map<String, Map<String, Object>> schema = Collections.singletonMap("schema", Collections.singletonMap("attribute", "value")); when(users.update(userId, new User().setCustomSchemas(schema))).thenReturn(updateRequest); User toReturn = new User().setPrimaryEmail(userId); doAnswer( invocation -> { AsyncRequest<User> input = invocation.getArgument(0); setAsyncRequestResponse(input, toReturn); return null; }) .when(batchRequestService) .add(any()); ListenableFuture<User> user = usersService.updateUserMapping(userId, "schema", "attribute", Optional.of("value")); assertEquals(toReturn, user.get()); }
@Test public void testUpdateUserMappingWithoutValue() throws Exception { String userId = "user1@mydomain.com"; Users.Update updateRequest = mock(Users.Update.class); Map<String, Map<String, Object>> schema = Collections.singletonMap("schema", Collections.singletonMap("attribute", "")); when(users.update(userId, new User().setCustomSchemas(schema))).thenReturn(updateRequest); User toReturn = new User().setPrimaryEmail(userId); doAnswer( invocation -> { AsyncRequest<User> input = invocation.getArgument(0); setAsyncRequestResponse(input, toReturn); return null; }) .when(batchRequestService) .add(any()); ListenableFuture<User> user = usersService.updateUserMapping(userId, "schema", "attribute", Optional.empty()); assertEquals(toReturn, user.get()); }