Package org.apache.ambari.server.api.predicate

Examples of org.apache.ambari.server.api.predicate.PredicateCompiler


   * a predicate.
   *
   * @return the predicate compiler
   */
  protected PredicateCompiler getPredicateCompiler() {
    return new PredicateCompiler();
  }
View Full Code Here


   * a predicate.
   *
   * @return the predicate compiler
   */
  protected PredicateCompiler getPredicateCompiler() {
    return new PredicateCompiler();
  }
View Full Code Here

   * a predicate.
   *
   * @return the predicate compiler
   */
  protected PredicateCompiler getPredicateCompiler() {
    return new PredicateCompiler();
  }
View Full Code Here

  @Test
  public void testProcess_noBody() throws Exception {
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1";
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    PredicateCompiler compiler = createStrictMock(PredicateCompiler.class);
    UriInfo uriInfo = createMock(UriInfo.class);
    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> queryParams = createMock(MultivaluedMap.class);
    RequestHandler handler = createStrictMock(RequestHandler.class);
    Result result = createMock(Result.class);
View Full Code Here

  @Test
  public void testProcess_WithBody() throws Exception {
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1";
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    PredicateCompiler compiler = createStrictMock(PredicateCompiler.class);
    UriInfo uriInfo = createMock(UriInfo.class);
    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> queryParams = createMock(MultivaluedMap.class);
    RequestHandler handler = createStrictMock(RequestHandler.class);
    Result result = createMock(Result.class);
View Full Code Here

  @Test
  public void testProcess_QueryInURI() throws Exception {
    HttpHeaders headers = createNiceMock(HttpHeaders.class);
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1?foo=foo-value&bar=bar-value";
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    PredicateCompiler compiler = createStrictMock(PredicateCompiler.class);
    Predicate predicate = createNiceMock(Predicate.class);
    UriInfo uriInfo = createMock(UriInfo.class);
    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> queryParams = createMock(MultivaluedMap.class);
    RequestHandler handler = createStrictMock(RequestHandler.class);
    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();
    expect(resultStatus.isErrorState()).andReturn(false).anyTimes();
    processor.process(result);
View Full Code Here

    HttpHeaders headers = createNiceMock(HttpHeaders.class);
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1";
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> queryParams = createMock(MultivaluedMap.class);
    PredicateCompiler compiler = createStrictMock(PredicateCompiler.class);
    Predicate predicate = createNiceMock(Predicate.class);
    UriInfo uriInfo = createMock(UriInfo.class);
    RequestHandler handler = createStrictMock(RequestHandler.class);
    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();
    expect(resultStatus.isErrorState()).andReturn(false).anyTimes();
    processor.process(result);
View Full Code Here

  @Test
  public void testProcess_QueryInBodyAndURI() throws Exception {
    HttpHeaders headers = createNiceMock(HttpHeaders.class);
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1?bar=value";
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    PredicateCompiler compiler = createStrictMock(PredicateCompiler.class);
    Predicate predicate = createNiceMock(Predicate.class);
    UriInfo uriInfo = createMock(UriInfo.class);
    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> queryParams = createMock(MultivaluedMap.class);
    RequestHandler handler = createStrictMock(RequestHandler.class);
    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();
    expect(resultStatus.isErrorState()).andReturn(false).anyTimes();
    processor.process(result);
View Full Code Here

    UriInfo uriInfo = createMock(UriInfo.class);
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1";
    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> queryParams = createMock(MultivaluedMap.class);
    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,
        resourceDefinition, body);

    Result processResult = request.process();
View Full Code Here

  @Test
  public void testProcess_noBody_ErrorStateResult() throws Exception {
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1";
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    PredicateCompiler compiler = createStrictMock(PredicateCompiler.class);
    UriInfo uriInfo = createMock(UriInfo.class);
    @SuppressWarnings("unchecked")
    MultivaluedMap<String, String> queryParams = createMock(MultivaluedMap.class);
    RequestHandler handler = createStrictMock(RequestHandler.class);
    Result result = createMock(Result.class);
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.api.predicate.PredicateCompiler

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.