@Test public void testFinalizeProperties__instance_noComponentNode() { QueryInfo rootQuery = new QueryInfo(new ClusterResourceDefinition(), new HashSet<String>()); TreeNode<QueryInfo> queryTree = new TreeNodeImpl<QueryInfo>(null, rootQuery, "Cluster"); rootQuery.getProperties().add("foo/bar"); rootQuery.getProperties().add("prop1"); ClusterBlueprintRenderer renderer = new ClusterBlueprintRenderer(); TreeNode<Set<String>> propertyTree = renderer.finalizeProperties(queryTree, false); Set<String> rootProperties = propertyTree.getObject(); assertEquals(2, rootProperties.size()); assertNotNull(propertyTree.getChild("Host")); assertTrue(propertyTree.getChild("Host").getObject().isEmpty()); assertNotNull(propertyTree.getChild("Host/HostComponent")); assertEquals(1, propertyTree.getChild("Host/HostComponent").getObject().size()); assertTrue(propertyTree.getChild("Host/HostComponent").getObject().contains("HostRoles/component_name")); }
@Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryProperties, boolean isCollection) { Set<String> properties = new HashSet<String>(queryProperties.getObject().getProperties()); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, properties, queryProperties.getName()); copyPropertiesToResult(queryProperties, resultTree); String configType = Resource.Type.Configuration.name(); if (resultTree.getChild(configType) == null) { resultTree.addChild(new HashSet<String>(), configType); } String serviceType = Resource.Type.Service.name(); if (resultTree.getChild(serviceType) == null) { resultTree.addChild(new HashSet<String>(), serviceType); } TreeNode<Set<String>> serviceNode = resultTree.getChild(serviceType); if (serviceNode == null) { serviceNode = resultTree.addChild(new HashSet<String>(), serviceType); } String serviceComponentType = Resource.Type.Component.name(); TreeNode<Set<String>> serviceComponentNode = resultTree.getChild( serviceType + "/" + serviceComponentType); if (serviceComponentNode == null) { serviceComponentNode = serviceNode.addChild(new HashSet<String>(), serviceComponentType); } serviceComponentNode.getObject().add("ServiceComponentInfo/cluster_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/service_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/component_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/recovery_enabled"); String hostType = Resource.Type.Host.name(); String hostComponentType = Resource.Type.HostComponent.name(); TreeNode<Set<String>> hostComponentNode = resultTree.getChild( hostType + "/" + hostComponentType); if (hostComponentNode == null) { TreeNode<Set<String>> hostNode = resultTree.getChild(hostType); if (hostNode == null) { hostNode = resultTree.addChild(new HashSet<String>(), hostType); } hostComponentNode = hostNode.addChild(new HashSet<String>(), hostComponentType); } resultTree.getChild(configType).getObject().add("properties"); hostComponentNode.getObject().add("HostRoles/component_name"); return resultTree; }
ClusterBlueprintRenderer extends BaseRenderer implements Renderer { @Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryProperties, boolean isCollection) { Set<String> properties = new HashSet<String>(queryProperties.getObject().getProperties()); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, properties, queryProperties.getName()); copyPropertiesToResult(queryProperties, resultTree); String configType = Resource.Type.Configuration.name(); if (resultTree.getChild(configType) == null) { resultTree.addChild(new HashSet<String>(), configType); } String serviceType = Resource.Type.Service.name(); if (resultTree.getChild(serviceType) == null) { resultTree.addChild(new HashSet<String>(), serviceType); } TreeNode<Set<String>> serviceNode = resultTree.getChild(serviceType); if (serviceNode == null) { serviceNode = resultTree.addChild(new HashSet<String>(), serviceType); } String serviceComponentType = Resource.Type.Component.name(); TreeNode<Set<String>> serviceComponentNode = resultTree.getChild( serviceType + "/" + serviceComponentType); if (serviceComponentNode == null) { serviceComponentNode = serviceNode.addChild(new HashSet<String>(), serviceComponentType); } serviceComponentNode.getObject().add("ServiceComponentInfo/cluster_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/service_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/component_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/recovery_enabled"); String hostType = Resource.Type.Host.name(); String hostComponentType = Resource.Type.HostComponent.name(); TreeNode<Set<String>> hostComponentNode = resultTree.getChild( hostType + "/" + hostComponentType); if (hostComponentNode == null) { TreeNode<Set<String>> hostNode = resultTree.getChild(hostType); if (hostNode == null) { hostNode = resultTree.addChild(new HashSet<String>(), hostType); } hostComponentNode = hostNode.addChild(new HashSet<String>(), hostComponentType); } resultTree.getChild(configType).getObject().add("properties"); hostComponentNode.getObject().add("HostRoles/component_name"); return resultTree; } }
ClusterBlueprintRenderer extends BaseRenderer implements Renderer { @Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryProperties, boolean isCollection) { Set<String> properties = new HashSet<String>(queryProperties.getObject().getProperties()); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, properties, queryProperties.getName()); copyPropertiesToResult(queryProperties, resultTree); String configType = Resource.Type.Configuration.name(); if (resultTree.getChild(configType) == null) { resultTree.addChild(new HashSet<String>(), configType); } String serviceType = Resource.Type.Service.name(); if (resultTree.getChild(serviceType) == null) { resultTree.addChild(new HashSet<String>(), serviceType); } TreeNode<Set<String>> serviceNode = resultTree.getChild(serviceType); if (serviceNode == null) { serviceNode = resultTree.addChild(new HashSet<String>(), serviceType); } String serviceComponentType = Resource.Type.Component.name(); TreeNode<Set<String>> serviceComponentNode = resultTree.getChild( serviceType + "/" + serviceComponentType); if (serviceComponentNode == null) { serviceComponentNode = serviceNode.addChild(new HashSet<String>(), serviceComponentType); } serviceComponentNode.getObject().add("ServiceComponentInfo/cluster_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/service_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/component_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/recovery_enabled"); String hostType = Resource.Type.Host.name(); String hostComponentType = Resource.Type.HostComponent.name(); TreeNode<Set<String>> hostComponentNode = resultTree.getChild( hostType + "/" + hostComponentType); if (hostComponentNode == null) { TreeNode<Set<String>> hostNode = resultTree.getChild(hostType); if (hostNode == null) { hostNode = resultTree.addChild(new HashSet<String>(), hostType); } hostComponentNode = hostNode.addChild(new HashSet<String>(), hostComponentType); } resultTree.getChild(configType).getObject().add("properties"); hostComponentNode.getObject().add("HostRoles/component_name"); return resultTree; }  }
ClusterBlueprintRenderer extends BaseRenderer implements Renderer { @Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryProperties, boolean isCollection) { Set<String> properties = new HashSet<String>(queryProperties.getObject().getProperties()); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, properties, queryProperties.getName()); copyPropertiesToResult(queryProperties, resultTree); String configType = Resource.Type.Configuration.name(); if (resultTree.getChild(configType) == null) { resultTree.addChild(new HashSet<String>(), configType); } String serviceType = Resource.Type.Service.name(); if (resultTree.getChild(serviceType) == null) { resultTree.addChild(new HashSet<String>(), serviceType); } TreeNode<Set<String>> serviceNode = resultTree.getChild(serviceType); if (serviceNode == null) { serviceNode = resultTree.addChild(new HashSet<String>(), serviceType); } String serviceComponentType = Resource.Type.Component.name(); TreeNode<Set<String>> serviceComponentNode = resultTree.getChild( serviceType + "/" + serviceComponentType); if (serviceComponentNode == null) { serviceComponentNode = serviceNode.addChild(new HashSet<String>(), serviceComponentType); } serviceComponentNode.getObject().add("ServiceComponentInfo/cluster_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/service_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/component_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/recovery_enabled"); String hostType = Resource.Type.Host.name(); String hostComponentType = Resource.Type.HostComponent.name(); TreeNode<Set<String>> hostComponentNode = resultTree.getChild( hostType + "/" + hostComponentType); if (hostComponentNode == null) { TreeNode<Set<String>> hostNode = resultTree.getChild(hostType); if (hostNode == null) { hostNode = resultTree.addChild(new HashSet<String>(), hostType); } hostComponentNode = hostNode.addChild(new HashSet<String>(), hostComponentType); } resultTree.getChild(configType).getObject().add("properties"); hostComponentNode.getObject().add("HostRoles/component_name"); return resultTree; }  @Override TreeNode<Set<String>> finalizeProperties(
      TreeNode<QueryInfo> queryProperties, boolean isCollection); @Override Result finalizeResult(Result queryResult); @Override ResultPostProcessor getResultPostProcessor(Request request); @Override boolean requiresPropertyProviderInput(); }
