@Test public void testFinalizeProperties__collection_subResource_noProperties() { SchemaFactory schemaFactory = createNiceMock(SchemaFactory.class); Schema serviceSchema = createNiceMock(Schema.class); Schema componentSchema = createNiceMock(Schema.class); expect(schemaFactory.getSchema(Resource.Type.Service)).andReturn(serviceSchema).anyTimes(); expect(serviceSchema.getKeyPropertyId(Resource.Type.Service)).andReturn("ServiceInfo/service_name").anyTimes(); expect(schemaFactory.getSchema(Resource.Type.Component)).andReturn(componentSchema).anyTimes(); expect(componentSchema.getKeyPropertyId(Resource.Type.Component)).andReturn("ServiceComponentInfo/component_name").anyTimes(); replay(schemaFactory, serviceSchema, componentSchema); HashSet<String> serviceProperties = new HashSet<String>(); QueryInfo rootQuery = new QueryInfo(new ServiceResourceDefinition(), serviceProperties); TreeNode<QueryInfo> queryTree = new TreeNodeImpl<QueryInfo>(null, rootQuery, "Service"); queryTree.addChild(new QueryInfo(new ComponentResourceDefinition(), new HashSet<String>()), "Component"); MinimalRenderer renderer = new MinimalRenderer(); renderer.init(schemaFactory); TreeNode<Set<String>> propertyTree = renderer.finalizeProperties(queryTree, true); assertEquals(1, propertyTree.getChildren().size()); assertEquals(1, propertyTree.getObject().size()); assertTrue(propertyTree.getObject().contains("ServiceInfo/service_name")); TreeNode<Set<String>> componentNode = propertyTree.getChild("Component"); assertEquals(0, componentNode.getChildren().size()); assertEquals(1, componentNode.getObject().size()); assertTrue(componentNode.getObject().contains("ServiceComponentInfo/component_name")); verify(schemaFactory, serviceSchema, componentSchema); }
@Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryTree, boolean isCollection) { QueryInfo queryInfo = queryTree.getObject(); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, queryInfo.getProperties(), queryTree.getName()); copyPropertiesToResult(queryTree, resultTree); m_rootType = queryTree.getObject().getResource().getType(); m_isCollection = isCollection; boolean addKeysToEmptyResource = true; if (! isCollection && isRequestWithNoProperties(queryTree)) { addSubResources(queryTree, resultTree); addKeysToEmptyResource = false; } processRequestedProperties(queryTree); ensureRequiredProperties(resultTree, addKeysToEmptyResource); return resultTree; }
MinimalRenderer extends BaseRenderer implements Renderer { @Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryTree, boolean isCollection) { QueryInfo queryInfo = queryTree.getObject(); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, queryInfo.getProperties(), queryTree.getName()); copyPropertiesToResult(queryTree, resultTree); m_rootType = queryTree.getObject().getResource().getType(); m_isCollection = isCollection; boolean addKeysToEmptyResource = true; if (! isCollection && isRequestWithNoProperties(queryTree)) { addSubResources(queryTree, resultTree); addKeysToEmptyResource = false; } processRequestedProperties(queryTree); ensureRequiredProperties(resultTree, addKeysToEmptyResource); return resultTree; } }
MinimalRenderer extends BaseRenderer implements Renderer { @Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryTree, boolean isCollection) { QueryInfo queryInfo = queryTree.getObject(); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, queryInfo.getProperties(), queryTree.getName()); copyPropertiesToResult(queryTree, resultTree); m_rootType = queryTree.getObject().getResource().getType(); m_isCollection = isCollection; boolean addKeysToEmptyResource = true; if (! isCollection && isRequestWithNoProperties(queryTree)) { addSubResources(queryTree, resultTree); addKeysToEmptyResource = false; } processRequestedProperties(queryTree); ensureRequiredProperties(resultTree, addKeysToEmptyResource); return resultTree; }  }
MinimalRenderer extends BaseRenderer implements Renderer { @Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryTree, boolean isCollection) { QueryInfo queryInfo = queryTree.getObject(); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, queryInfo.getProperties(), queryTree.getName()); copyPropertiesToResult(queryTree, resultTree); m_rootType = queryTree.getObject().getResource().getType(); m_isCollection = isCollection; boolean addKeysToEmptyResource = true; if (! isCollection && isRequestWithNoProperties(queryTree)) { addSubResources(queryTree, resultTree); addKeysToEmptyResource = false; } processRequestedProperties(queryTree); ensureRequiredProperties(resultTree, addKeysToEmptyResource); return resultTree; }  @Override TreeNode<Set<String>> finalizeProperties(
      TreeNode<QueryInfo> queryTree, boolean isCollection); @Override Result finalizeResult(Result queryResult); @Override ResultPostProcessor getResultPostProcessor(Request request); }
MinimalRenderer extends BaseRenderer implements Renderer { @Override public TreeNode<Set<String>> finalizeProperties( TreeNode<QueryInfo> queryTree, boolean isCollection) { QueryInfo queryInfo = queryTree.getObject(); TreeNode<Set<String>> resultTree = new TreeNodeImpl<Set<String>>( null, queryInfo.getProperties(), queryTree.getName()); copyPropertiesToResult(queryTree, resultTree); m_rootType = queryTree.getObject().getResource().getType(); m_isCollection = isCollection; boolean addKeysToEmptyResource = true; if (! isCollection && isRequestWithNoProperties(queryTree)) { addSubResources(queryTree, resultTree); addKeysToEmptyResource = false; } processRequestedProperties(queryTree); ensureRequiredProperties(resultTree, addKeysToEmptyResource); return resultTree; }  @Override TreeNode<Set<String>> finalizeProperties(
      TreeNode<QueryInfo> queryTree, boolean isCollection); @Override Result finalizeResult(Result queryResult); @Override ResultPostProcessor getResultPostProcessor(Request request);  }