ConfigGroup configGroup1 = createNiceMock(ConfigGroup.class);
ConfigGroup configGroup2 = createNiceMock(ConfigGroup.class);
ConfigGroup configGroup3 = createNiceMock(ConfigGroup.class);
ConfigGroup configGroup4 = createNiceMock(ConfigGroup.class);
ConfigGroupResponse response1 = createNiceMock(ConfigGroupResponse.class);
ConfigGroupResponse response2 = createNiceMock(ConfigGroupResponse.class);
ConfigGroupResponse response3 = createNiceMock(ConfigGroupResponse.class);
ConfigGroupResponse response4 = createNiceMock(ConfigGroupResponse.class);
Map<Long, ConfigGroup> configGroupMap = new HashMap<Long, ConfigGroup>();
configGroupMap.put(1L, configGroup1);
configGroupMap.put(2L, configGroup2);
configGroupMap.put(3L, configGroup3);
configGroupMap.put(4L, configGroup4);
Map<Long, ConfigGroup> configGroupByHostname = new HashMap<Long, ConfigGroup>();
configGroupByHostname.put(4L, configGroup4);
expect(configGroup1.convertToResponse()).andReturn(response1).anyTimes();
expect(configGroup2.convertToResponse()).andReturn(response2).anyTimes();
expect(configGroup3.convertToResponse()).andReturn(response3).anyTimes();
expect(configGroup4.convertToResponse()).andReturn(response4).anyTimes();
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
expect(cluster.getConfigGroups()).andReturn(configGroupMap).anyTimes();
expect(cluster.getClusterName()).andReturn("Cluster100").anyTimes();
expect(configGroup1.getName()).andReturn("g1").anyTimes();
expect(configGroup2.getName()).andReturn("g2").anyTimes();
expect(configGroup3.getName()).andReturn("g3").anyTimes();
expect(configGroup4.getName()).andReturn("g4").anyTimes();
expect(configGroup1.getTag()).andReturn("t1").anyTimes();
expect(configGroup2.getTag()).andReturn("t2").anyTimes();
expect(configGroup3.getTag()).andReturn("t3").anyTimes();
expect(configGroup4.getTag()).andReturn("t4").anyTimes();
Map<String, Host> hostMap = new HashMap<String, Host>();
hostMap.put("h1", h1);
expect(configGroup4.getHosts()).andReturn(hostMap).anyTimes();
expect(response1.getClusterName()).andReturn("Cluster100").anyTimes();
expect(response2.getClusterName()).andReturn("Cluster100").anyTimes();
expect(response3.getClusterName()).andReturn("Cluster100").anyTimes();
expect(response4.getClusterName()).andReturn("Cluster100").anyTimes();
expect(response1.getId()).andReturn(1L).anyTimes();
expect(response2.getId()).andReturn(2L).anyTimes();
expect(response3.getId()).andReturn(3L).anyTimes();
expect(response4.getId()).andReturn(4L).anyTimes();
expect(response2.getGroupName()).andReturn("g2").anyTimes();
expect(response3.getTag()).andReturn("t3").anyTimes();
expect(cluster.getConfigGroupsByHostname("h1")).andReturn(configGroupByHostname).anyTimes();
Set<Map<String, Object>> hostObj = new HashSet<Map<String, Object>>();
Map<String, Object> hostnames = new HashMap<String, Object>();
hostnames.put("host_name", "h1");
hostObj.add(hostnames);
expect(response4.getHosts()).andReturn(hostObj).anyTimes();
replay(managementController, clusters, cluster, configGroup1,
configGroup2, configGroup3, configGroup4, response1, response2,
response3, response4);