@Test
public void testInitializeStromAndKafkaWidgets() throws AmbariException {

  String stormServiceName = "STORM";
  String kafkaServiceName = "KAFKA";
  String hbaseServiceName = "HBASE";
  final AmbariManagementController controller = createStrictMock(AmbariManagementController.class);
  final Clusters clusters = createStrictMock(Clusters.class);
  final Cluster cluster = createStrictMock(Cluster.class);
  final Service stormService = createStrictMock(Service.class);
  final Service kafkaService = createStrictMock(Service.class);
  final Service hbaseService = createStrictMock(Service.class);
  final Map<String, Cluster> clusterMap = Collections.singletonMap("c1", cluster);
  // Use a TreeMap so we can assume a particular order when iterating over the services.
  final Map<String, Service> services = new TreeMap<>();
  services.put(stormServiceName, stormService);
  services.put(kafkaServiceName, kafkaService);
  services.put(hbaseServiceName, hbaseService);
  Module module = new Module() {
    @Override
    public void configure(Binder binder) {
      binder.bind(AmbariManagementController.class).toInstance(controller);
      binder.bind(Clusters.class).toInstance(clusters);
      binder.bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
      binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
    }
  };
  expect(controller.getClusters()).andReturn(clusters).anyTimes();
  expect(clusters.getClusters()).andReturn(clusterMap).anyTimes();
  expect(cluster.getServices()).andReturn(services).once();
  expect(stormService.getName()).andReturn(stormServiceName).atLeastOnce();
  expect(kafkaService.getName()).andReturn(kafkaServiceName).atLeastOnce();
  expect(hbaseService.getName()).andReturn(hbaseServiceName).atLeastOnce();
  controller.initializeWidgetsAndLayouts(cluster, kafkaService);
  expectLastCall().once();
  controller.initializeWidgetsAndLayouts(cluster, stormService);
  expectLastCall().once();
  // but no controller call for HBase
  replay(controller, clusters, cluster, stormService, kafkaService, hbaseService);
  Injector injector = Guice.createInjector(module);
  injector.getInstance(UpgradeCatalog222.class).initializeStromAndKafkaWidgets();
  verify(controller, clusters, cluster, stormService, kafkaService, hbaseService);
}