class CmHostGroupRoleConfigProviderProcessor {

    @VisibleForTesting
    Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) {
        Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>();
        Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity()));
        List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor);
        Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents();

        for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) {
            String hostGroupName = hostTemplate.getRefName();
            List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of);
            HostgroupView hostgroupView = hostGroups.get(hostGroupName);
            groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView);
        }
        return configsByRoleConfigGroup;
    }

}