Package com.linkedin.restli.common

Examples of com.linkedin.restli.common.ErrorResponse


  {
    MockFailedResponseFutureBuilder<Long, Greeting> builder = new MockFailedResponseFutureBuilder<Long, Greeting>();
    builder.setEntity(new Greeting());
    try
    {
      builder.setErrorResponse(new ErrorResponse());
      Assert.fail();
    }
    catch (IllegalStateException e)
    {
      // expected
    }

    builder = new MockFailedResponseFutureBuilder<Long, Greeting>();
    builder.setErrorResponse(new ErrorResponse());
    try
    {
      builder.setEntity(new Greeting());
      Assert.fail();
    }
View Full Code Here


  }

  private ResponseFuture<Greeting> buildWithErrorResponse(ErrorHandlingBehavior errorHandlingBehavior)
  {
    MockFailedResponseFutureBuilder<Long, Greeting> builder = new MockFailedResponseFutureBuilder<Long, Greeting>();
    ErrorResponse errorResponse = new ErrorResponse().setStatus(404).setMessage("foo");

    builder.setErrorResponse(errorResponse).setErrorHandlingBehavior(errorHandlingBehavior);
    return builder.build();
  }
View Full Code Here

    Map<Long, ErrorResponse> errorResponses = new HashMap<Long, ErrorResponse>();

    recordTemplates.put(1L, buildGreeting(1L));
    recordTemplates.put(2L, buildGreeting(2L));

    errorResponses.put(3L, new ErrorResponse().setMessage("3"));

    BatchKVResponse<Long, Greeting> response = MockBatchKVResponseFactory.createWithPrimitiveKey(Long.class,
                                                                                                 Greeting.class,
                                                                                                 recordTemplates,
                                                                                                 errorResponses);
View Full Code Here

    Map<MyCustomString, Greeting> recordTemplates = new HashMap<MyCustomString, Greeting>();
    Map<MyCustomString, ErrorResponse> errorResponses = new HashMap<MyCustomString, ErrorResponse>();

    recordTemplates.put(m1, buildGreeting(1L));
    recordTemplates.put(m2, buildGreeting(2L));
    errorResponses.put(m3, new ErrorResponse().setMessage("3"));

    BatchKVResponse<MyCustomString, Greeting> response = MockBatchKVResponseFactory.createWithCustomTyperefKey(
        MyCustomString.class,
        MyCustomStringRef.class,
        Greeting.class,
View Full Code Here

    Map<CompoundKey, Greeting> recordTemplates = new HashMap<CompoundKey, Greeting>();
    recordTemplates.put(c1, buildGreeting(1L));
    recordTemplates.put(c2, buildGreeting(2L));

    Map<CompoundKey, ErrorResponse> errorResponses = new HashMap<CompoundKey, ErrorResponse>();
    errorResponses.put(c3, new ErrorResponse().setMessage("3"));

    Map<String, CompoundKey.TypeInfo> keyParts = new HashMap<String, CompoundKey.TypeInfo>();
    keyParts.put("part1", new CompoundKey.TypeInfo(String.class, String.class));
    keyParts.put("part2", new CompoundKey.TypeInfo(Integer.class, Integer.class));
View Full Code Here

    Greeting g3 = buildGreeting(3L);

    recordTemplates.put(new ComplexResourceKey<Greeting, Greeting>(g1, g1), g1);
    recordTemplates.put(new ComplexResourceKey<Greeting, Greeting>(g2, g2), g2);

    errorResponses.put(new ComplexResourceKey<Greeting, Greeting>(g3, g3), new ErrorResponse().setMessage("3"));

    BatchKVResponse<ComplexResourceKey<Greeting, Greeting>, Greeting> response =
        MockBatchKVResponseFactory.createWithComplexKey(Greeting.class,
                                                        Greeting.class,
                                                        Greeting.class,
                                                        recordTemplates,
                                                        errorResponses);

    Map<ComplexResourceKey, Greeting> storedResults = new HashMap<ComplexResourceKey, Greeting>();
    for (Map.Entry<ComplexResourceKey<Greeting, Greeting>, Greeting> entry: recordTemplates.entrySet())
    {
      storedResults.put(new ComplexResourceKey<Greeting, Greeting>(entry.getKey().getKey(),
                                                                   new Greeting()), entry.getValue());
    }

    Map<ComplexResourceKey, ErrorResponse> storedErrorResponses = new HashMap<ComplexResourceKey, ErrorResponse>();
    storedErrorResponses.put(new ComplexResourceKey<Greeting, Greeting>(g3, new Greeting()),
                             new ErrorResponse().setMessage("3"));

    Assert.assertEquals(response.getResults(), storedResults);
    Assert.assertEquals(response.getErrors(), storedErrorResponses);
  }
View Full Code Here

  public ResponseFuture<V> build()
  {
    if (_errorResponse == null && getEntity() == null)
    {
      // Create an ErrorResponse from the status, or use the DEFAULT_HTTP_STATUS to build one
      _errorResponse = new ErrorResponse();
      _errorResponse.setStatus(getStatus());
    }

    _errorHandlingBehavior = (_errorHandlingBehavior == null) ?
        ErrorHandlingBehavior.FAIL_ON_ERROR : _errorHandlingBehavior;
View Full Code Here

        .setHeaders(decodedResponse.getHeaders())
        .build();

    RestLiResponseException restLiResponseException = new RestLiResponseException(restResponse,
                                                                                  decodedResponse,
                                                                                  new ErrorResponse());
    ExecutionException executionException = new ExecutionException(restLiResponseException);

    Future<Response<V>> responseFuture = buildFuture(null, executionException);
    return new ResponseFutureImpl<V>(responseFuture, _errorHandlingBehavior);
  }
View Full Code Here

            {
              greeting.setTone(mapToneForOutgoingResponse(greeting.getTone()));
              responseContext.getResponseData().setEntityResponse(greeting);
            }
          }
          ErrorResponse errorResponse = responseContext.getResponseData().getErrorResponse();
          if (errorResponse != null && requestContext.getMethodType() == ResourceMethod.CREATE
              && responseContext.getHttpStatus() == REQ_FILTER_ERROR_STATUS)
          {
            errorResponse.setMessage(RESP_FILTER_ERROR_MESSAGE);
            responseContext.setHttpStatus(RESP_FILTER_ERROR_STATUS);
          }
          return null;
        }
      }).when(_responseFilter).onResponse(any(FilterRequestContext.class), any(FilterResponseContext.class));
View Full Code Here

    super(cause);
  }

  public ErrorResponse toErrorResponse()
  {
    ErrorResponse response = new ErrorResponse();
    response.setStatus(RestStatus.INTERNAL_SERVER_ERROR);
    response.setExceptionClass(RestLiInternalException.class.getName());
    if (getMessage() != null)
    {
      response.setMessage(getMessage());
    }

    return response;
  }
View Full Code Here

TOP

Related Classes of com.linkedin.restli.common.ErrorResponse

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.