anchor.diff:       fail_to_start_scenario_without_name,
        fail_to_start_with_invalid_settings,
        fail_to_start_when_not_idle,
  +     fail_to_start_when_amoc_dist_fails,
        stop_scenario,
        fail_to_stop_scenario_when_not_running,
  +     fail_to_stop_when_amoc_dist_fails,
        add_users,
        add_users_on_nodes,
        fail_to_add_users_when_not_running,
  +     fail_to_add_users_when_amoc_dist_fails,
        remove_users,
        remove_users_on_nodes,
        fail_to_remove_users_when_not_running,
  +     fail_to_remove_users_when_amoc_dist_fails,
        update_settings,
        update_settings_on_nodes,
        fail_to_update_settings_when_not_running,
  +     fail_to_update_settings_when_amoc_dist_fails,
        fail_to_update_with_invalid_settings].
   
   %% Setup and teardown
  
positive.code:                 fun(Settings) ->
                          ?assertEqual(lists:sort(Settings), lists:sort(settings())),
                          {ok, mocked}
                  end);
  setup_meck(update_settings_on_nodes) ->
      meck:expect(amoc_dist, get_state, fun() -> running end),
  
negative.code: 
  fail_to_start_when_not_idle(_Config) ->
      JsonBody = #{scenario => bad_scenario},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/start", JsonBody),
      ?assertEqual(409, HttpCode),
      ?assertEqual(#{}, Body).
  
  stop_scenario(_Config) ->
      {HttpCode, Body} = amoc_api_helper:patch("/execution/stop"),
      ?assertEqual(200, HttpCode),
      ?assertEqual(#{}, Body).
  
  fail_to_stop_when_amoc_dist_fails(_Config) ->
      {HttpCode, Body} = amoc_api_helper:patch("/execution/stop"),
      ?assertEqual(500, HttpCode),
      ?assertEqual(#{<<"error">> => <<"mocked">>}, Body).
  
  fail_to_stop_scenario_when_not_running(_Config) ->
      {HttpCode, Body} = amoc_api_helper:patch("/execution/stop"),
      ?assertEqual(409, HttpCode),
      ?assertEqual(#{}, Body).
  
  add_users(_Config) ->
      JsonBody = #{users=> 10},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/add_users", JsonBody),
      ?assertEqual(200, HttpCode),
      ?assertEqual(#{}, Body).
  
  add_users_on_nodes(_Config) ->
      JsonBody = #{users=> 10, nodes=> [node1@host1, node2@host2]},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/add_users", JsonBody),
      ?assertEqual(200, HttpCode),
      ?assertEqual(#{}, Body).
  
  fail_to_add_users_when_amoc_dist_fails(_Config) ->
      JsonBody = #{users=> 10},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/add_users", JsonBody),
      ?assertEqual(500, HttpCode),
      ?assertEqual(#{<<"error">> => <<"mocked">>}, Body).
  
  fail_to_add_users_when_not_running(_Config) ->
      JsonBody = #{users=> 10},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/add_users", JsonBody),
      ?assertEqual(409, HttpCode),
      ?assertEqual(#{}, Body).
  
  remove_users(_Config) ->
      JsonBody = #{users=> 10},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/remove_users", JsonBody),
      ?assertEqual(200, HttpCode),
      ?assertEqual(#{}, Body).
  
  remove_users_on_nodes(_Config) ->
      JsonBody = #{users=> 10, nodes=> [node1@host1, node2@host2]},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/remove_users", JsonBody),
      ?assertEqual(200, HttpCode),
      ?assertEqual(#{}, Body).
  
  fail_to_remove_users_when_amoc_dist_fails(_Config) ->
      JsonBody = #{users=> 10},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/remove_users", JsonBody),
      ?assertEqual(500, HttpCode),
      ?assertEqual(#{<<"error">> => <<"mocked">>}, Body).
  
  fail_to_remove_users_when_not_running(_Config) ->
      JsonBody = #{users=> 10},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/remove_users", JsonBody),
      ?assertEqual(409, HttpCode),
      ?assertEqual(#{}, Body).
  
  update_settings(_Config) ->
      JsonBody = #{settings=> json_settings()},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/update_settings", JsonBody),
      ?assertEqual(200, HttpCode),
      ?assertEqual(#{}, Body).
  
  fail_to_update_settings_when_amoc_dist_fails(_Config) ->
      JsonBody = #{settings=> json_settings()},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/update_settings", JsonBody),
      ?assertEqual(500, HttpCode),
      ?assertEqual(#{<<"error">> => <<"mocked">>}, Body).
  
  update_settings_on_nodes(_Config) ->
      JsonBody = #{settings=> json_settings(), nodes=>[node1@host1, node2@host2]},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/update_settings", JsonBody),
      ?assertEqual(200, HttpCode),
      ?assertEqual(#{}, Body).
  
  fail_to_update_settings_when_not_running(_Config) ->
      JsonBody = #{settings=> json_settings()},
      {HttpCode, Body} = amoc_api_helper:patch("/execution/update_settings", JsonBody),
      ?assertEqual(409, HttpCode),
      ?assertEqual(#{}, Body).
  
  fail_to_update_with_invalid_settings(_config) ->
      {InvalidJsonSettings, Error} = invalid_json_settings_and_error(),
  