### Question:
StackResponseUtils { public String getRoleConfigNameForHostGroup(StackV4Response stackResponse, String hostGroupName, String serviceType, String roleType) throws Exception { String template = stackResponse.getCluster().getBlueprint().getBlueprint(); ApiClusterTemplate cmTemplate = JsonUtil.readValue(template, ApiClusterTemplate.class); Set<String> hostGroupRoleConfigNames = cmTemplate.getHostTemplates().stream() .filter(clusterTemplate -> clusterTemplate.getRefName().equalsIgnoreCase(hostGroupName)) .findFirst().map(ApiClusterTemplateHostTemplate::getRoleConfigGroupsRefNames).orElse(List.of()) .stream() .collect(Collectors.toSet()); String roleReferenceName = cmTemplate.getServices().stream() .filter(s -> s.getServiceType().equalsIgnoreCase(serviceType)) .findFirst() .map(ApiClusterTemplateService::getRoleConfigGroups).orElse(List.of()) .stream() .filter(rcg -> rcg.getRoleType().equalsIgnoreCase(roleType)) .filter(rcg -> hostGroupRoleConfigNames.contains(rcg.getRefName())) .map(ApiClusterTemplateRoleConfigGroup::getRefName) .findFirst() .orElseThrow( () -> new Exception(String.format("Unable to retrieve RoleConfigGroupRefName for Service '%s', RoleType '%s'," + " HostGroup '%s', Cluster '%s'", serviceType, roleType, hostGroupName, stackResponse.getCrn()))); return roleReferenceName; }  Optional<InstanceMetaDataV4Response> getNotTerminatedPrimaryGateways(StackV4Response stackResponse); Map<String, String> getCloudInstanceIdsForHostGroup(StackV4Response stackResponse, String hostGroup); Integer getNodeCountForHostGroup(StackV4Response stackResponse, String hostGroup); String getRoleConfigNameForHostGroup(StackV4Response stackResponse, String hostGroupName, String serviceType, String roleType);  }### Answer:
@Test public void testGetRoleConfigNameForHostGroup() throws Exception { validateGetRoleConfigNameForHostGroup("YARN", "NODEMANAGER", "compute", "yarn-NODEMANAGER-COMPUTE"); validateGetRoleConfigNameForHostGroup("YARN", "NODEMANAGER", "worker", "yarn-NODEMANAGER-WORKER"); validateGetRoleConfigNameForHostGroup("YARN", "NODEMANAGER", "randomHostGroup", "random-NODEMANAGER-BASE"); }