AmbariManagementController managementController = createMock(AmbariManagementController.class);
Clusters clusters = createNiceMock(Clusters.class);
Cluster cluster = createNiceMock(Cluster.class);
Host h1 = createNiceMock(Host.class);
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();