@Test
public void testUpdateKAFKAConfigs() throws Exception{

  EasyMockSupport easyMockSupport = new EasyMockSupport();
  final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
  final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
  final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
  final Config kafkaBroker = easyMockSupport.createNiceMock(Config.class);
  expect(kafkaBroker.getProperties()).andReturn(new HashMap<String, String>(){{
    put("listeners", "PLAINTEXT://localhost:6667,SSL://localhost:6666");
  }}
  ).anyTimes();
  final Injector mockInjector = Guice.createInjector(new AbstractModule() {
    @Override
    protected void configure() {
      bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
      bind(Clusters.class).toInstance(mockClusters);
      bind(EntityManager.class).toInstance(entityManager);
      bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
      bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
      bind(PasswordEncoder.class).toInstance(createNiceMock(PasswordEncoder.class));
      bind(HookContextFactory.class).toInstance(createMock(HookContextFactory.class));
      bind(HookService.class).toInstance(createMock(HookService.class));
    }
  });
  expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
  expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
    put("normal", mockClusterExpected);
  }}).atLeastOnce();
  expect(mockClusterExpected.getDesiredConfigByType("kafka-broker")).andReturn(kafkaBroker).atLeastOnce();
  expect(mockClusterExpected.getSecurityType()).andReturn(SecurityType.KERBEROS);
  expect(mockClusterExpected.getServices()).andReturn(new HashMap<String, Service>() {
    {
      put("KAFKA", null);
    }
  }).atLeastOnce();
  UpgradeCatalog240 upgradeCatalog240 = createMockBuilder(UpgradeCatalog240.class)
          .withConstructor(Injector.class)
          .withArgs(mockInjector)
          .addMockedMethod("updateConfigurationProperties", String.class,
                  Map.class, boolean.class, boolean.class)
          .createMock();
  Map<String, String> expectedUpdates = new HashMap<>();
  expectedUpdates.put("listeners", "PLAINTEXTSASL://localhost:6667,SSL://localhost:6666");
  upgradeCatalog240.updateConfigurationProperties("kafka-broker", expectedUpdates,
          true, false);
  expectLastCall().once();
  easyMockSupport.replayAll();
  replay(upgradeCatalog240);
  upgradeCatalog240.updateKAFKAConfigs();
  easyMockSupport.verifyAll();
}