### Question:
FinalizeKerberosServerAction extends KerberosServerAction { @Override public CommandReport execute(ConcurrentMap<String, Object> requestSharedDataContext) throws AmbariException, InterruptedException { String dataDirectoryPath = getCommandParameterValue(DATA_DIRECTORY); if(getKDCType(getCommandParameters()) != KDCType.NONE) { requestSharedDataContext.put(this.getClass().getName() + "_visited", new HashSet<String>()); processIdentities(requestSharedDataContext); requestSharedDataContext.remove(this.getClass().getName() + "_visited"); } deleteDataDirectory(dataDirectoryPath); return sendTopologyUpdateEvent(); } @Inject  FinalizeKerberosServerAction(TopologyHolder topologyHolder); @Override CommandReport execute(ConcurrentMap<String, Object> requestSharedDataContext);  }### Answer:
@Test @Ignore("Update accordingly to changes") public void executeMITKDCOption() throws Exception { String clusterName = "c1"; String clusterId = "1"; Injector injector = setup(clusterName); File dataDirectory = createDataDirectory(); Map<String, String> commandParams = new HashMap<>(); commandParams.put(KerberosServerAction.KDC_TYPE, KDCType.MIT_KDC.name()); commandParams.put(KerberosServerAction.DATA_DIRECTORY, dataDirectory.getAbsolutePath()); ExecutionCommand executionCommand = createMockExecutionCommand(clusterId, clusterName, commandParams); HostRoleCommand hostRoleCommand = createMockHostRoleCommand(); PrincipalKeyCredential principleKeyCredential = createMock(PrincipalKeyCredential.class); KerberosHelper kerberosHelper = injector.getInstance(KerberosHelper.class); expect(kerberosHelper.getKDCAdministratorCredentials(clusterName)).andReturn(principleKeyCredential).anyTimes(); replayAll(); ConcurrentMap<String, Object> requestSharedDataContext = new ConcurrentHashMap<>(); FinalizeKerberosServerAction action = new FinalizeKerberosServerAction(topologyHolder); action.setExecutionCommand(executionCommand); action.setHostRoleCommand(hostRoleCommand); Assert.assertTrue(dataDirectory.exists()); CommandReport commandReport = action.execute(requestSharedDataContext); assertSuccess(commandReport); Assert.assertTrue(!dataDirectory.exists()); verifyAll(); }
@Test public void executeManualOption() throws Exception { String clusterName = "c1"; String clusterId = "1"; Injector injector = setup(clusterName); File dataDirectory = createDataDirectory(); Map<String, String> commandParams = new HashMap<>(); commandParams.put(KerberosServerAction.DATA_DIRECTORY, dataDirectory.getAbsolutePath()); ExecutionCommand executionCommand = createMockExecutionCommand(clusterId, clusterName, commandParams); HostRoleCommand hostRoleCommand = createMockHostRoleCommand(); replayAll(); ConcurrentMap<String, Object> requestSharedDataContext = new ConcurrentHashMap<>(); FinalizeKerberosServerAction action = new FinalizeKerberosServerAction(topologyHolder); action.setExecutionCommand(executionCommand); action.setHostRoleCommand(hostRoleCommand); Assert.assertTrue(dataDirectory.exists()); CommandReport commandReport = action.execute(requestSharedDataContext); assertSuccess(commandReport); Assert.assertTrue(!dataDirectory.exists()); verifyAll(); }