ClusterRead implements Comparable<ClusterRead> { public NodeGroupRead getNodeGroupByName(String nodeGroupName) { List<NodeGroupRead> nodeGroups = this.getNodeGroups(); if (nodeGroups != null) { for (NodeGroupRead ng : nodeGroups) { if (ng.getName().equals(nodeGroupName)) { return ng; } } } return null; } ClusterRead();  ClusterRead(String name, String distro, int instanceNum,
         ClusterStatus status); String getName(); void setName(String name); void setVersion(String version); String getVersion(); String getExternalHDFS(); void setExternalHDFS(String externalHDFS); String getAppManager(); void setAppManager(String appManager); String getExternalMapReduce(); void setExternalMapReduce(String externalMapReduce); String getDistro(); void setDistro(String distro); String getDistroVendor(); void setDistroVendor(String distroVendor); TopologyType getTopologyPolicy(); void setTopologyPolicy(TopologyType topologyPolicy); int getInstanceNum(); void setInstanceNum(int instanceNum); ClusterStatus getStatus(); void setStatus(ClusterStatus status); Priority getIoShares(); void setIoShares(Priority ioShares); List<NodeGroupRead> getNodeGroups(); NodeGroupRead getNodeGroupByName(String nodeGroupName); void setNodeGroups(List<NodeGroupRead> nodeGroups); List<ResourcePoolRead> getResourcePools(); void setResourcePools(List<ResourcePoolRead> resourcePools); boolean validateSetManualElasticity(List<String>... nodeGroupNames); int retrieveComputeNodeNum(); @Override int compareTo(ClusterRead cluster); Boolean getAutomationEnable(); void setAutomationEnable(Boolean automationEnable); String retrieveVhmMinNum(); int getVhmMinNum(); void setVhmMinNum(int vhmMinNum); String retrieveVhmMaxNum(); int getVhmMaxNum(); void setVhmMaxNum(int vhmMaxNum); String retrieveVhmTargetNum(); Integer getVhmTargetNum(); void setVhmTargetNum(Integer vhmTargetNum); boolean needAsyncUpdateParam(ElasticityRequestBody requestBody); boolean isDcSeperation(); void setDcSeperation(boolean dcSeperation); boolean validateSetParamParameters(Integer targetComputeNodeNum,
         Integer minComputeNodeNum, Integer maxComputeNodeNum); String getLocalRepoURL(); void setLocalRepoURL(String localRepoURL); String getExternalNamenode(); void setExternalNamenode(String externalNamenode); String getExternalSecondaryNamenode(); void setExternalSecondaryNamenode(String externalSecondaryNamenode); Set<String> getExternalDatanodes(); void setExternalDatanodes(Set<String> externalDatanodes); Map<String, Map<String, String>> getInfrastructure_config(); void setInfrastructure_config(Map<String, Map<String, String>> infrastructure_config); String getClusterCloneType(); void setClusterCloneType(String clusterCloneType); String getTemplateName(); void setTemplateName(String templateName);  }
@Test public void testGetNodeGroupByName() { ClusterRead cluster = new ClusterRead(); assertEquals(null, cluster.getNodeGroupByName("master")); NodeGroupRead master = new NodeGroupRead(); master.setName("master"); NodeGroupRead client = new NodeGroupRead(); client.setName("client"); cluster.setNodeGroups(Arrays.asList(master, client)); assertEquals(master, cluster.getNodeGroupByName("master")); }