@Test
public void testUpdateConfigGroup() throws Exception {
AmbariManagementController managementController = createMock(AmbariManagementController.class);
RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
ConfigHelper configHelper = createNiceMock(ConfigHelper.class);
Clusters clusters = createNiceMock(Clusters.class);
Cluster cluster = createNiceMock(Cluster.class);
Host h1 = createNiceMock(Host.class);
Host h2 = createNiceMock(Host.class);
final ConfigGroup configGroup = createNiceMock(ConfigGroup.class);
ConfigGroupResponse configGroupResponse = createNiceMock
(ConfigGroupResponse.class);
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
expect(managementController.getAuthName()).andReturn("admin").anyTimes();
expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
expect(clusters.getHost("h1")).andReturn(h1);
expect(clusters.getHost("h2")).andReturn(h2);
expect(configGroup.getName()).andReturn("test-1").anyTimes();
expect(configGroup.getId()).andReturn(25L).anyTimes();
expect(configGroup.getTag()).andReturn("tag-1").anyTimes();
expect(configGroup.convertToResponse()).andReturn(configGroupResponse).anyTimes();
expect(configGroupResponse.getClusterName()).andReturn("Cluster100").anyTimes();
expect(configGroupResponse.getId()).andReturn(25L).anyTimes();
expect(cluster.getConfigGroups()).andStubAnswer(new IAnswer<Map<Long, ConfigGroup>>() {
@Override
public Map<Long, ConfigGroup> answer() throws Throwable {
Map<Long, ConfigGroup> configGroupMap = new HashMap<Long, ConfigGroup>();
configGroupMap.put(configGroup.getId(), configGroup);
return configGroupMap;
}
});
expect(managementController.getConfigHelper()).andReturn(configHelper).once();
configHelper.invalidateStaleConfigsCache();
expectLastCall().once();
replay(managementController, clusters, cluster,
configGroup, response, configGroupResponse, configHelper);