ClouderaManagerImpl extends AbstractSoftwareManager implements SoftwareManager { private String getSummaryErrorMsg(ApiCommand command, String domain) { ApiCommand newCommand = apiResourceRootV6.getCommandsResource().readCommand(command.getId()); StringBuilder errorMsg = new StringBuilder(newCommand.getResultMessage()); if (errorMsg.length() > 0) { errorMsg.append(". "); } if (newCommand.getResultDataUrl() != null) { errorMsg = errorMsg.append(referCmfUrlMsg(newCommand.getResultDataUrl())); } else { errorMsg = errorMsg.append(referCmfUrlMsg(domain + "/cmf/command/" + newCommand.getId() + "/details")); } return errorMsg.toString(); } ClouderaManagerImpl();  ClouderaManagerImpl(String cmServerHost, int port, String user,
         String password, String privateKey);  ClouderaManagerImpl(URL url, String user, String password,
         String privateKey); RootResourceV6 getApiResourceRootV6(); @Override boolean validateServerVersion(); @Override String getName(); @Override String getDescription(); @Override String getType(); @Override List<HadoopStack> getSupportedStacks(); @Override String getSupportedConfigs(HadoopStack hadoopStack); @Override boolean validateBlueprint(ClusterBlueprint blueprint); @Override boolean createCluster(ClusterBlueprint blueprint,
         ClusterReportQueue reportQueue); @Override /** * @TODO better use a event-listener mode to decouple the reportQueue. lixl */ boolean reconfigCluster(ClusterBlueprint blueprint,
         ClusterReportQueue reportQueue); @Override boolean scaleOutCluster(ClusterBlueprint blueprint, List<String> addedNodeNames,
         ClusterReportQueue reportQueue, boolean forceScaleOut); @Override boolean deleteCluster(ClusterBlueprint clusterBlueprint,
         ClusterReportQueue reports); @Override boolean onStopCluster(ClusterBlueprint clusterBlueprint,
         ClusterReportQueue reportQueue); @Override boolean onDeleteCluster(ClusterBlueprint clusterBlueprint,
         ClusterReportQueue reports); @Override boolean onDeleteNodes(ClusterBlueprint blueprint, List<String> nodeNames); @Override boolean decomissionNodes(String clusterName, List<NodeInfo> nodes,
         ClusterReportQueue reports); @Override void decommissionNode(ClusterBlueprint blueprint, String nodeGroupName, String nodeName, ClusterReportQueue reportQueue); @Override boolean recomissionNode(String clusterName, NodeInfo node, ClusterReportQueue reportQueue); @Override boolean comissionNodes(String clusterName, List<NodeInfo> nodes,
         ClusterReportQueue reports); @Override boolean startNodes(String clusterName, List<NodeInfo> nodes,
         ClusterReportQueue reports); @Override boolean stopNodes(String clusterName, List<NodeInfo> nodes,
         ClusterReportQueue reports); @Override String exportBlueprint(String clusterName); @Override ClusterReport queryClusterStatus(ClusterBlueprint blueprint); @Override boolean echo(); @Override HealthStatus getStatus(); boolean startCluster(ClusterBlueprint clusterBlueprint, ClusterReportQueue reportQueue); @Override boolean startCluster(ClusterBlueprint clusterBlueprint, ClusterReportQueue reportQueue, boolean forceStart); String getCmServerHostId(); @Override List<String> validateRolesForScaleOut(NodeGroupInfo group); void validateRolesForShrink(NodeGroupInfo groupInfo); @Override void updateInfrastructure(ClusterBlueprint blueprint); @Override boolean hasHbase(ClusterBlueprint blueprint); @Override boolean hasMgmtRole(List<String> roles); @Override boolean isComputeOnlyRoles(List<String> roles); @Override boolean twoDataDisksRequired(NodeGroupInfo group); @Override boolean hasComputeMasterGroup(ClusterBlueprint blueprint); @Override String getVersion(); @Override HadoopStack getDefaultStack(); @Override boolean hasMountPointStartwithDatax(String clusterName); @Override void restartClusterRequiredServices(ClusterBlueprint blueprint,
         ClusterReportQueue reports); final String MIN_SUPPORTED_VERSION; }
@Test (groups = { "TestClouderaManagerImpl" }) public void testGetSummaryErrorMsg() { Method method = null; try { method = ClouderaManagerImpl.class.getDeclaredMethod("getSummaryErrorMsg", ApiCommand.class, String.class); method.setAccessible(true); ApiCommand apiCommand = new ApiCommand(); apiCommand.setId(new Long(1)); CommandsResource fakeCommandResource = new CommandsResource() { @Override public ApiCommand readCommand(long commandId) { ApiCommand command = new ApiCommand(); command.setId(new Long(1)); command.setResultMessage("TestGetSummaryErrorMsg"); return command; } @Override public ApiCommand abortCommand(long commandId) { return null; } }; RootResourceV6 mockRootResourceV6 = Mockito.mock(RootResourceV6.class); Mockito.when(mockRootResourceV6.getCommandsResource()).thenReturn(fakeCommandResource); Mockito.when(apiRootResource.getRootV6()).thenReturn(mockRootResourceV6); ClouderaManagerImpl localProvider = new ClouderaManagerImpl("127.0.0.1", 7180, "admin", "admin", "RSA_CERT"); Object errMsg = method.invoke(localProvider, apiCommand, "http: Assert.assertTrue(errMsg instanceof String); Assert.assertEquals(errMsg, "TestGetSummaryErrorMsg. Please refer to http: } catch (NoSuchMethodException e) { Assert.assertTrue(false); } catch (InvocationTargetException e) { Assert.assertTrue(false); } catch (IllegalAccessException e) { Assert.assertTrue(false); } finally { if (method != null) { method.setAccessible(false); } Mockito.when(apiRootResource.getRootV6()).thenReturn(rootResourceV6); } }