anchor.diff:              },
               <<"__onedata.__rejected">> => <<"[{\"a\":\"B\"}]">>
           },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{
  -                <<"json">> => [#{<<"a">> => <<"B">>}],
  -                <<"xattrs">> => #{<<"x">> => <<"y">>},
  -                <<"rdf">> => <<"some rdf">>
  -            },
  -            <<"spaceId">> => <<"spaceId">>
  -        }, IndexInfo, {[<<"__onedata.xattrs.z">>], <<"Some reason">>})
  -    ),
  -    
  -    ?assertEqual(
  -        #{
  -            <<"__onedata">> => #{
  -                <<"__rejectionReason">> => <<"Provided JSON is not harvestable - only JSON objects are accepted">>,
  -                <<"fileName">> => <<"fileName">>,
  -                <<"jsonMetadataExists">> => true,
  -                <<"spaceId">> => <<"spaceId">>,
  +        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">> => <<"[]">>
           },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{<<"json">> => []},
  -            <<"spaceId">> => <<"spaceId">>
  -        }, IndexInfo, {[], <<>>})
  -    ),
  -    
  -    ?assertEqual(
  -        #{
  -            <<"__onedata">> => #{
  -                <<"__rejectionReason">> => <<"Provided JSON is not harvestable - only JSON objects are accepted">>,
  -                <<"fileName">> => <<"fileName">>,
  -                <<"jsonMetadataExists">> => true,
  -                <<"spaceId">> => <<"spaceId">>,
  +        call_prepare_data(#{<<"json">> => []}, IndexInfo, [])
  +    ),
  +    
  +    ?assertEqual(
  +        #{
  +            <<"__onedata">> => ExpectedInternalMetadata#{
                   <<"rdfMetadataExists">> => false,
                   <<"xattrsMetadataExists">> => false
               },
               <<"__onedata.__rejected">> => <<"\"string_json\"">>
           },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{<<"json">> => <<"string_json">>},
  -            <<"spaceId">> => <<"spaceId">>
  -        }, IndexInfo, {[], <<>>})
  -    ),
  -    
  -    ?assertEqual(
  -        #{
  -            <<"__onedata">> => #{
  -                <<"__rejectionReason">> => <<"Provided JSON is not harvestable - only JSON objects are accepted">>,
  -                <<"fileName">> => <<"fileName">>,
  -                <<"jsonMetadataExists">> => true,
  -                <<"spaceId">> => <<"spaceId">>,
  +        call_prepare_data(#{<<"json">> => <<"string_json">>}, IndexInfo, [])
  +    ),
  +    
  +    ?assertEqual(
  +        #{
  +            <<"__onedata">> => ExpectedInternalMetadata#{
                   <<"rdfMetadataExists">> => false,
                   <<"xattrsMetadataExists">> => false
               },
               <<"__onedata.__rejected">> => <<"8">>
           },
  -        elasticsearch_harvesting_backend:prepare_data(#{
  -            <<"fileId">> => <<"fileId">>,
  -            <<"fileName">> => <<"fileName">>,
  -            <<"payload">> => #{<<"json">> => 8},
  -            <<"spaceId">> => <<"spaceId">>
  -        }, IndexInfo, {[], <<>>})
  -    ),
  +        call_prepare_data(#{<<"json">> => 8}, IndexInfo, [])),
       ok.
   
   
  
positive.code:             },
              <<"a">> => <<"B">>
          },
          elasticsearch_harvesting_backend:prepare_data(#{
              <<"fileId">> => <<"fileId">>,
              <<"fileName">> => <<"fileName">>,
              <<"payload">> => #{<<"json">> => <<"{\"a\":\"B\"}">>},
              <<"spaceId">> => <<"spaceId">>
          }, IndexInfo, {[], <<>>})
      ),
      
      ?assertEqual(
  
negative.code: unmock_do_submit_request() ->
      meck:unload(elasticsearch_harvesting_backend).
  
  call_prepare_data(Payload, IndexInfo, RejectedFields) ->
      RejectionReason = case RejectedFields of
          [] -> <<>>;
          _ -> <<"Rejection reason">>
      end,
      elasticsearch_harvesting_backend:prepare_data(#{
          <<"fileId">> => <<"fileId">>,
          <<"fileName">> => <<"fileName">>,
          <<"payload">> => Payload,
          <<"spaceId">> => <<"spaceId">>
      }, IndexInfo, {RejectedFields, RejectionReason}).
  
  -endif.
  