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

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


  }

  @Override
  public Predicate toPredicate(String prop, String val) throws InvalidQueryException {
    if (val == null) {
      throw new InvalidQueryException("Filter operator is missing a required right operand.");
    }
    return new FilterPredicate(prop, val);
  }
View Full Code Here


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

  @Test
  public void testHandleRequest__InvalidQueryException() throws Exception {
    Request request = createStrictMock(Request.class);
    ResourceInstance resource = createStrictMock(ResourceInstance.class);
    Query query = createMock(Query.class);
    InvalidQueryException exception = new InvalidQueryException("test");

    expect(request.getResource()).andReturn(resource);
    expect(resource.getQuery()).andReturn(query);

    expect(request.getFields()).andReturn(Collections.<String, TemporalInfo>emptyMap());

    expect(request.getQueryPredicate()).andThrow(exception);
    replay(request, resource, query);

    //test
    QueryCreateHandler handler = new QueryCreateHandler();
    Result result = handler.handleRequest(request);

    assertEquals(ResultStatus.STATUS.BAD_REQUEST, result.getStatus().getStatus());
    assertTrue(result.getStatus().getMessage().contains(exception.getMessage()));
    verify(request, resource, query);
  }
View Full Code Here

  @Override
  public Predicate toPredicate(String prop, String val) throws InvalidQueryException {

    if (val == null) {
      throw new InvalidQueryException("IN operator is missing a required right operand.");
    }

    String[] tokens = val.split(",");
    List<EqualsPredicate> listPredicates = new ArrayList<EqualsPredicate>();
    for (String token : tokens) {
View Full Code Here

  @Test
  public void testHandleRequest__InvalidQuery() throws Exception {
    Request request = createNiceMock(Request.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    Exception e = new InvalidQueryException("test exception");

    expect(request.getResource()).andReturn(resource);
    expect(request.getQueryPredicate()).andThrow(e);
    replay(request, resource);

    Result result = new CreateHandler().handleRequest(request);
    assertEquals(ResultStatus.STATUS.BAD_REQUEST, result.getStatus().getStatus());
    assertTrue(result.getStatus().getMessage().contains(e.getMessage()));

    verify(request, resource);
  }
View Full Code Here

  @Test
  public void testHandleRequest__InvalidQueryException() throws Exception {
    Request request = createStrictMock(Request.class);
    ResourceInstance resource = createStrictMock(ResourceInstance.class);
    Query query = createMock(Query.class);
    InvalidQueryException exception = new InvalidQueryException("test");

    expect(request.getResource()).andReturn(resource);
    expect(resource.getQuery()).andReturn(query);

    expect(request.getFields()).andReturn(Collections.<String, TemporalInfo>emptyMap());

    expect(request.getQueryPredicate()).andThrow(exception);
    replay(request, resource, query);

    //test
    ReadHandler handler = new ReadHandler();
    Result result = handler.handleRequest(request);

    assertEquals(ResultStatus.STATUS.BAD_REQUEST, result.getStatus().getStatus());
    assertTrue(result.getStatus().getMessage().contains(exception.getMessage()));
    verify(request, resource, query);
  }
View Full Code Here

  @Test
  public void testHandleRequest__InvalidQuery() throws Exception {
    Request request = createNiceMock(Request.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    Exception e = new InvalidQueryException("test exception");

    expect(request.getResource()).andReturn(resource);
    expect(request.getQueryPredicate()).andThrow(e);
    replay(request, resource);

    Result result = new UpdateHandler().handleRequest(request);
    assertEquals(ResultStatus.STATUS.BAD_REQUEST, result.getStatus().getStatus());
    assertTrue(result.getStatus().getMessage().contains(e.getMessage()));

    verify(request, resource);
  }
View Full Code Here

    UriInfo uriInfo = createMock(UriInfo.class);
    URI uri = new URI(URLEncoder.encode(uriString, "UTF-8"));

    expect(uriInfo.getRequestUri()).andReturn(uri);
    expect(compiler.compile(uriString.substring(uriString.indexOf("?") + 1))).
        andThrow(new InvalidQueryException("test"));
    replay(uriInfo, compiler);

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

    try {
View Full Code Here

  @Test
  public void testHandleRequest__InvalidQuery() throws Exception {
    Request request = createNiceMock(Request.class);
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    Exception e = new InvalidQueryException("test exception");

    expect(request.getResource()).andReturn(resource);
    expect(request.getQueryPredicate()).andThrow(e);
    replay(request, resource);

    Result result = new DeleteHandler().handleRequest(request);
    assertEquals(ResultStatus.STATUS.BAD_REQUEST, result.getStatus().getStatus());
    assertTrue(result.getStatus().getMessage().contains(e.getMessage()));

    verify(request, resource);
  }
View Full Code Here

  @Override
  public Predicate toPredicate(String prop, String val) throws InvalidQueryException {

    if (val == null) {
      throw new InvalidQueryException("IN operator is missing a required right operand.");
    }

    String[] tokens = val.split(",");
    List<EqualsPredicate> listPredicates = new ArrayList<EqualsPredicate>();
    for (String token : tokens) {
View Full Code Here

TOP

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

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.