assertEquals(0, clusterNode.getChildren().size());
}
@Test
public void testExecute__collection_nonNullInternalPredicate_nonNullUserPredicate() throws Exception {
Result result = createNiceMock(Result.class);
ResourceInstance componentResourceInstance = createNiceMock(ResourceInstance.class);
ResourceDefinition componentResourceDefinition = createNiceMock(ResourceDefinition.class);
Schema componentSchema = createNiceMock(Schema.class);
Resource componentResource = createNiceMock(Resource.class);
String componentPropertyId = "componentId";
String servicePropertyId = "serviceId";
String clusterPropertyId = "clusterId";
Set<String> setPropertyIds = new HashSet<String>();
setPropertyIds.add(clusterPropertyId);
setPropertyIds.add(servicePropertyId);
setPropertyIds.add(componentPropertyId);
TreeNode<Resource> tree = new TreeNodeImpl<Resource>(null, null, null);
List<Resource> listResources = Collections.singletonList(componentResource);
Map<Resource.Type, String> mapResourceIds = new HashMap<Resource.Type, String>();
mapResourceIds.put(Resource.Type.Cluster, "clusterName");
mapResourceIds.put(Resource.Type.Service, "serviceName");
mapResourceIds.put(Resource.Type.Component, null);
PredicateBuilder pb = new PredicateBuilder();
Predicate internalPredicate = pb.property("clusterId").equals("clusterName").and().
property("serviceId").equals("serviceName").toPredicate();
pb = new PredicateBuilder();
Predicate userPredicate = pb.property("foo").equals("bar").toPredicate();
// combine internal predicate and user predicate
//todo: for now, need to cast to BasePredicate
Predicate predicate = new AndPredicate((BasePredicate) internalPredicate, (BasePredicate) userPredicate);
// expectations
expect(componentResource.getType()).andReturn(Resource.Type.Component).anyTimes();
expect(componentResourceInstance.getIds()).andReturn(mapResourceIds).anyTimes();
expect(componentResourceInstance.getResourceDefinition()).andReturn(componentResourceDefinition).anyTimes();
expect(componentResourceDefinition.getType()).andReturn(Resource.Type.Component).anyTimes();
expect(m_controller.getSchema(Resource.Type.Component)).andReturn(componentSchema).anyTimes();
expect(componentSchema.getKeyPropertyId(Resource.Type.Component)).andReturn(componentPropertyId).atLeastOnce();
expect(componentSchema.getKeyPropertyId(Resource.Type.Cluster)).andReturn("clusterId").anyTimes();
expect(componentSchema.getKeyPropertyId(Resource.Type.Service)).andReturn("serviceId").anyTimes();
expect(result.getResultTree()).andReturn(tree).anyTimes();
expect(m_controller.getResources(eq(Resource.Type.Component), eq(PropertyHelper.getReadRequest(setPropertyIds)),
eq(predicate))).andReturn(listResources);
expect(componentResourceInstance.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();