Package org.apache.ambari.server.api.resources

Examples of org.apache.ambari.server.api.resources.ResourceDefinition$PostProcessor


  @Test
  public void testExecute__Component_collection_noSpecifiedProps() 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 predicate = pb.property("clusterId").equals("clusterName").and().
        property("serviceId").equals("serviceName").toPredicate();

    // 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).anyTimes();
    expect(componentSchema.getKeyPropertyId(Resource.Type.Cluster)).andReturn("clusterId").anyTimes();
View Full Code Here


  @Test
  public void testExecute__collection_nullInternalPredicate_nullUserPredicate() throws Exception {
    Result result = createNiceMock(Result.class);
    ResourceInstance clusterResourceInstance = createNiceMock(ResourceInstance.class);
    ResourceDefinition clusterResourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema clusterSchema = createNiceMock(Schema.class);
    Resource clusterResource = createNiceMock(Resource.class);
    String clusterPropertyId = "clusterId";

    TreeNode<Resource> tree = new TreeNodeImpl<Resource>(null, null, null);
    List<Resource> listResources = Collections.singletonList(clusterResource);

    Map<Resource.Type, String> mapResourceIds = new HashMap<Resource.Type, String>();

    // expectations
    expect(clusterResource.getType()).andReturn(Resource.Type.Cluster).anyTimes();

    expect(clusterResourceInstance.getIds()).andReturn(mapResourceIds).anyTimes();
    expect(clusterResourceInstance.getResourceDefinition()).andReturn(clusterResourceDefinition).anyTimes();

    expect(clusterResourceDefinition.getType()).andReturn(Resource.Type.Component).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Component)).andReturn(clusterSchema).atLeastOnce();

    expect(clusterSchema.getKeyPropertyId(Resource.Type.Component)).andReturn(clusterPropertyId).atLeastOnce();
View Full Code Here

  @Test
  public void testExecute__collection_nullInternalPredicate_nonNullUserPredicate() throws Exception {
    Result result = createNiceMock(Result.class);
    ResourceInstance clusterResourceInstance = createNiceMock(ResourceInstance.class);
    ResourceDefinition clusterResourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema clusterSchema = createNiceMock(Schema.class);
    Resource clusterResource = createNiceMock(Resource.class);
    String clusterPropertyId = "clusterId";
    Predicate userPredicate = createNiceMock(Predicate.class);

    TreeNode<Resource> tree = new TreeNodeImpl<Resource>(null, null, null);
    List<Resource> listResources = Collections.singletonList(clusterResource);

    Map<Resource.Type, String> mapResourceIds = new HashMap<Resource.Type, String>();

    // expectations
    expect(clusterResource.getType()).andReturn(Resource.Type.Cluster).anyTimes();

    expect(clusterResourceInstance.getIds()).andReturn(mapResourceIds).anyTimes();
    expect(clusterResourceInstance.getResourceDefinition()).andReturn(clusterResourceDefinition).anyTimes();

    expect(clusterResourceDefinition.getType()).andReturn(Resource.Type.Component).atLeastOnce();

    expect(m_controller.getSchema(Resource.Type.Component)).andReturn(clusterSchema).anyTimes();
    expect(clusterSchema.getKeyPropertyId(Resource.Type.Component)).andReturn(clusterPropertyId).anyTimes();

    expect(result.getResultTree()).andReturn(tree).anyTimes();
View Full Code Here

  @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(internalPredicate, 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();
View Full Code Here

  }

  @Test
  public void testAddProperty__localProperty() throws Exception {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema schema = createNiceMock(Schema.class);

    //expectations
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();
    expect(resource.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();

    expect(resourceDefinition.getType()).andReturn(Resource.Type.Service).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();

    replay(m_controller, resource, resourceDefinition, schema);
View Full Code Here

  }

  @Test
  public void testAddProperty__allProperties() throws Exception {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema schema = createNiceMock(Schema.class);

    //expectations
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();
    expect(resource.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();

    expect(resourceDefinition.getType()).andReturn(Resource.Type.Service).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();

    replay(m_controller, resource, resourceDefinition, schema);
View Full Code Here

  }

  @Test
  public void testAddProperty__allCategoryProperties() throws Exception {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema schema = createNiceMock(Schema.class);

    //expectations
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();
    expect(resource.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();

    expect(resourceDefinition.getType()).andReturn(Resource.Type.Service).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();

    replay(m_controller, resource, resourceDefinition, schema);
View Full Code Here

  // this is the case where service can't differentiate category and property name
  // the category name is give as the property name
  @Test
  public void testAddProperty__localCategory_asPropertyName() throws Exception  {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema schema = createNiceMock(Schema.class);

    //expectations
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();

    expect(resourceDefinition.getType()).andReturn(Resource.Type.Service).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();
    expect(resource.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();

    replay(m_controller, resource, resourceDefinition, schema);
View Full Code Here

  // This is the case where the service can determine that only a category was provided because it contained
  // a trailing '/'
  @Test
  public void testAddProperty__localCategory_categoryNameOnly() throws Exception {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema schema = createNiceMock(Schema.class);

    //expectations
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();

    expect(resourceDefinition.getType()).andReturn(Resource.Type.Service).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();
    expect(resource.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();

    replay(m_controller, resource, resourceDefinition, schema);
View Full Code Here

  }

  @Test
  public void testAddProperty__localSubCategory() throws Exception {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema schema = createNiceMock(Schema.class);

    //expectations
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();

    expect(resourceDefinition.getType()).andReturn(Resource.Type.Service).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();

    expect(resource.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.api.resources.ResourceDefinition$PostProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.