@Test
public void testUpdateRangerHiveConfigs() 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 mockRangerPlugin = easyMockSupport.createNiceMock(Config.class);
  final Config mockHiveEnv = easyMockSupport.createNiceMock(Config.class);
  final Config mockHiveServer = easyMockSupport.createNiceMock(Config.class);
  final Map<String, String> propertiesExpectedRangerPlugin = new HashMap<String, String>();
  propertiesExpectedRangerPlugin.put("ranger-hive-plugin-enabled", "yes");
  final Map<String, String> propertiesExpectedHiveEnv = new HashMap<String, String>();
  final Map<String, String> propertiesExpectedHiveServer2 = new HashMap<String, String>();
  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();
  expect(mockClusterExpected.getDesiredConfigByType("ranger-hive-plugin-properties")).andReturn(mockRangerPlugin).atLeastOnce();
  expect(mockClusterExpected.getDesiredConfigByType("hive-env")).andReturn(mockHiveEnv).atLeastOnce();
  expect(mockClusterExpected.getDesiredConfigByType("hiveserver2-site")).andReturn(mockHiveServer).atLeastOnce();
  expect(mockRangerPlugin.getProperties()).andReturn(propertiesExpectedRangerPlugin).anyTimes();
  expect(mockHiveEnv.getProperties()).andReturn(propertiesExpectedHiveEnv).anyTimes();
  expect(mockHiveServer.getProperties()).andReturn(propertiesExpectedHiveServer2).anyTimes();
  ServiceConfigVersionResponse r = null;
  expect(mockClusterExpected.getConfig(anyObject(String.class), anyObject(String.class))).
      andReturn(mockHiveServer).anyTimes();
  expect(mockClusterExpected.addDesiredConfig("ambari-upgrade", Collections.singleton(mockHiveServer), "Updated hive-env during Ambari Upgrade from 2.0.0 to 2.1.0.")).
      andReturn(r).times(1);
  expect(mockClusterExpected.addDesiredConfig("ambari-upgrade", Collections.singleton(mockHiveServer), "Updated hiveserver2-site during Ambari Upgrade from 2.0.0 to 2.1.0.")).
      andReturn(r).times(1);
  expect(mockClusterExpected.addDesiredConfig("ambari-upgrade", Collections.singleton(mockHiveServer), "Updated ranger-hive-plugin-properties during Ambari Upgrade from 2.0.0 to 2.1.0.")).
      andReturn(r).times(1);
  easyMockSupport.replayAll();
  mockInjector.getInstance(UpgradeCatalog210.class).updateRangerHiveConfigs();
  easyMockSupport.verifyAll();
}