@Test
public void testRemoveHiveOozieDBConnectionConfigs() throws Exception{

  EasyMockSupport easyMockSupport = new EasyMockSupport();
  final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(
          AmbariManagementController.class);
  final ConfigHelper mockConfigHelper = easyMockSupport.createMock(ConfigHelper.class);
  final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
  final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
  final Config mockOozieEnv = easyMockSupport.createNiceMock(Config.class);
  final Config mockHiveEnv = easyMockSupport.createNiceMock(Config.class);
  final Map<String, String> propertiesExpectedOozieEnv = new HashMap<String, String>();
  propertiesExpectedOozieEnv.put("oozie_derby_database", "Derby");
  propertiesExpectedOozieEnv.put("property", "value");
  // Imitate missing property
  // propertiesExpectedOozieEnv.put("oozie_hostname", "hostname");
  final Map<String, String> propertiesExpectedHiveEnv = new HashMap<String, String>();
  propertiesExpectedHiveEnv.put("hive_hostname", "hostname");
  final Injector mockInjector = Guice.createInjector(new Module() {
    @Override
    public void configure(Binder binder) {
      binder.bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
      binder.bind(ConfigHelper.class).toInstance(mockConfigHelper);
      binder.bind(Clusters.class).toInstance(mockClusters);
      binder.bind(EntityManager.class).toInstance(entityManager);
      binder.bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
      binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
      binder.bind(PasswordEncoder.class).toInstance(createNiceMock(PasswordEncoder.class));
      binder.bind(HookContextFactory.class).toInstance(createMock(HookContextFactory.class));
      binder.bind(HookService.class).toInstance(createMock(HookService.class));
    }
  });
  expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
  expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
    put("normal", mockClusterExpected);
  }}).once();
  expect(mockClusterExpected.getDesiredConfigByType("oozie-env")).andReturn(mockOozieEnv).atLeastOnce();
  expect(mockClusterExpected.getDesiredConfigByType("hive-env")).andReturn(mockHiveEnv).atLeastOnce();
  expect(mockOozieEnv.getProperties()).andReturn(propertiesExpectedOozieEnv).anyTimes();
  expect(mockHiveEnv.getProperties()).andReturn(propertiesExpectedHiveEnv).anyTimes();
  Capture<Map<String, String>> oozieCapture =  newCapture();
  Capture<Map<String, String>> hiveCapture =  newCapture();
  expect(mockAmbariManagementController.createConfig(eq(mockClusterExpected), eq("oozie-env"),
      capture(oozieCapture), anyString(), EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(null).once();
  expect(mockAmbariManagementController.createConfig(eq(mockClusterExpected), eq("hive-env"),
          capture(hiveCapture), anyString(), EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(null).once();
  easyMockSupport.replayAll();
  mockInjector.getInstance(UpgradeCatalog240.class).removeHiveOozieDBConnectionConfigs();
  easyMockSupport.verifyAll();
  assertEquals("value", oozieCapture.getValue().get("property"));
  assertNull(oozieCapture.getValue().get("oozie_derby_database"));
  assertNull(oozieCapture.getValue().get("oozie_hostname"));
  assertNull(hiveCapture.getValue().get("hive_hostname"));
}