Java Code Examples for com.sun.jersey.api.client.ClientResponse#Status

The following examples show how to use com.sun.jersey.api.client.ClientResponse#Status . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestTimelineClient.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private static ClientResponse mockEntityClientResponse(
    TimelineClientImpl client, ClientResponse.Status status,
    boolean hasError, boolean hasRuntimeError) {
  ClientResponse response = mock(ClientResponse.class);
  if (hasRuntimeError) {
    doThrow(new ClientHandlerException(new ConnectException())).when(client)
        .doPostingObject(any(TimelineEntities.class), any(String.class));
    return response;
  }
  doReturn(response).when(client)
      .doPostingObject(any(TimelineEntities.class), any(String.class));
  when(response.getClientResponseStatus()).thenReturn(status);
  TimelinePutResponse.TimelinePutError error =
      new TimelinePutResponse.TimelinePutError();
  error.setEntityId("test entity id");
  error.setEntityType("test entity type");
  error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION);
  TimelinePutResponse putResponse = new TimelinePutResponse();
  if (hasError) {
    putResponse.addError(error);
  }
  when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse);
  return response;
}
 
Example 2
Source File: TestTimelineClient.java    From big-c with Apache License 2.0 6 votes vote down vote up
private static ClientResponse mockEntityClientResponse(
    TimelineClientImpl client, ClientResponse.Status status,
    boolean hasError, boolean hasRuntimeError) {
  ClientResponse response = mock(ClientResponse.class);
  if (hasRuntimeError) {
    doThrow(new ClientHandlerException(new ConnectException())).when(client)
        .doPostingObject(any(TimelineEntities.class), any(String.class));
    return response;
  }
  doReturn(response).when(client)
      .doPostingObject(any(TimelineEntities.class), any(String.class));
  when(response.getClientResponseStatus()).thenReturn(status);
  TimelinePutResponse.TimelinePutError error =
      new TimelinePutResponse.TimelinePutError();
  error.setEntityId("test entity id");
  error.setEntityType("test entity type");
  error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION);
  TimelinePutResponse putResponse = new TimelinePutResponse();
  if (hasError) {
    putResponse.addError(error);
  }
  when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse);
  return response;
}
 
Example 3
Source File: TestTimelineClient.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static ClientResponse mockDomainClientResponse(
    TimelineClientImpl client, ClientResponse.Status status,
    boolean hasRuntimeError) {
  ClientResponse response = mock(ClientResponse.class);
  if (hasRuntimeError) {
    doThrow(new ClientHandlerException(new ConnectException())).when(client)
        .doPostingObject(any(TimelineDomain.class), any(String.class));
    return response;
  }
  doReturn(response).when(client)
      .doPostingObject(any(TimelineDomain.class), any(String.class));
  when(response.getClientResponseStatus()).thenReturn(status);
  return response;
}
 
Example 4
Source File: TestTimelineClient.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static ClientResponse mockDomainClientResponse(
    TimelineClientImpl client, ClientResponse.Status status,
    boolean hasRuntimeError) {
  ClientResponse response = mock(ClientResponse.class);
  if (hasRuntimeError) {
    doThrow(new ClientHandlerException(new ConnectException())).when(client)
        .doPostingObject(any(TimelineDomain.class), any(String.class));
    return response;
  }
  doReturn(response).when(client)
      .doPostingObject(any(TimelineDomain.class), any(String.class));
  when(response.getClientResponseStatus()).thenReturn(status);
  return response;
}
 
Example 5
Source File: AtlasServiceException.java    From atlas with Apache License 2.0 4 votes vote down vote up
private AtlasServiceException(AtlasBaseClient.API api, ClientResponse.Status status, String response) {
    super("Metadata service API " + api + " failed with status " + (status != null ? status.getStatusCode() : -1)
            + " (" + status + ") Response Body (" + response + ")");
    this.status = status;
}
 
Example 6
Source File: AtlasServiceException.java    From atlas with Apache License 2.0 4 votes vote down vote up
public ClientResponse.Status getStatus() {
    return status;
}
 
Example 7
Source File: AtlasServiceException.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
private AtlasServiceException(AtlasClient.API api, ClientResponse.Status status, String response) {
    super("Metadata service API " + api + " failed with status " + (status != null ? status.getStatusCode() : -1)
            + " (" + status + ") Response Body (" + response + ")");
    this.status = status;
}
 
Example 8
Source File: AtlasServiceException.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
private AtlasServiceException(AtlasBaseClient.APIInfo api, ClientResponse.Status status, String response) {
    super("Metadata service API " + api + " failed with status " + (status != null ? status.getStatusCode() : -1)
            + " (" + status + ") Response Body (" + response + ")");
    this.status = status;
}
 
Example 9
Source File: AtlasServiceException.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
public ClientResponse.Status getStatus() {
    return status;
}