### Question:
ClouderaManagerModificationService implements ClusterModificationService { @VisibleForTesting void pollDeployConfig(ApiCommand restartCommand) throws CloudbreakException { PollingResult hostTemplatePollingResult = clouderaManagerPollingServiceProvider.startPollingCmClientConfigDeployment( stack, apiClient, restartCommand.getId()); if (isExited(hostTemplatePollingResult)) { throw new CancellationException("Cluster was terminated while waiting for config deploy"); } else if (isTimeout(hostTemplatePollingResult)) { throw new CloudbreakException("Timeout while Cloudera Manager was config deploying services."); } } ClouderaManagerModificationService(Stack stack, HttpClientConfig clientConfig); @PostConstruct void initApiClient(); @Override List<String> upscaleCluster(HostGroup hostGroup, Collection<InstanceMetaData> instanceMetaDatas); @Override void cleanupCluster(Telemetry telemetry); @Override void upgradeClusterRuntime(Set<ClusterComponent> components, boolean patchUpgrade); void restartStaleServices(MgmtServiceResourceApi mgmtServiceResourceApi, ClustersResourceApi clustersResourceApi); @Override void stopCluster(boolean disableKnoxAutorestart); @Override int startCluster(Set<InstanceMetaData> hostsInCluster); @Override Map<String, String> getComponentsByCategory(String blueprintName, String hostGroupName); @Override String getStackRepositoryJson(StackRepoDetails repoDetails, String stackRepoId); @Override Map<String, String> gatherInstalledParcels(String stackName); @Override void removeUnusedParcels(Set<ClusterComponent> usedParcelComponents); @Override void restartAll();  }### Answer:
@Test void testPollDeployConfigWhenCancelled() { ApiCommand apiCommand = new ApiCommand(); when(clouderaManagerPollingServiceProvider.startPollingCmClientConfigDeployment(any(), any(), any())).thenReturn(PollingResult.EXIT); CancellationException actual = assertThrows(CancellationException.class, () -> underTest.pollDeployConfig(apiCommand)); assertEquals("Cluster was terminated while waiting for config deploy", actual.getMessage()); }
@Test void testPollDeployConfigWhenTimeout() { ApiCommand apiCommand = new ApiCommand(); when(clouderaManagerPollingServiceProvider.startPollingCmClientConfigDeployment(any(), any(), any())).thenReturn(PollingResult.TIMEOUT); CloudbreakException actual = assertThrows(CloudbreakException.class, () -> underTest.pollDeployConfig(apiCommand)); assertEquals("Timeout while Cloudera Manager was config deploying services.", actual.getMessage()); }