@Test
public void testAllowedSet() throws Exception {

  makeUpgradeCluster();
  Cluster c = clusters.getCluster("c1");
  assertEquals(1, c.getConfigsByType("zoo.cfg").size());
  c.setCurrentStackVersion(HDP_211_STACK);
  c.setDesiredStackVersion(HDP_220_STACK);
  Config config = cf.createNew(c, "zoo.cfg", "version2", new HashMap<String, String>() {
    {
      put("set.key.1", "s1");
      put("set.key.2", "s2");
      put("set.key.3", "s3");
      put("set.key.4", "s4");
    }
  }, new HashMap<String, Map<String, String>>());
  c.addDesiredConfig("user", Collections.singleton(config));
  assertEquals(2, c.getConfigsByType("zoo.cfg").size());
  // create several configurations
  List<ConfigurationKeyValue> configurations = new ArrayList<>();
  ConfigurationKeyValue fooKey1 = new ConfigurationKeyValue();
  configurations.add(fooKey1);
  fooKey1.key = "fooKey1";
  fooKey1.value = "barValue1";
  ConfigurationKeyValue fooKey2 = new ConfigurationKeyValue();
  configurations.add(fooKey2);
  fooKey2.key = "fooKey2";
  fooKey2.value = "barValue2";
  ConfigurationKeyValue fooKey3 = new ConfigurationKeyValue();
  configurations.add(fooKey3);
  fooKey3.key = "fooKey3";
  fooKey3.value = "barValue3";
  fooKey3.ifKey = "set.key.1";
  fooKey3.ifType = "zoo.cfg";
  fooKey3.ifValue = "s1";
  ConfigurationKeyValue fooKey4 = new ConfigurationKeyValue();
  configurations.add(fooKey4);
  fooKey4.key = "fooKey4";
  fooKey4.value = "barValue4";
  fooKey4.ifKey = "set.key.2";
  fooKey4.ifType = "zoo.cfg";
  fooKey4.ifKeyState= PropertyKeyState.PRESENT;
  ConfigurationKeyValue fooKey5 = new ConfigurationKeyValue();
  configurations.add(fooKey5);
  fooKey5.key = "fooKey5";
  fooKey5.value = "barValue5";
  fooKey5.ifKey = "abc";
  fooKey5.ifType = "zoo.cfg";
  fooKey5.ifKeyState= PropertyKeyState.ABSENT;
  Map<String, String> commandParams = new HashMap<>();
  commandParams.put("upgrade_direction", "upgrade");
  commandParams.put("version", HDP_2_2_0_1);
  commandParams.put("clusterName", "c1");
  commandParams.put(ConfigureTask.PARAMETER_CONFIG_TYPE, "zoo.cfg");
  commandParams.put(ConfigureTask.PARAMETER_KEY_VALUE_PAIRS, new Gson().toJson(configurations));
  ExecutionCommand executionCommand = new ExecutionCommand();
  executionCommand.setCommandParams(commandParams);
  executionCommand.setClusterName("c1");
  HostRoleCommand hostRoleCommand = hostRoleCommandFactory.create(null, null, null, null);
  hostRoleCommand.setExecutionCommandWrapper(new ExecutionCommandWrapper(executionCommand));
  action.setExecutionCommand(executionCommand);
  action.setHostRoleCommand(hostRoleCommand);
  CommandReport report = action.execute(null);
  assertNotNull(report);
  assertEquals(2, c.getConfigsByType("zoo.cfg").size());
  config = c.getDesiredConfigByType("zoo.cfg");
  assertNotNull(config);
  assertEquals("barValue1", config.getProperties().get("fooKey1"));
  assertEquals("barValue2", config.getProperties().get("fooKey2"));
  assertEquals("barValue3", config.getProperties().get("fooKey3"));
  assertEquals("barValue4", config.getProperties().get("fooKey4"));
  assertEquals("barValue5", config.getProperties().get("fooKey5"));
  assertEquals("s1", config.getProperties().get("set.key.1"));
  assertEquals("s2", config.getProperties().get("set.key.2"));
  assertEquals("s3", config.getProperties().get("set.key.3"));
  assertEquals("s4", config.getProperties().get("set.key.4"));
}