ClusterBlueprintRenderer extends BaseRenderer implements Renderer { @Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryProperties, boolean isCollection) { Set<String> properties = new HashSet<String>(queryProperties.getObject().getProperties()); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, properties, queryProperties.getName()); copyPropertiesToResult(queryProperties, resultTree); String configType = Resource.Type.Configuration.name(); if (resultTree.getChild(configType) == null) { resultTree.addChild(new HashSet<String>(), configType); } String serviceType = Resource.Type.Service.name(); if (resultTree.getChild(serviceType) == null) { resultTree.addChild(new HashSet<String>(), serviceType); } TreeNode<Set<String>> serviceNode = resultTree.getChild(serviceType); if (serviceNode == null) { serviceNode = resultTree.addChild(new HashSet<String>(), serviceType); } String serviceComponentType = Resource.Type.Component.name(); TreeNode<Set<String>> serviceComponentNode = resultTree.getChild( serviceType + "/" + serviceComponentType); if (serviceComponentNode == null) { serviceComponentNode = serviceNode.addChild(new HashSet<String>(), serviceComponentType); } serviceComponentNode.getObject().add("ServiceComponentInfo/cluster_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/service_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/component_name"); serviceComponentNode.getObject().add("ServiceComponentInfo/recovery_enabled"); String hostType = Resource.Type.Host.name(); String hostComponentType = Resource.Type.HostComponent.name(); TreeNode<Set<String>> hostComponentNode = resultTree.getChild( hostType + "/" + hostComponentType); if (hostComponentNode == null) { TreeNode<Set<String>> hostNode = resultTree.getChild(hostType); if (hostNode == null) { hostNode = resultTree.addChild(new HashSet<String>(), hostType); } hostComponentNode = hostNode.addChild(new HashSet<String>(), hostComponentType); } resultTree.getChild(configType).getObject().add("properties"); hostComponentNode.getObject().add("HostRoles/component_name"); return resultTree; }  @Override TreeNode<Set<String>> finalizeProperties(
      TreeNode<QueryInfo> queryProperties, boolean isCollection); @Override Result finalizeResult(Result queryResult); @Override ResultPostProcessor getResultPostProcessor(Request request); @Override boolean requiresPropertyProviderInput();  }