@Test
  public void testGetExecutionCommand() throws Exception {
    String cluster1 = getUniqueName();
    final String host1 = getUniqueName();

    createServiceComponentHostSimple(cluster1, host1, getUniqueName());

    String serviceName = "HDFS";

    Cluster cluster = clusters.getCluster(cluster1);
    Service s1 = cluster.getService(serviceName);

    // Create and attach config
    Map<String, String> configs = new HashMap<>();
    configs.put("a", "b");

    Map<String, String> hadoopEnvConfigs = new HashMap<>();
    hadoopEnvConfigs.put("hdfs_user", "myhdfsuser");
    hadoopEnvConfigs.put("hdfs_group", "myhdfsgroup");

    ConfigurationRequest cr1,cr2, cr3;

    cr1 = new ConfigurationRequest(cluster1, "core-site","version1",
                                   configs, null);
    cr2 = new ConfigurationRequest(cluster1, "hdfs-site","version1",
                                   configs, null);
    cr3 = new ConfigurationRequest(cluster1, "hadoop-env","version1",
      hadoopEnvConfigs, null);

    ClusterRequest crReq = new ClusterRequest(cluster.getClusterId(), cluster1, null, null);
    crReq.setDesiredConfig(Collections.singletonList(cr1));
    controller.updateClusters(Collections.singleton(crReq), null);
    crReq = new ClusterRequest(cluster.getClusterId(), cluster1, null, null);
    crReq.setDesiredConfig(Collections.singletonList(cr2));
    controller.updateClusters(Collections.singleton(crReq), null);
    crReq = new ClusterRequest(cluster.getClusterId(), cluster1, null, null);
    crReq.setDesiredConfig(Collections.singletonList(cr3));
    controller.updateClusters(Collections.singleton(crReq), null);



    // Install
    installService(cluster1, serviceName, false, false);

    ExecutionCommand ec =
        controller.getExecutionCommand(cluster,
                                       s1.getServiceComponent("NAMENODE").getServiceComponentHost(host1),
                                       RoleCommand.START);
    assertEquals("1-0", ec.getCommandId());
    assertEquals(cluster1, ec.getClusterName());
    Map<String, Map<String, String>> configurations = ec.getConfigurations();
    assertNotNull(configurations);
    assertEquals(0, configurations.size());
    assertTrue(ec.getCommandParams().containsKey("max_duration_for_retries"));
    assertEquals("0", ec.getCommandParams().get("max_duration_for_retries"));
    assertTrue(ec.getCommandParams().containsKey("command_retry_enabled"));
    assertEquals("false", ec.getCommandParams().get("command_retry_enabled"));
    assertFalse(ec.getCommandParams().containsKey("custom_folder"));

    ec = controller.getExecutionCommand(cluster,
                                        s1.getServiceComponent("DATANODE").getServiceComponentHost(host1),
                                        RoleCommand.START);
    assertEquals(cluster1, ec.getClusterName());
    assertNotNull(ec.getCommandParams());
    assertNotNull(ec.getHostLevelParams());
    assertTrue(ec.getHostLevelParams().containsKey(ExecutionCommand.KeyNames.USER_LIST));
    assertEquals("[\"myhdfsuser\"]", ec.getHostLevelParams().get(ExecutionCommand.KeyNames.USER_LIST));
    assertTrue(ec.getHostLevelParams().containsKey(ExecutionCommand.KeyNames.GROUP_LIST));
    assertEquals("[\"myhdfsgroup\"]", ec.getHostLevelParams().get(ExecutionCommand.KeyNames.GROUP_LIST));
    assertTrue(ec.getHostLevelParams().containsKey(ExecutionCommand.KeyNames.USER_GROUPS));
    assertEquals("{\"myhdfsuser\":[\"myhdfsgroup\"]}", ec.getHostLevelParams().get(ExecutionCommand.KeyNames.USER_GROUPS));
  }
Allows to set maintenanceStateHelper. For use when there is anything to test
with maintenance mode.
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java