ViewContextImpl implements ViewContext, ViewController { @Override public Cluster getCluster() { return viewRegistry.getCluster(viewInstanceEntity); } ViewContextImpl(ViewInstanceEntity viewInstanceEntity, ViewRegistry viewRegistry);  ViewContextImpl(ViewEntity viewEntity, ViewRegistry viewRegistry); private  ViewContextImpl(ViewEntity viewEntity, ViewInstanceEntity viewInstanceEntity, ViewRegistry viewRegistry); @Override String getViewName(); @Override ViewDefinition getViewDefinition(); @Override String getInstanceName(); @Override ViewInstanceDefinition getViewInstanceDefinition(); @Override Map<String, String> getProperties(); @Transactional @Override void putInstanceData(String key, String value); @Override String getInstanceData(String key); @Override Map<String, String> getInstanceData(); @Override void removeInstanceData(String key); @Override String getAmbariProperty(String key); @Override ResourceProvider<?> getResourceProvider(String type); @Override String getUsername(); @Override String getLoggedinUser(); @Override void hasPermission(String userName, String permissionName); @Override org.apache.ambari.view.URLStreamProvider getURLStreamProvider(); @Override URLConnectionProvider getURLConnectionProvider(); @Override synchronized AmbariStreamProvider getAmbariStreamProvider(); @Override AmbariStreamProvider getAmbariClusterStreamProvider(); @Override synchronized DataStore getDataStore(); @Override Collection<ViewDefinition> getViewDefinitions(); @Override Collection<ViewInstanceDefinition> getViewInstanceDefinitions(); @Override ViewController getController(); @Override HttpImpersonatorImpl getHttpImpersonator(); @Override ImpersonatorSetting getImpersonatorSetting(); @Override Cluster getCluster(); @Override void fireEvent(String eventId, Map<String, String> eventProperties); @Override void registerListener(Listener listener, String viewName); @Override void registerListener(Listener listener, String viewName, String viewVersion); @Override void unregisterListener(Listener listener, String viewName); @Override void unregisterListener(Listener listener, String viewName, String viewVersion); static final String HADOOP_SECURITY_AUTH_TO_LOCAL; static final String CORE_SITE; static final String HDFS_AUTH_TO_LOCAL; }
@Test public void testGetCluster() throws Exception { InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0); ViewEntity viewDefinition = ViewEntityTest.getViewEntity(); ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); ViewRegistry viewRegistry = createNiceMock(ViewRegistry.class); Cluster cluster = createNiceMock(Cluster.class); expect(viewRegistry.getCluster(viewInstanceDefinition)).andReturn(cluster); replay(viewRegistry); ViewContextImpl viewContext = new ViewContextImpl(viewInstanceDefinition, viewRegistry); Assert.assertEquals(cluster, viewContext.getCluster()); verify(viewRegistry); }