@Test
public void testAmsSiteUpdateConfigs() throws Exception{

  Map<String, String> oldPropertiesAmsSite = new HashMap<String, String>() {
    {
      put("timeline.metrics.sink.collection.period", "60");
      put("timeline.metrics.host.aggregator.ttl", "86400");
      put("timeline.metrics.cluster.aggregator.second.ttl", "604800");
    }
  };
  Map<String, String> newPropertiesAmsSite = new HashMap<String, String>() {
    {
      put("timeline.metrics.sink.collection.period", "10");
      put("timeline.metrics.host.aggregator.ttl", "86400");
      put("timeline.metrics.cluster.aggregator.second.ttl", "259200");
    }
  };
  EasyMockSupport easyMockSupport = new EasyMockSupport();
  Clusters clusters = easyMockSupport.createNiceMock(Clusters.class);
  final Cluster cluster = easyMockSupport.createNiceMock(Cluster.class);
  Config mockAmsSite = easyMockSupport.createNiceMock(Config.class);
  expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
    put("normal", cluster);
  }}).once();
  expect(cluster.getDesiredConfigByType("ams-site")).andReturn(mockAmsSite).atLeastOnce();
  expect(mockAmsSite.getProperties()).andReturn(oldPropertiesAmsSite).anyTimes();
  Injector injector = easyMockSupport.createNiceMock(Injector.class);
  expect(injector.getInstance(Gson.class)).andReturn(null).anyTimes();
  expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null).anyTimes();
  expect(injector.getInstance(KerberosHelper.class)).andReturn(createNiceMock(KerberosHelper.class)).anyTimes();
  replay(injector, clusters, mockAmsSite, cluster);
  AmbariManagementControllerImpl controller = createMockBuilder(AmbariManagementControllerImpl.class)
    .addMockedMethod("createConfiguration")
    .addMockedMethod("getClusters", new Class[] { })
    .addMockedMethod("createConfig")
    .withConstructor(createNiceMock(ActionManager.class), 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(createNiceMock(Config.class)).once();
  replay(controller, injector2);
  new UpgradeCatalog240(injector2).updateAMSConfigs();
  easyMockSupport.verifyAll();
  Map<String, String> updatedProperties = propertiesCapture.getValue();
  assertTrue(Maps.difference(newPropertiesAmsSite, updatedProperties).areEqual());
}