@Test
public void testAction() throws Exception {

  Map<String, String> commandParams = new HashMap<String, String>();
  commandParams.put("clusterName", "c1");
  ExecutionCommand executionCommand = new ExecutionCommand();
  executionCommand.setCommandParams(commandParams);
  executionCommand.setClusterName("c1");
  HostRoleCommand hrc = EasyMock.createMock(HostRoleCommand.class);
  expect(hrc.getRequestId()).andReturn(1L).anyTimes();
  expect(hrc.getStageId()).andReturn(2L).anyTimes();
  expect(hrc.getExecutionCommandWrapper()).andReturn(new ExecutionCommandWrapper(executionCommand)).anyTimes();
  replay(hrc);
  RangerConfigCalculation action = new RangerConfigCalculation();
  m_clusterField.set(action, m_clusters);
  action.setExecutionCommand(executionCommand);
  action.setHostRoleCommand(hrc);
  CommandReport report = action.execute(null);
  assertNotNull(report);
  Cluster c = m_clusters.getCluster("c1");
  Config config = c.getDesiredConfigByType("ranger-admin-site");
  Map<String, String> map = config.getProperties();
  assertTrue(map.containsKey("ranger.jpa.jdbc.driver"));
  assertTrue(map.containsKey("ranger.jpa.jdbc.url"));
  assertTrue(map.containsKey("ranger.jpa.jdbc.dialect"));
  assertTrue(map.containsKey("ranger.jpa.audit.jdbc.driver"));
  assertTrue(map.containsKey("ranger.jpa.audit.jdbc.url"));
  assertTrue(map.containsKey("ranger.jpa.audit.jdbc.dialect"));
  assertEquals("com.mysql.jdbc.Driver", map.get("ranger.jpa.jdbc.driver"));
  assertEquals("jdbc:mysql://host1/ranger", map.get("ranger.jpa.jdbc.url"));
  assertEquals("org.eclipse.persistence.platform.database.MySQLPlatform", map.get("ranger.jpa.jdbc.dialect"));
  assertEquals("com.mysql.jdbc.Driver", map.get("ranger.jpa.audit.jdbc.driver"));
  assertEquals("jdbc:mysql://host1/ranger_audit", map.get("ranger.jpa.audit.jdbc.url"));
  assertEquals("org.eclipse.persistence.platform.database.MySQLPlatform", map.get("ranger.jpa.audit.jdbc.dialect"));
  config = c.getDesiredConfigByType("ranger-env");
  map = config.getProperties();
  assertEquals("jdbc:mysql://host1", map.get("ranger_privelege_user_jdbc_url"));
  config = c.getDesiredConfigByType("admin-properties");
  config.getProperties().put("DB_FLAVOR", "oracle");
  report = action.execute(null);
  assertNotNull(report);
  config = c.getDesiredConfigByType("ranger-admin-site");
  map = config.getProperties();
  assertEquals("oracle.jdbc.OracleDriver", map.get("ranger.jpa.jdbc.driver"));
  assertEquals("jdbc:oracle:thin:@//host1", map.get("ranger.jpa.jdbc.url"));
  assertEquals("org.eclipse.persistence.platform.database.OraclePlatform", map.get("ranger.jpa.jdbc.dialect"));
  assertEquals("oracle.jdbc.OracleDriver", map.get("ranger.jpa.audit.jdbc.driver"));
  assertEquals("jdbc:oracle:thin:@//host1", map.get("ranger.jpa.audit.jdbc.url"));
  assertEquals("org.eclipse.persistence.platform.database.OraclePlatform", map.get("ranger.jpa.audit.jdbc.dialect"));
  config = c.getDesiredConfigByType("ranger-env");
  map = config.getProperties();
  assertEquals("jdbc:oracle:thin:@//host1", map.get("ranger_privelege_user_jdbc_url"));
}