### Question:
ClouderaHostGroupAssociationBuilder { Map<String, List<Map<String, String>>> buildHostGroupAssociations(Map<HostGroup, List<InstanceMetaData>> instanceMetaDataByHostGroup) { Map<String, List<Map<String, String>>> hostGroupMappings = new HashMap<>(); LOGGER.debug("Computing host - hostGroup mappings based on hostGroup - instanceGroup associations"); for (Entry<HostGroup, List<InstanceMetaData>> hostGroupListEntry : instanceMetaDataByHostGroup.entrySet()) { List<Map<String, String>> hostInfoForHostGroup = buildHostGroupAssociation(hostGroupListEntry.getValue()); hostGroupMappings.put(hostGroupListEntry.getKey().getName(), hostInfoForHostGroup); } LOGGER.debug("Computed host-hostGroup associations: {}", hostGroupMappings); return hostGroupMappings; }    }### Answer:
@Test public void testBuildHostGroupAssociationsShouldReturnsHostGroupAssociationsWhenTheParametersArePresent() { Map<HostGroup, List<InstanceMetaData>> instanceMetaDataByHostGroup = createInstanceMetaDataByHostGroup(); Map<String, List<Map<String, String>>> actual = underTest.buildHostGroupAssociations(instanceMetaDataByHostGroup); assertEquals(FQDN_1, actual.get(HOSTGROUP_NAME_1).get(0).get(FQDN)); assertEquals(FQDN_2, actual.get(HOSTGROUP_NAME_1).get(1).get(FQDN)); assertEquals(FQDN_3, actual.get(HOSTGROUP_NAME_2).get(0).get(FQDN)); assertEquals(FQDN_4, actual.get(HOSTGROUP_NAME_2).get(1).get(FQDN)); }
@Test public void testBuildHostGroupAssociationsShouldReturnsEmptyMapWhenTheParameterEmpty() { Map<String, List<Map<String, String>>> actual = underTest.buildHostGroupAssociations(Collections.emptyMap()); assertEquals(Collections.emptyMap(), actual); }