@Test
public void testAmsEnvUpdateConfigs() throws Exception {

  Map<String, String> oldPropertiesAmsEnv = new HashMap<String, String>() {
    {
      put("content", "\n" +
          "# AMS Collector heapsize\n" +
          "export AMS_COLLECTOR_HEAPSIZE={{metrics_collector_heapsize}}\n" +
          "\n" +
          "# HBase normalizer enabled\n" +
          "export AMS_HBASE_NORMALIZER_ENABLED={{ams_hbase_normalizer_enabled}}\n" +
          "\n" +
          "# HBase compaction policy enabled\n" +
          "export HBASE_FIFO_COMPACTION_POLICY_ENABLED={{ams_hbase_fifo_compaction_policy_enabled}}\n" +
          "\n" +
          "# HBase Tables Initialization check enabled\n" +
          "export AMS_HBASE_INIT_CHECK_ENABLED={{ams_hbase_init_check_enabled}}\n");
    }
  };
  Map<String, String> newPropertiesAmsEnv = new HashMap<String, String>() {
    {
      put("content", "\n" +
          "# AMS Collector heapsize\n" +
          "export AMS_COLLECTOR_HEAPSIZE={{metrics_collector_heapsize}}\n" +
          "\n" +
          "# HBase Tables Initialization check enabled\n" +
          "export AMS_HBASE_INIT_CHECK_ENABLED={{ams_hbase_init_check_enabled}}\n");
    }
  };
  EasyMockSupport easyMockSupport = new EasyMockSupport();
  Config mockAmsEnv = easyMockSupport.createNiceMock(Config.class);
  reset(clusters, cluster);
  expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
    put("normal", cluster);
  }}).once();
  expect(cluster.getDesiredConfigByType("ams-env")).andReturn(mockAmsEnv).atLeastOnce();
  expect(mockAmsEnv.getProperties()).andReturn(oldPropertiesAmsEnv).anyTimes();
  replay(clusters, mockAmsEnv, cluster);
  AmbariManagementControllerImpl controller = createMockBuilder(AmbariManagementControllerImpl.class)
      .addMockedMethod("createConfiguration")
      .addMockedMethod("getClusters", new Class[]{})
      .addMockedMethod("createConfig")
      .withConstructor(actionManager, clusters, injector)
      .createNiceMock();
  Injector injector2 = easyMockSupport.createNiceMock(Injector.class);
  Capture<Map<String, String>> propertiesCapture = EasyMock.newCapture();
  expect(injector2.getInstance(AmbariManagementController.class)).andReturn(controller).anyTimes();
  expect(controller.getClusters()).andReturn(clusters).anyTimes();
  expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(propertiesCapture), anyString(),
      EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(config).once();
  replay(controller, injector2);
  new UpgradeCatalog250(injector2).updateAMSConfigs();
  easyMockSupport.verifyAll();
  Map<String, String> updatedProperties = propertiesCapture.getValue();
  assertTrue(Maps.difference(newPropertiesAmsEnv, updatedProperties).areEqual());
}