@Test
public void testKafkaUpdateConfigs() throws Exception {

  Map<String, String> oldProperties = new HashMap<String, String>() {
    {
      put("kafka.timeline.metrics.host", "{{metric_collector_host}}");
      put("kafka.timeline.metrics.port", "{{metric_collector_port}}");
    }
  };
  Map<String, String> newProperties = new HashMap<String, String>() {
    {
      put("kafka.timeline.metrics.port", "{{metric_collector_port}}");
    }
  };
  EasyMockSupport easyMockSupport = new EasyMockSupport();
  Config mockKafkaBroker = easyMockSupport.createNiceMock(Config.class);
  reset(clusters, cluster);
  expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
    put("normal", cluster);
  }}).once();
  expect(cluster.getDesiredConfigByType("kafka-broker")).andReturn(mockKafkaBroker).atLeastOnce();
  expect(mockKafkaBroker.getProperties()).andReturn(oldProperties).anyTimes();
  replay(clusters, mockKafkaBroker, 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).updateKafkaConfigs();
  easyMockSupport.verifyAll();
  Map<String, String> updatedProperties = propertiesCapture.getValue();
  assertTrue(Maps.difference(newProperties, updatedProperties).areEqual());
}