### Question:
HdfsRoleConfigProvider extends AbstractRoleConfigProvider { @Override protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) { switch (roleType) { case HdfsRoles.DATANODE: return List.of( config(FAILED_VOLUMES_TOLERATED, NUM_FAILED_VOLUMES_TOLERATED.toString()) ); case HdfsRoles.NAMENODE: if (isNamenodeHA(source)) { return List.of( config("autofailover_enabled", "true"), config("dfs_federation_namenode_nameservice", DEFAULT_NAME_SERVICE), config("dfs_namenode_quorum_journal_name", DEFAULT_NAME_SERVICE) ); } return List.of(); default: return List.of(); } }  @Override String getServiceType(); @Override List<String> getRoleTypes(); static boolean isNamenodeHA(TemplatePreparationObject source); static Set<String> nameNodeFQDNs(TemplatePreparationObject source); static final String DEFAULT_NAME_SERVICE; }### Answer:
@Test void nameNodeHA() { HostgroupView gateway = new HostgroupView("gateway", 1, InstanceGroupType.GATEWAY, 1); HostgroupView master = new HostgroupView("master", 0, InstanceGroupType.CORE, 2); HostgroupView quorum = new HostgroupView("quorum", 0, InstanceGroupType.CORE, 3); HostgroupView worker = new HostgroupView("worker", 0, InstanceGroupType.CORE, 3); String inputJson = FileReaderUtils.readFileFromClasspathQuietly("input/namenode-ha.bp"); CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson); TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder() .withHostgroupViews(Set.of(gateway, master, quorum, worker)) .withBlueprintView(new BlueprintView(inputJson, "CDP", "1.0", cmTemplateProcessor)) .build(); Map<String, List<ApiClusterTemplateConfig>> roleConfigs = subject.getRoleConfigs(cmTemplateProcessor, preparationObject); List<ApiClusterTemplateConfig> namenodeConfigs = roleConfigs.get("hdfs-NAMENODE-BASE"); Map<String, ApiClusterTemplateConfig> configMap = cmTemplateProcessor.mapByName(namenodeConfigs); assertEquals(NN_HA_PROPERTIES, configMap.keySet()); assertEquals("true", configMap.get("autofailover_enabled").getValue()); }
@Test void nonHA() { HostgroupView master = new HostgroupView("master", 0, InstanceGroupType.CORE, 1); HostgroupView worker = new HostgroupView("worker", 0, InstanceGroupType.CORE, 3); String inputJson = FileReaderUtils.readFileFromClasspathQuietly("input/clouderamanager.bp"); CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson); TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder() .withHostgroupViews(Set.of(master, worker)) .withBlueprintView(new BlueprintView(inputJson, "CDP", "1.0", cmTemplateProcessor)) .build(); Map<String, List<ApiClusterTemplateConfig>> roleConfigs = subject.getRoleConfigs(cmTemplateProcessor, preparationObject); assertEquals(List.of(), roleConfigs.get("hdfs-NAMENODE-BASE")); assertEquals(List.of(config("dfs_datanode_failed_volumes_tolerated", "0")), roleConfigs.get("hdfs-DATANODE-BASE")); }