### Question:
ClouderaManagerRoleRefreshService { void refreshClusterRoles(ApiClient client, Stack stack) throws ApiException, CloudbreakException { waitForGenerateCredentialsToFinish(stack, client); ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(client); ApiCommand refreshCommand = clustersResourceApi.refresh(stack.getCluster().getName()); LOGGER.debug("Cluster role refresh has been started."); pollingRefresh(refreshCommand, client, stack); LOGGER.debug("Cluster role refresh finished successfully."); }    }### Answer:
@Test public void testRestartClusterRolesShouldUpdateTheRoles() throws ApiException, CloudbreakException { ApiClient apiClient = mock(ApiClient.class); Stack stack = createStack(); ClustersResourceApi clustersResourceApi = mock(ClustersResourceApi.class); ClouderaManagerResourceApi clouderaManagerResourceApi = mock(ClouderaManagerResourceApi.class); ApiCommand apiCommand = createApiCommand(); ApiCommandList apiCommandList = createApiCommandList(); when(clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient)).thenReturn(clouderaManagerResourceApi); when(clouderaManagerResourceApi.listActiveCommands(DataView.SUMMARY.name())).thenReturn(apiCommandList); when(clouderaManagerApiFactory.getClustersResourceApi(apiClient)).thenReturn(clustersResourceApi); when(clustersResourceApi.refresh(CLUSTER_NAME)).thenReturn(apiCommand); when(clouderaManagerPollingServiceProvider.startPollingCmConfigurationRefresh(stack, apiClient, COMMAND_ID)).thenReturn(PollingResult.SUCCESS); underTest.refreshClusterRoles(apiClient, stack); verify(clouderaManagerPollingServiceProvider).startPollingCmConfigurationRefresh(stack, apiClient, COMMAND_ID); verify(clustersResourceApi).refresh(CLUSTER_NAME); verify(clouderaManagerPollingServiceProvider).startPollingCmConfigurationRefresh(stack, apiClient, COMMAND_ID); }