@Test (groups = { "TestClouderaManagerImpl" }, dependsOnMethods = { "testStartStoppedCluster" })
public void testStopClusterGotException() {
setupMocks();
blueprint.getHadoopStack().setDistro("CDH-5.0.1");
ClustersResourceV6 resourceV6 = Mockito.mock(FakeClustersResource.class);
Mockito.when(resourceV6.stopCommand(blueprint.getName())).thenThrow(
SoftwareManagementPluginException.STOP_CLUSTER_FAILED(null, null, blueprint.getName()));
ServicesResourceV6 servicesResourceV6 = Mockito.mock(ServicesResourceV6.class);
List<ApiService> serviceList = new ArrayList<>();
ApiService hdfs = new ApiService();
hdfs.setName("HDFS");
hdfs.setServiceState(ApiServiceState.STARTED);
serviceList.add(hdfs);
ApiServiceList apiServiceList = new ApiServiceList();
apiServiceList.setServices(serviceList);
Mockito.when(servicesResourceV6.readServices((DataView) anyObject())).thenReturn(apiServiceList);
List<ApiRole> roleList = new ArrayList<>();
ApiRole role = new ApiRole();
role.setName("NAMENODE");
role.setRoleState(ApiRoleState.STARTED);
role.setType(role.getName());
ApiHostRef hostRef = new ApiHostRef("host1");
role.setHostRef(hostRef);
roleList.add(role);
RolesResourceV6 rolesResourceV6 = new FakeRolesResource(roleList);
Mockito.when(servicesResourceV6.getRolesResource(hdfs.getName())).thenReturn(rolesResourceV6);
Mockito.when(resourceV6.getServicesResource(blueprint.getName())).thenReturn(servicesResourceV6);
ApiClusterList apiClusterList = new ApiClusterList();
ApiCluster apiCluster = new ApiCluster();
apiCluster.setName(blueprint.getName());
apiClusterList.add(apiCluster);
Mockito.when(resourceV6.readClusters((DataView) anyObject())).thenReturn(apiClusterList);
RootResourceV6 fakeRootResourceV6 = Mockito.mock(FakeRootResource.class);
Mockito.when(fakeRootResourceV6.getClustersResource()).thenReturn(resourceV6);
FakeHostsResource fakeHostsResource = Mockito.mock(FakeHostsResource.class);