@Test
  public void testDisallowedTransferDelete() throws Exception {
    Cluster c = clusters.getCluster("c1");
    assertEquals(1, c.getConfigsByType("zoo.cfg").size());

    Map<String, String> properties = new HashMap<String, String>() {
      {
        put("initLimit", "10");
        put("delete.key.1", "d1");
        put("delete.key.2", "d2");
        put("delete.key.3", "d3");
        put("delete.key.4", "d4");
      }
    };

    Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties);

    c.addDesiredConfig("user", Collections.singleton(config));
    assertEquals(2, c.getConfigsByType("zoo.cfg").size());

    List<ConfigurationKeyValue> configurations = new ArrayList<>();
    ConfigurationKeyValue keyValue = new ConfigurationKeyValue();
    configurations.add(keyValue);
    keyValue.key = "initLimit";
    keyValue.value = "11";

    createUpgrade(c, repoVersion2111);

    Map<String, String> commandParams = new HashMap<>();
    commandParams.put("clusterName", "c1");
    commandParams.put(ConfigureTask.PARAMETER_CONFIG_TYPE, "zoo.cfg");
    commandParams.put(ConfigureTask.PARAMETER_KEY_VALUE_PAIRS, new Gson().toJson(configurations));

    List<Transfer> transfers = new ArrayList<>();
    Transfer transfer2 = new Transfer();
    transfer2.operation = TransferOperation.DELETE;
    transfer2.deleteKey = "delete.key.2";
    transfer2.ifKey = "initLimit";
    transfer2.ifType = "zoo.cfg";
    transfer2.ifValue = "not.real.value";
    transfers.add(transfer2);

    Transfer transfer3 = new Transfer();
    transfer3.operation = TransferOperation.DELETE;
    transfer3.deleteKey = "delete.key.3";
    transfer3.ifKey = "initLimit";
    transfer3.ifType = "zoo.cfg";
    transfer3.ifKeyState = PropertyKeyState.ABSENT;
    transfers.add(transfer3);

    Transfer transfer4 = new Transfer();
    transfer4.operation = TransferOperation.DELETE;
    transfer4.deleteKey = "delete.key.4";
    transfer4.ifKey = "no.such.key";
    transfer4.ifType = "zoo.cfg";
    transfer4.ifKeyState = PropertyKeyState.PRESENT;
    transfers.add(transfer4);

    commandParams.put(ConfigureTask.PARAMETER_TRANSFERS, new Gson().toJson(transfers));

    ExecutionCommand executionCommand = getExecutionCommand(commandParams);
    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(3, c.getConfigsByType("zoo.cfg").size());

    config = c.getDesiredConfigByType("zoo.cfg");
    assertNotNull(config);
    assertFalse("version2".equals(config.getTag()));

    Map<String, String> map = config.getProperties();
    assertEquals(5, map.size());
    assertEquals("11", map.get("initLimit"));
    String[] shouldExitKeys = new String[]{"delete.key.1","delete.key.2","delete.key.3","delete.key.4"};
    for(String key: shouldExitKeys){
      assertTrue(map.containsKey(key));
    }
  }
Tests that replacing a {@code null} value works.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java