@Test
public void testUpdateHiveConfigs() 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 ServiceConfigVersionResponse mockServiceConfigVersionResponse = easyMockSupport.createNiceMock(ServiceConfigVersionResponse.class);
  final Config mockHiveEnv = easyMockSupport.createNiceMock(Config.class);
  final Config mockHiveServerSite = easyMockSupport.createNiceMock(Config.class);
  final Config mockHiveSite = easyMockSupport.createNiceMock(Config.class);
  final Map<String, String> propertiesExpectedHiveEnv = new HashMap<String, String>() {{
    put("hive_security_authorization", "none");
  }};
  final Map<String, String> propertiesExpectedHiveSite = new HashMap<String, String>() {{
    put("hive.server2.authentication", "pam");
    put("hive.server2.custom.authentication.class", "");
  }};
  final Map<String, String> propertiesExpectedHiveServerSite = new HashMap<String, String>() {{
    put("hive.security.authorization.manager", "");
    put("hive.security.authenticator.manager", "");
  }};
  final Map<String, Service> servicesExpected = new HashMap<String, Service>();
  final Injector mockInjector = Guice.createInjector(new AbstractModule() {
    @Override
    protected void configure() {
      bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
      bind(ConfigHelper.class).toInstance(mockConfigHelper);
      bind(Clusters.class).toInstance(mockClusters);
      bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
      bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
    }
  });
  expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
  expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
    put("normal", mockClusterExpected);
  }}).once();
  Capture<String> configTypeEnv = EasyMock.newCapture();
  Capture<String> configTypeSite = EasyMock.newCapture();
  Capture<String> configTypeServerSite = EasyMock.newCapture();
  expect(mockClusterExpected.getDesiredConfigByType("hive-env")).andReturn(mockHiveEnv).atLeastOnce();
  expect(mockClusterExpected.getDesiredConfigByType("hiveserver2-site")).andReturn(mockHiveServerSite).atLeastOnce();
  expect(mockHiveEnv.getProperties()).andReturn(propertiesExpectedHiveEnv).anyTimes();
  expect(mockHiveServerSite.getProperties()).andReturn(propertiesExpectedHiveServerSite).anyTimes();
  expect(mockClusterExpected.getConfig(capture(configTypeEnv), anyObject(String.class))).andReturn(mockHiveEnv).once();
  expect(mockClusterExpected.getConfig(capture(configTypeServerSite), anyObject(String.class))).andReturn(mockHiveServerSite).once();
  expect(mockClusterExpected.addDesiredConfig("ambari-upgrade", Collections.singleton(mockHiveEnv), "Updated hive-env during Ambari Upgrade from 2.0.0 to 2.1.0.")).andReturn(mockServiceConfigVersionResponse).once();
  expect(mockClusterExpected.addDesiredConfig("ambari-upgrade", Collections.singleton(mockHiveServerSite), "Updated hiveserver2-site during Ambari Upgrade from 2.0.0 to 2.1.0.")).andReturn(mockServiceConfigVersionResponse).once();
  expect(mockClusterExpected.getDesiredConfigByType("hive-site")).andReturn(mockHiveSite).atLeastOnce();
  expect(mockHiveSite.getProperties()).andReturn(propertiesExpectedHiveSite).anyTimes();
  expect(mockClusterExpected.getServices()).andReturn(servicesExpected).once();
  expect(mockClusterExpected.getConfig(capture(configTypeSite), anyObject(String.class))).andReturn(mockHiveSite).once();
  expect(mockClusterExpected.addDesiredConfig("ambari-upgrade", Collections.singleton(mockHiveSite), "Updated hive-site during Ambari Upgrade from 2.0.0 to 2.1.0.")).andReturn(mockServiceConfigVersionResponse).once();
  easyMockSupport.replayAll();
  mockInjector.getInstance(UpgradeCatalog210.class).updateHiveConfigs();
  easyMockSupport.verifyAll();
  assertEquals("hive-env", configTypeEnv.getValue());
  assertEquals("hive-site", configTypeSite.getValue());
  assertEquals("hiveserver2-site", configTypeServerSite.getValue());
}