@Test public void testInitializeClusterAndServiceWidgets() throws Exception { final AmbariManagementController controller = createStrictMock(AmbariManagementController.class); final Clusters clusters = createStrictMock(Clusters.class); final Cluster cluster = createStrictMock(Cluster.class); final Service service = createStrictMock(Service.class); final Map<String, Cluster> clusterMap = Collections.singletonMap("c1", cluster); final Map<String, Service> services = Collections.singletonMap("HBASE", service); 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(); controller.initializeWidgetsAndLayouts(cluster, null); expectLastCall().once(); expect(cluster.getServices()).andReturn(services).once(); controller.initializeWidgetsAndLayouts(cluster, service); expectLastCall().once(); replay(controller, clusters, cluster); Injector injector = Guice.createInjector(module); injector.getInstance(UpgradeCatalog210.class).initializeClusterAndServiceWidgets(); verify(controller, clusters, cluster); }
protected void initializeClusterAndServiceWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { controller.initializeWidgetsAndLayouts(cluster, null); Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } }
UpgradeCatalog210 extends AbstractUpgradeCatalog { protected void initializeClusterAndServiceWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { controller.initializeWidgetsAndLayouts(cluster, null); Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } }
UpgradeCatalog210 extends AbstractUpgradeCatalog { protected void initializeClusterAndServiceWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { controller.initializeWidgetsAndLayouts(cluster, null); Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } @Inject  UpgradeCatalog210(Injector injector); }
UpgradeCatalog210 extends AbstractUpgradeCatalog { protected void initializeClusterAndServiceWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { controller.initializeWidgetsAndLayouts(cluster, null); Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } @Inject  UpgradeCatalog210(Injector injector); @Override String getSourceVersion(); @Override String getTargetVersion(); }
UpgradeCatalog210 extends AbstractUpgradeCatalog { protected void initializeClusterAndServiceWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { controller.initializeWidgetsAndLayouts(cluster, null); Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } @Inject  UpgradeCatalog210(Injector injector); @Override String getSourceVersion(); @Override String getTargetVersion();  }