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

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


    Assert.assertEquals("centos5", osResource.getPropertyValue("OperatingSystems/os_type"));
  }

  @Test
  public void testExecute__Stack_instance_specifiedSubResources() throws Exception {
    ResourceDefinition resourceDefinition = new StackResourceDefinition();

    Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
    mapIds.put(Resource.Type.Stack, "HDP");

    //test
View Full Code Here


  @Test
  public void testExecute_StackVersionPageResourcePredicate()
    throws NoSuchParentResourceException, UnsupportedPropertyException,
    NoSuchResourceException, SystemException {

    ResourceDefinition resourceDefinition = new StackVersionResourceDefinition();

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

    //test
    QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
View Full Code Here

  @Test
  public void testExecute_StackVersionPageSubResourcePredicate()
      throws NoSuchParentResourceException, UnsupportedPropertyException,
    NoSuchResourceException, SystemException {

    ResourceDefinition resourceDefinition = new StackVersionResourceDefinition();

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

    QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
    instance.addProperty("operatingSystems/*", null);
View Full Code Here

  }

  @Test
  public void testExecute__Host_collection_noSpecifiedProps() throws Exception {
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);

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

    // expectations
    expect(resourceDefinition.getType()).andReturn(Resource.Type.Host).anyTimes();
    Set<SubResourceDefinition> setChildren = new HashSet<SubResourceDefinition>();

    expect(resourceDefinition.getSubResourceDefinitions()).andReturn(setChildren).anyTimes();

    replay(resourceDefinition);

    //test
    QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
View Full Code Here

    Assert.assertEquals(Resource.Type.Host, hostNode.getObject().getType());
  }

  @Test
  public void testExecute__collection_nullInternalPredicate_nullUserPredicate() throws Exception {
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);

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

    // expectations
    expect(resourceDefinition.getType()).andReturn(Resource.Type.Cluster).anyTimes();
    Set<SubResourceDefinition> setChildren = new HashSet<SubResourceDefinition>();
    setChildren.add(new SubResourceDefinition(Resource.Type.Host));

    expect(resourceDefinition.getSubResourceDefinitions()).andReturn(setChildren).anyTimes();

    replay(resourceDefinition);

    //test
    QueryImpl instance = new TestQuery(mapIds, resourceDefinition);
View Full Code Here

  /**
   * Finalize properties for entire query tree before executing query.
   */
  private void finalizeProperties() {
    ResourceDefinition rootDefinition = this.resourceDefinition;

    QueryInfo rootQueryInfo = new QueryInfo(rootDefinition, this.requestedProperties);
    TreeNode<QueryInfo> rootNode = new TreeNodeImpl<QueryInfo>(
        null, rootQueryInfo, rootDefinition.getType().name());

    TreeNode<QueryInfo> requestedPropertyTree = buildQueryPropertyTree(this, rootNode);

    mergeFinalizedProperties(renderer.finalizeProperties(
        requestedPropertyTree, isCollectionResource()), this);
View Full Code Here

   *
   * @return query info tree
   */
  private TreeNode<QueryInfo> buildQueryPropertyTree(QueryImpl query, TreeNode<QueryInfo> node) {
    for (QueryImpl subQuery : query.requestedSubResources.values()) {
      ResourceDefinition childResource = subQuery.resourceDefinition;

      QueryInfo queryInfo = new QueryInfo(childResource, subQuery.requestedProperties);
      TreeNode<QueryInfo> childNode = node.addChild(queryInfo, childResource.getType().name());
      buildQueryPropertyTree(subQuery, childNode);
    }
    return node;
  }
View Full Code Here

    // currently not exposing temporal information to renderer
    query.requestedProperties.addAll(finalizedProperties);

    for (TreeNode<Set<String>> child : node.getChildren()) {
      Resource.Type childType = Resource.Type.valueOf(child.getName());
      ResourceDefinition parentResource = query.resourceDefinition;
      Set<SubResourceDefinition> subResources = parentResource.getSubResourceDefinitions();
      String subResourceName = null;
      for (SubResourceDefinition subResource : subResources) {
        if (subResource.getType() == childType) {
          ResourceDefinition resource = ResourceInstanceFactoryImpl.getResourceDefinition(
              subResource.getType(), query.keyValueMap);
          subResourceName = getSubResourceName(resource, subResource);
          break;
        }
      }
View Full Code Here

  public void testCreate_Post__UriQueryParams() {
    HttpHeaders headers = createNiceMock(HttpHeaders.class);
    UriInfo uriInfo = createNiceMock(UriInfo.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> mapQueryParams = createMock(MultivaluedMap.class);
    Map<String, List<String>> mapProps = new HashMap<String, List<String>>();
    mapProps.put("foo", Collections.singletonList("bar"));


    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(mapQueryParams).anyTimes();
    expect(mapQueryParams.entrySet()).andReturn(mapProps.entrySet()).anyTimes();
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();
    expect(resourceDefinition.getCreateDirectives()).andReturn(Collections.<String>emptySet());
    expect(body.getQueryString()).andReturn(null);

    replay(headers, uriInfo, body, resource, mapQueryParams, resourceDefinition);

    //test
View Full Code Here

  public void testCreate_Post__WithUriDirective() {
    HttpHeaders headers = createNiceMock(HttpHeaders.class);
    UriInfo uriInfo = createNiceMock(UriInfo.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);

    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> mapQueryParams = createMock(MultivaluedMap.class);
    Map<String, List<String>> mapProps = new HashMap<String, List<String>>();
    mapProps.put("foo", Collections.singletonList("bar"));

    Map<String, String> requestInfoMap = new HashMap<String, String>();

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(mapQueryParams).anyTimes();
    expect(mapQueryParams.entrySet()).andReturn(mapProps.entrySet()).anyTimes();
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();
    expect(resourceDefinition.getCreateDirectives()).andReturn(Collections.singleton("foo"));
    expect(body.getQueryString()).andReturn(null);
    expect(body.getRequestInfoProperties()).andReturn(requestInfoMap).anyTimes();

    replay(headers, uriInfo, body, resource, mapQueryParams, resourceDefinition);
View Full Code Here

TOP

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

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.