@Test
public void testCoerceValueOnCopy() throws Exception {

  makeUpgradeCluster();
  Cluster c = clusters.getCluster("c1");
  assertEquals(1, c.getConfigsByType("zoo.cfg").size());
  c.setDesiredStackVersion(HDP_220_STACK);
  Config config = cf.createNew(c, "zoo.cfg", "version2", new HashMap<String, String>() {
    {
      put("zoo.server.csv", "c6401,c6402,  c6403");
    }
  }, new HashMap<String, Map<String, String>>());
  c.addDesiredConfig("user", Collections.singleton(config));
  assertEquals(2, c.getConfigsByType("zoo.cfg").size());
  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");
  // copy with coerce
  List<Transfer> transfers = new ArrayList<>();
  Transfer transfer = new Transfer();
  transfer.operation = TransferOperation.COPY;
  transfer.coerceTo = TransferCoercionType.YAML_ARRAY;
  transfer.fromKey = "zoo.server.csv";
  transfer.toKey = "zoo.server.array";
  transfer.defaultValue = "['foo','bar']";
  transfers.add(transfer);
  commandParams.put(ConfigureTask.PARAMETER_TRANSFERS, new Gson().toJson(transfers));
  ExecutionCommand executionCommand = new ExecutionCommand();
  executionCommand.setCommandParams(commandParams);
  executionCommand.setClusterName("c1");
  executionCommand.setRoleParams(new HashMap<String, String>());
  executionCommand.getRoleParams().put(ServerAction.ACTION_USER_NAME, "username");
  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("c6401,c6402,  c6403", map.get("zoo.server.csv"));
  assertEquals("['c6401','c6402','c6403']", map.get("zoo.server.array"));
}