### Question:
StackResponseUtils { public Integer getNodeCountForHostGroup(StackV4Response stackResponse, String hostGroup) { return stackResponse.getInstanceGroups().stream() .filter(instanceGroupV4Response -> instanceGroupV4Response.getName().equalsIgnoreCase(hostGroup)) .flatMap(instanceGroupV4Response -> instanceGroupV4Response.getMetadata().stream()) .map(InstanceMetaDataV4Response::getDiscoveryFQDN) .collect(Collectors.counting()) .intValue(); }  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 testGetNodeCountForHostGroup() { String hostGroup = "compute"; Integer nodeCountForHostGroup = underTest .getNodeCountForHostGroup(getMockStackV4Response(hostGroup), hostGroup); assertEquals("Retrieved HostGroup Instance Count should match.", Integer.valueOf(3), nodeCountForHostGroup); }