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

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


  @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);
    RequestHandler handler = createStrictMock(RequestHandler.class);
    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.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);
    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);

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

    //expectations
    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

  @Test
  public void testProcess_QueryInBody() throws Exception {
    HttpHeaders headers = createNiceMock(HttpHeaders.class);
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1";
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    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);

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

    //expectations
    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);
    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);

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

    //expectations
    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_WithBody_InvalidQuery() throws Exception {
    UriInfo uriInfo = createMock(UriInfo.class);
    String uriString = "http://localhost.com:8080/api/v1/clusters/c1";
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));
    PredicateCompiler compiler = createStrictMock(PredicateCompiler.class);
    RequestBody body = createNiceMock(RequestBody.class);
    Exception exception = new InvalidQueryException("test");

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

    //expectations
    expect(uriInfo.getRequestUri()).andReturn(uri).anyTimes();
    expect(body.getQueryString()).andReturn("blahblahblah");
    expect(compiler.compile("blahblahblah")).andThrow(exception);

    replay(compiler, uriInfo, 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);
    RequestHandler handler = createStrictMock(RequestHandler.class);
    Result result = createMock(Result.class);
    ResultStatus resultStatus = createMock(ResultStatus.class);
    ResultPostProcessor processor = createStrictMock(ResultPostProcessor.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.