anchor.diff:      ])).
   
   
  -set_rdf_metadata_test(Config) ->
  -    [Provider2, Provider1] = Providers = ?config(op_worker_nodes, Config),
  -
  -    GetSessionFun = fun(Node) ->
  -        ?config({session_id, {?USER_IN_BOTH_SPACES, ?GET_DOMAIN(Node)}}, Config)
  -    end,
  -
  -    UserSessId = GetSessionFun(Provider2),
  -
  -    RootDirPath = filename:join(["/", ?SPACE_2, ?SCENARIO_NAME]),
  -    {ok, RootDirGuid} = lfm_proxy:mkdir(Provider2, UserSessId, RootDirPath, 8#777),
  -    {ok, ShareId} = lfm_proxy:create_share(Provider2, UserSessId, {guid, RootDirGuid}, <<"share">>),
  -
  -    DirPath = filename:join([RootDirPath, <<"dir">>]),
  -    {ok, DirGuid} = lfm_proxy:mkdir(Provider2, UserSessId, DirPath, 8#777),
  -
  -    RegularFilePath = filename:join([RootDirPath, <<"file">>]),
  -    {ok, RegularFileGuid} = lfm_proxy:create(Provider2, UserSessId, RegularFilePath, 8#777),
  -
  -    % Wait for metadata sync between providers
  -    ?assertMatch(
  -        {ok, #file_attr{}},
  -        lfm_proxy:stat(Provider1, GetSessionFun(Provider1), {guid, RegularFileGuid}),
  -        ?ATTEMPTS
  -    ),
  -
  -    GetMetadataFun = fun(Node, FileGuid) ->
  -        SessId = GetSessionFun(Node),
  +%%%===================================================================
  +%%% Set rdf metadata functions
  +%%%===================================================================
  +
  +
  +set_file_rdf_metadata_test(Config) ->
  +    set_rdf_metadata_test_base(<<"file">>, _TestShareMode = false, Config).
  +
  +
  +set_dir_rdf_metadata_test(Config) ->
  +    set_rdf_metadata_test_base(<<"dir">>, _TestShareMode = false, Config).
  +
  +
  +set_shared_file_rdf_metadata_test(Config) ->
  +    set_rdf_metadata_test_base(<<"file">>, _TestShareMode = true, Config).
  +
  +
  +set_shared_dir_rdf_metadata_test(Config) ->
  +    set_rdf_metadata_test_base(<<"dir">>, _TestShareMode = true, Config).
  +
  +
  +%% @private
  +set_rdf_metadata_test_base(FileType, TestShareMode, Config) ->
  +    [P2, P1] = Providers = ?config(op_worker_nodes, Config),
  +    SessIdP1 = ?USER_IN_BOTH_SPACES_SESS_ID(P1, Config),
  +    SessIdP2 = ?USER_IN_BOTH_SPACES_SESS_ID(P2, Config),
  +
  +    FilePath = filename:join(["/", ?SPACE_2, ?RANDOM_FILE_NAME]),
  +    {ok, FileGuid} = create_file(FileType, P1, SessIdP1, FilePath),
  +
  +    GetRdfFun = fun(Node, FileGuid) ->
  +        SessId = ?USER_IN_BOTH_SPACES_SESS_ID(Node, Config),
           lfm_proxy:get_metadata(Node, SessId, {guid, FileGuid}, rdf, [], false)
       end,
  -    RemoveMetadataFun = fun(Node, FileGuid) ->
  -        SessId = GetSessionFun(Node),
  +    RemoveRdfFun = fun(Node, FileGuid) ->
  +        SessId = ?USER_IN_BOTH_SPACES_SESS_ID(Node, Config),
           lfm_proxy:remove_metadata(Node, SessId, {guid, FileGuid}, rdf)
       end,
   
  +    {ShareId, ClientSpec, VerifyEnvFun, GetExpCallResultFun} = case TestShareMode of
  +        true ->
  +            {ok, Id} = lfm_proxy:create_share(P1, SessIdP1, {guid, FileGuid}, <<"share">>),
  +            {
  +                Id,
  +                ?CLIENT_SPEC_FOR_SHARE_SCENARIOS(Config),
  +                fun(_, #api_test_ctx{node = TestNode}) ->
  +                    ?assertMatch({error, ?ENODATA}, GetRdfFun(TestNode, FileGuid), ?ATTEMPTS),
  +                    true
  +                end,
  +                fun(_TestCtx) -> ?ERROR_NOT_SUPPORTED end
  +            };
  +        false ->
  +            {
  +                undefined,
  +                ?CLIENT_SPEC_FOR_SPACE_2_SCENARIOS(Config),
  +                fun
  +                    (false, #api_test_ctx{node = TestNode}) ->
  +                        ?assertMatch({error, ?ENODATA}, GetRdfFun(TestNode, FileGuid), ?ATTEMPTS),
  +                        true;
  +                    (true, #api_test_ctx{node = TestNode, data = #{<<"metadata">> := Metadata}}) ->
  +                        lists:foreach(fun(Node) ->
  +                            ?assertMatch({ok, Metadata}, GetRdfFun(Node, FileGuid), ?ATTEMPTS)
  +                        end, Providers),
  +
  +                        case Metadata of
  +                            ?RDF_METADATA_1 ->
  +                                % Do nothing after setting ?RDF_METADATA_1 to test
  +                                % overriding it by ?RDF_METADATA_2
  +                                ok;
  +                            ?RDF_METADATA_2 ->
  +                                % Remove ?RDF_METADATA_2 to test setting ?RDF_METADATA_1 on clean state
  +                                ?assertMatch(ok, RemoveRdfFun(TestNode, FileGuid)),
  +                                % Wait for removal to be synced between providers.
  +                                lists:foreach(fun(Node) ->
  +                                    ?assertMatch({error, ?ENODATA}, GetRdfFun(Node, FileGuid), ?ATTEMPTS)
  +                                end, Providers)
  +                        end,
  +                        true
  +                end,
  +                fun(_TestCtx) -> ok end
  +            }
  +    end,
       DataSpec = #data_spec{
           required = [<<"metadata">>],
           correct_values = #{
  
positive.code:         true -> ?CLIENT_SPEC_FOR_SHARE_SCENARIOS(Config);
          false -> ?CLIENT_SPEC_FOR_SPACE_2_SCENARIOS(Config)
      end,
  
      DataSpec = #data_spec{
          optional = QsParams = [<<"attribute">>, <<"inherited">>, <<"show_internal">>],
          correct_values = #{
  
negative.code:     get_file_xattrs_on_provider_not_supporting_space_test/1,
      get_dir_xattrs_on_provider_not_supporting_space_test/1,
  
      % Set rdf metadata test cases
      set_file_rdf_metadata_test/1,
      set_dir_rdf_metadata_test/1,
      set_shared_file_rdf_metadata_test/1,
      set_shared_dir_rdf_metadata_test/1,
  
  
      set_json_metadata_test/1
  ]).
  
  all() ->
      ?ALL([
  %%        get_file_rdf_metadata_with_rdf_set_test,
  %%        get_dir_rdf_metadata_with_rdf_set_test,
  %%        get_file_rdf_metadata_without_rdf_set_test,
  %%        get_dir_rdf_metadata_without_rdf_set_test,
  %%        get_shared_file_rdf_metadata_with_rdf_set_test,
  %%        get_shared_dir_rdf_metadata_with_rdf_set_test,
  %%        get_shared_file_rdf_metadata_without_rdf_set_test,
  %%        get_shared_dir_rdf_metadata_without_rdf_set_test,
  %%        get_file_rdf_metadata_on_provider_not_supporting_space_test,
  %%        get_dir_rdf_metadata_on_provider_not_supporting_space_test,
  %%
  %%        get_file_json_metadata_with_json_set_test,
  %%        get_dir_json_metadata_with_json_set_test,
  %%        get_file_json_metadata_without_json_set_test,
  %%        get_dir_json_metadata_without_json_set_test,
  %%        get_shared_file_json_metadata_with_json_set_test,
  %%        get_shared_dir_json_metadata_with_json_set_test,
  %%        get_shared_file_json_metadata_without_json_set_test,
  %%        get_shared_dir_json_metadata_without_json_set_test,
  %%        get_file_json_metadata_on_provider_not_supporting_space_test,
  %%        get_dir_json_metadata_on_provider_not_supporting_space_test,
  %%
  %%        get_file_xattrs_with_json_set_test,
  %%        get_dir_xattrs_with_json_set_test,
  %%        get_file_xattrs_without_json_set_test,
  %%        get_dir_xattrs_without_json_set_test,
  %%        get_shared_file_xattrs_with_json_set_test,
  %%        get_shared_dir_xattrs_with_json_set_test,
  %%        get_shared_file_xattrs_without_json_set_test,
  %%        get_shared_dir_xattrs_without_json_set_test,
  %%        get_file_xattrs_on_provider_not_supporting_space_test,
  %%        get_dir_xattrs_on_provider_not_supporting_space_test,
  
          set_file_rdf_metadata_test,
          set_dir_rdf_metadata_test,
          set_shared_file_rdf_metadata_test,
          set_shared_dir_rdf_metadata_test
  
  
  %%        set_json_metadata_test
      ]).
  
  