Package com.linkedin.restli.server

Examples of com.linkedin.restli.server.RestLiServiceException


    {
      String stringParam = param.getStringParameter();
      Integer intParam = param.getIntParameter();
      if (stringParam == null || intParam == null || !stringParam.equals(intParam.toString()))
      {
        throw new RestLiServiceException(S_400_BAD_REQUEST, "The values of testParam parameter don't match");
      }
    }
    return fromGroupMembership(_app.getMembershipMgr().get(complexKeyToCompoundKey(id)));
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  @Test
  public void testOnErrorRestLiServiceExceptionNoFilters() throws Exception
  {
    RestLiServiceException ex = new RestLiServiceException(HttpStatus.S_404_NOT_FOUND);
    RequestExecutionReport executionReport = new RequestExecutionReportBuilder().build();
    Map<String, String> inputHeaders = Maps.newHashMap();
    inputHeaders.put(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION,
                     AllProtocolVersions.BASELINE_PROTOCOL_VERSION.toString());

    Map<String, String> restExceptionHeaders = Maps.newHashMap();
    restExceptionHeaders.put("foo", "bar");

    @SuppressWarnings("rawtypes")
    ArgumentCaptor<Map> augErrorHeadersCapture = ArgumentCaptor.forClass(Map.class);
    AugmentedRestLiResponseData responseData =
        new AugmentedRestLiResponseData.Builder(ResourceMethod.GET).status(ex.getStatus()).headers(restExceptionHeaders).build();
    PartialRestResponse partialResponse = new PartialRestResponse.Builder().build();
    RestException restException = new RestException(new RestResponseBuilder().build());
    // Set up.
    when(_restRequest.getHeaders()).thenReturn(inputHeaders);
    when(
View Full Code Here

  public BatchUpdateResult<Long, Greeting> batchUpdate(BatchUpdateRequest<Long, Greeting> entities)
  {
    final Map<Long, UpdateResponse> responseMap = new HashMap<Long, UpdateResponse>();
    responseMap.put(3l, new UpdateResponse(HttpStatus.S_201_CREATED));
    final Map<Long, RestLiServiceException> errorsMap = new HashMap<Long, RestLiServiceException>();
    errorsMap.put(8l, new RestLiServiceException(HttpStatus.S_202_ACCEPTED));
    if (entities.getData().containsKey(1l))
    {
      //Return a null BatchUpdateResult
      return null;
    }
    else if (entities.getData().containsKey(2l))
    {
      //Return a BatchUpdateResult with a null results Map
      return new BatchUpdateResult<Long, Greeting>(null);
    }
    else if (entities.getData().containsKey(3l))
    {
      //Return a BatchUpdateResult with a null errors Map
      return new BatchUpdateResult<Long, Greeting>(responseMap, null);
    }
    else if (entities.getData().containsKey(4l))
    {
      //Return a BatchUpdateResult with a errors Map that has a null key in it
      errorsMap.put(null, new RestLiServiceException(HttpStatus.S_202_ACCEPTED));
      return new BatchUpdateResult<Long, Greeting>(responseMap, errorsMap);
    }
    else if (entities.getData().containsKey(5l))
    {
      //Return a BatchUpdateResult with a errors Map that has a null value in it
View Full Code Here

    verify(_responseHandler).buildRestException(ex, partialResponse);
    verify(_callback).onError(restException, executionReport);
    verify(_restRequest, times(1)).getHeaders();
    verifyZeroInteractions(_routingResult);
    verifyNoMoreInteractions(_restRequest, _responseHandler, _callback);
    RestLiServiceException restliEx = exCapture.getValue();
    assertNotNull(restliEx);
    if (ex instanceof RoutingException)
    {
      assertEquals(HttpStatus.fromCode(((RoutingException) ex).getStatus()), restliEx.getStatus());
    }
    else
    {
      assertEquals(HttpStatus.S_500_INTERNAL_SERVER_ERROR, restliEx.getStatus());
    }
    assertEquals(ex.getMessage(), restliEx.getMessage());
    assertEquals(ex, restliEx.getCause());
  }
View Full Code Here

  @Override
  public BatchUpdateResult<CompoundKey, Message> batchUpdate(BatchUpdateRequest<CompoundKey, Message> entities)
  {
    if (!entities.getData().equals(DB))
    {
      throw new RestLiServiceException(HttpStatus.S_417_EXPECTATION_FAILED);
    }

    return buildUpdateResult(entities.getData().keySet());
  }
View Full Code Here

  @Override
  public BatchUpdateResult<CompoundKey, Message> batchUpdate(BatchPatchRequest<CompoundKey, Message> patches)
  {
    if (!patches.getData().keySet().equals(DB.keySet()))
    {
      throw new RestLiServiceException(HttpStatus.S_417_EXPECTATION_FAILED);
    }

    return buildUpdateResult(patches.getData().keySet());
  }
View Full Code Here

      {
        data.put(key, _db.get(stringKey));
      }
      else
      {
        errors.put(key, new RestLiServiceException(HttpStatus.S_404_NOT_FOUND));
      }
    }

    return new BatchResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message>(data, errors);
  }
View Full Code Here

        _db.put(keyToString(entry.getKey().getKey()), entry.getValue());
        results.put(entry.getKey(), new UpdateResponse(HttpStatus.S_200_OK));
      }
      else
      {
        errors.put(entry.getKey(), new RestLiServiceException(HttpStatus.S_404_NOT_FOUND));
      }
    }

    return new BatchUpdateResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message>(results, errors);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.restli.server.RestLiServiceException

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.