anchor.diff:  
   
   %% @private
  --spec populate_links(node(), od_space:id(), atm_workflow_execution:phase(), pos_integer()) ->
  -    [{atm_workflow_execution:id(), atm_workflow_executions_collection:index()}] .
  -populate_links(Node, SpaceId, Phase, LinksNum) ->
  -    lists:keysort(2, lists:map(fun(_) ->
  -        AtmWorkflowExecutionDoc = gen_rand_workflow(SpaceId),
  +-spec populate_links(
  +    node(),
  +    od_space:id(),
  +    atm_workflow_execution:phase(),
  +    [od_atm_inventory:id()],
  +    atm_workflow_executions_forest:tree_ids(),
  +    pos_integer()
  +) ->
  +    atm_workflow_execution:listing().
  +populate_links(Node, SpaceId, Phase, AllAtmInventoryIds, all, LinksNum) ->
  +    populate_links(Node, SpaceId, Phase, AllAtmInventoryIds, AllAtmInventoryIds, LinksNum);
  +
  +populate_links(Node, SpaceId, Phase, AllAtmInventoryIds, ListedAtmInventoryId, LinksNum) when
  +    is_binary(ListedAtmInventoryId)
  +->
  +    populate_links(Node, SpaceId, Phase, AllAtmInventoryIds, [ListedAtmInventoryId], LinksNum);
  +
  +populate_links(Node, SpaceId, Phase, AllAtmInventoryIds, ListedAtmInventoryIds, LinksNum) ->
  +    lists:keysort(2, lists:filtermap(fun(_) ->
  +        AtmInventoryId = lists_utils:random_element(AllAtmInventoryIds),
  +        AtmWorkflowExecutionDoc = gen_rand_workflow(SpaceId, AtmInventoryId),
           AtmWorkflowExecutionId = AtmWorkflowExecutionDoc#document.key,
           add_link(Node, Phase, AtmWorkflowExecutionDoc),
   
  -        {AtmWorkflowExecutionId, index(Phase, AtmWorkflowExecutionDoc)}
  +        case lists:member(AtmInventoryId, ListedAtmInventoryIds) of
  +            true ->
  +                {true, {AtmWorkflowExecutionId, index(Phase, AtmWorkflowExecutionDoc)}};
  +            false ->
  +                false
  +        end
       end, lists:seq(1, LinksNum))).
   
   
   %% @private
  --spec gen_rand_workflow(od_space:id()) -> atm_workflow_execution:record().
  -gen_rand_workflow(SpaceId) ->
  +-spec gen_rand_workflow(od_space:id(), od_atm_inventory:id()) ->
  +    atm_workflow_execution:record().
  +gen_rand_workflow(SpaceId, AtmInventoryId) ->
       #document{key = str_utils:rand_hex(32), value = #atm_workflow_execution{
           space_id = SpaceId,
  +        atm_inventory_id = AtmInventoryId,
           schedule_time = rand:uniform(9999999),
           start_time = rand:uniform(9999999),
           finish_time = rand:uniform(9999999)
  
positive.code:     oct_background:end_per_suite().
  
  
  init_per_group(_Group, Config) ->
      lfm_proxy:init(Config, false).
  
  
  end_per_group(_Group, Config) ->
      lfm_proxy:teardown(Config).
  
  
  init_per_testcase(_Case, Config) ->
      ct:timetrap({minutes, 5}),
      Config.
  
negative.code:     SpaceId = str_utils:rand_hex(32),
      Node = oct_background:get_random_provider_node(paris),
  
      AllAtmInventoryIds = [str_utils:rand_hex(32) || _ <- lists:seq(1, 5)],
      ListedAtmInventoryIds = lists_utils:random_element([
          all,
          lists_utils:random_element(AllAtmInventoryIds),
          lists_utils:random_sublist(AllAtmInventoryIds)
      ]),
      ExpLinks = populate_links(Node, SpaceId, Phase, AllAtmInventoryIds, ListedAtmInventoryIds, LinksNum),
  
      ListingOpts = case ListingMethod of
          offset -> #{offset => 0, limit => Limit};
          start_index -> #{start_index => <<>>, limit => Limit}
      end,
      ListedLinks = list_all_links_by_chunk(
          Node, ListingMethod, SpaceId, Phase, ListedAtmInventoryIds, ListingOpts, []
      ),
      ?assertEqual(ExpLinks, ListedLinks).
  
  
  