anchor.diff:                  <<"json">> => <<"{\"a\":\"B\", \"c\":\"d\"}">>,
                   <<"xattrs">> => #{<<"x">> => <<"y">>, <<"z">> => <<"b">>}
               },
  -            <<"spaceId">> => <<"spaceId">>
  -        }, IndexInfo, {all, <<"Rejection reason">>})
  -    ),
  -    
  -    ?assertEqual(
  -        #{
  -            <<"a">> => <<"B">>
  -        },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{
  -                <<"json">> => <<"{\"a\":\"B\"}">>,
  -                <<"xattrs">> => #{<<"x">> => <<"y">>},
  -                <<"rdf">> => <<"some rdf">>
  -            },
  -            <<"spaceId">> => <<"spaceId">>
  -        }, #harvester_index{include_metadata = [json]}, {[], <<>>})
  -    ),
  -    
  -    ?assertEqual(
  -        #{
  -            <<"__onedata">> => #{
  -                <<"xattrs">> => #{<<"x">> => #{<<"__value">> => <<"y">>}}
  -            }
  -        },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{
  -                <<"json">> => <<"{\"a\":\"B\"}">>,
  -                <<"xattrs">> => #{<<"x">> => <<"y">>},
  -                <<"rdf">> => <<"some rdf">>
  -            },
  -            <<"spaceId">> => <<"spaceId">>
  -        }, #harvester_index{include_metadata = [xattrs]}, {[], <<>>})
  -    ),
  -    
  -    ?assertEqual(
  -        #{
  -            <<"__onedata">> => #{
  -                <<"rdf">> => <<"some rdf">>
  -            }
  -        },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{
  -                <<"json">> => <<"{\"a\":\"B\"}">>,
  -                <<"xattrs">> => #{<<"x">> => <<"y">>},
  -                <<"rdf">> => <<"some rdf">>
  -            },
  -            <<"spaceId">> => <<"spaceId">>
  -        }, #harvester_index{include_metadata = [rdf]}, {[], <<>>})
  -    ),
  -    
  -    ?assertEqual(
  -        #{
  -            <<"__onedata.__rejected">> => <<"{\"c\":\"d\",\"a\":\"B\"}">>
  -        },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{
  -                <<"json">> => <<"{\"a\":\"B\", \"c\":\"d\"}">>,
  -                <<"xattrs">> => #{<<"x">> => <<"y">>, <<"z">> => <<"b">>}
  -            },
  -            <<"spaceId">> => <<"spaceId">>},
  -            #harvester_index{include_metadata = [json], include_rejection_reason = false},
  -            {all, <<"Rejection reason">>}
  -        )
  -    ),
  -    
  -    ?assertEqual(
  -        #{
  -            <<"a">> => <<"B">>,
  -            <<"c">> => <<"d">>,
  -            <<"__onedata">> => #{<<"__rejected">> => [<<"x">>]}
  -        },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{
  -                <<"json">> => <<"{\"a\":\"B\", \"c\":\"d\"}">>,
  -                <<"xattrs">> => #{<<"x">> => <<"y">>, <<"z">> => <<"b">>}
  -            },
               <<"spaceId">> => <<"spaceId">>},
               #harvester_index{include_metadata = [json], include_rejection_reason = false},
               {[<<"x">>], <<"Rejection reason">>}
  
positive.code:             },
              <<"c">> => <<"d">>
          },
          elasticsearch_harvesting_backend:prepare_data(#{
              <<"fileId">> => <<"fileId">>,
              <<"fileName">> => <<"fileName">>,
              <<"payload">> => #{<<"json">> => <<"{\"a\":\"B\", \"c\":\"d\"}">>, <<"xattrs">> => #{<<"x">> => <<"y">>}},
              <<"spaceId">> => <<"spaceId">>
          }, IndexInfo, {[<<"a">>], <<"Rejection reason">>})
      ),
      
      ?assertEqual(
  
negative.code:             },
              <<"__onedata.__rejected">> => <<"[{\"a\":\"B\"}]">>
          },
          call_prepare_data(#{
              <<"json">> => [#{<<"a">> => <<"B">>}],
              <<"xattrs">> => #{<<"x">> => <<"y">>},
              <<"rdf">> => <<"some rdf">>
          }, IndexInfo, [<<"__onedata.xattrs.z">>])
      ),
      
      ?assertEqual(
          #{
              <<"__onedata">> => ExpectedInternalMetadata#{
                  <<"rdfMetadataExists">> => false,
                  <<"xattrsMetadataExists">> => false
              },
              <<"__onedata.__rejected">> => <<"[]">>
          },
          call_prepare_data(#{<<"json">> => []}, IndexInfo, [])
      ),
      
      ?assertEqual(
          #{
              <<"__onedata">> => ExpectedInternalMetadata#{
                  <<"rdfMetadataExists">> => false,
                  <<"xattrsMetadataExists">> => false
              },
              <<"__onedata.__rejected">> => <<"\"string_json\"">>
          },
          call_prepare_data(#{<<"json">> => <<"string_json">>}, IndexInfo, [])
      ),
      
      ?assertEqual(
          #{
              <<"__onedata">> => ExpectedInternalMetadata#{
                  <<"rdfMetadataExists">> => false,
                  <<"xattrsMetadataExists">> => false
              },
              <<"__onedata.__rejected">> => <<"8">>
          },
          call_prepare_data(#{<<"json">> => 8}, IndexInfo, [])),
      ok.
  
  
  