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

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


  public void testCreate_Post__BodyQueryParams() {
    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);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(mapQueryParams).anyTimes();
    expect(mapQueryParams.entrySet()).andReturn(Collections.<Map.Entry<String, List<String>>>emptySet()).anyTimes();
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();
    expect(resourceDefinition.getCreateDirectives()).andReturn(Collections.<String>emptySet());
    expect(body.getQueryString()).andReturn("foo=bar");

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

    //test
View Full Code Here


  public void testCreate_Post__WithBodyDirective() {
    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(Collections.<Map.Entry<String, List<String>>>emptySet()).anyTimes();
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();
    expect(resourceDefinition.getCreateDirectives()).andReturn(Collections.singleton("foo"));
    expect(body.getQueryString()).andReturn("foo=bar");
    expect(body.getRequestInfoProperties()).andReturn(requestInfoMap).anyTimes();

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

    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Renderer renderer = new DefaultRenderer();

    Request request = getTestRequest(null, body, uriInfo, compiler, handler, processor, resource);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(queryParams).anyTimes();
    expect(queryParams.getFirst(QueryLexer.QUERY_MINIMAL)).andReturn(null);
    expect(queryParams.getFirst(QueryLexer.QUERY_FORMAT)).andReturn(null);
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getRenderer(null)).andReturn(renderer);
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(handler.handleRequest(request)).andReturn(result);
    expect(result.getStatus()).andReturn(resultStatus).anyTimes();
    expect(resultStatus.isErrorState()).andReturn(false).anyTimes();
    processor.process(result);
View Full Code Here

    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Renderer renderer = new DefaultRenderer();

    Request request = getTestRequest(null, body, uriInfo, compiler, handler, processor, resource);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(queryParams).anyTimes();
    expect(queryParams.getFirst(QueryLexer.QUERY_MINIMAL)).andReturn(null);
    expect(queryParams.getFirst(QueryLexer.QUERY_FORMAT)).andReturn(null);
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getRenderer(null)).andReturn(renderer);
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(handler.handleRequest(request)).andReturn(result);
    expect(result.getStatus()).andReturn(resultStatus).anyTimes();
    expect(resultStatus.isErrorState()).andReturn(false).anyTimes();
    processor.process(result);
View Full Code Here

    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Renderer renderer = new DefaultRenderer();

    Request request = getTestRequest(headers, body, uriInfo, compiler, handler, processor, resource);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(queryParams).anyTimes();
    expect(queryParams.getFirst(QueryLexer.QUERY_MINIMAL)).andReturn(null);
    expect(queryParams.getFirst(QueryLexer.QUERY_FORMAT)).andReturn(null);
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getRenderer(null)).andReturn(renderer);
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(body.getQueryString()).andReturn(null);
    expect(compiler.compile("foo=foo-value&bar=bar-value")).andReturn(predicate);
    expect(handler.handleRequest(request)).andReturn(result);
    expect(result.getStatus()).andReturn(resultStatus).anyTimes();
View Full Code Here

    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Renderer renderer = new DefaultRenderer();

    Request request = getTestRequest(headers, body, uriInfo, compiler, handler, processor, resource);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(queryParams).anyTimes();
    expect(queryParams.getFirst(QueryLexer.QUERY_MINIMAL)).andReturn(null);
    expect(queryParams.getFirst(QueryLexer.QUERY_FORMAT)).andReturn(null);
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getRenderer(null)).andReturn(renderer);
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(body.getQueryString()).andReturn("foo=bar");
    expect(compiler.compile("foo=bar")).andReturn(predicate);
    expect(handler.handleRequest(request)).andReturn(result);
    expect(result.getStatus()).andReturn(resultStatus).anyTimes();
View Full Code Here

    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Renderer renderer = new DefaultRenderer();

    Request request = getTestRequest(headers, body, uriInfo, compiler, handler, processor, resource);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(queryParams).anyTimes();
    expect(queryParams.getFirst(QueryLexer.QUERY_MINIMAL)).andReturn(null);
    expect(queryParams.getFirst(QueryLexer.QUERY_FORMAT)).andReturn(null);
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getRenderer(null)).andReturn(renderer);
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(body.getQueryString()).andReturn("foo=bar");
    expect(compiler.compile("foo=bar")).andReturn(predicate);
    expect(handler.handleRequest(request)).andReturn(result);
    expect(result.getStatus()).andReturn(resultStatus).anyTimes();
View Full Code Here

    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    PredicateCompiler compiler = createStrictMock(PredicateCompiler.class);
    RequestBody body = createNiceMock(RequestBody.class);
    Exception exception = new InvalidQueryException("test");
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Renderer renderer = new DefaultRenderer();

    Request request = getTestRequest(null, body, uriInfo, compiler, null, null, resource);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(queryParams).anyTimes();
    expect(queryParams.getFirst(QueryLexer.QUERY_MINIMAL)).andReturn(null);
    expect(queryParams.getFirst(QueryLexer.QUERY_FORMAT)).andReturn(null);
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getRenderer(null)).andReturn(renderer);
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(body.getQueryString()).andReturn("blahblahblah");
    expect(compiler.compile("blahblahblah")).andThrow(exception);

    replay(compiler, uriInfo, queryParams, resource,
View Full Code Here

    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Renderer renderer = new DefaultRenderer();

    Request request = getTestRequest(null, body, uriInfo, compiler, handler, processor, resource);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(queryParams).anyTimes();
    expect(queryParams.getFirst(QueryLexer.QUERY_MINIMAL)).andReturn(null);
    expect(queryParams.getFirst(QueryLexer.QUERY_FORMAT)).andReturn(null);
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getRenderer(null)).andReturn(renderer);
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(handler.handleRequest(request)).andReturn(result);
    expect(result.getStatus()).andReturn(resultStatus).anyTimes();
    expect(resultStatus.isErrorState()).andReturn(true).anyTimes();
View Full Code Here

    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.class);
    RequestBody body = createNiceMock(RequestBody.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Renderer renderer = new MinimalRenderer();

    Request request = getTestRequest(null, body, uriInfo, compiler, handler, processor, resource);

    //expectations
    expect(uriInfo.getQueryParameters()).andReturn(queryParams).anyTimes();
    expect(queryParams.getFirst(QueryLexer.QUERY_MINIMAL)).andReturn("true");
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getRenderer("minimal")).andReturn(renderer);
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(handler.handleRequest(request)).andReturn(result);
    expect(result.getStatus()).andReturn(resultStatus).anyTimes();
    expect(resultStatus.isErrorState()).andReturn(false).anyTimes();
    processor.process(result);
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.