# Class MockHttpTransport.Builder (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockHttpTransport.Builder)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.testing.http.MockHttpTransport.Builder)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.testing.http.MockHttpTransport.Builder)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.testing.http.MockHttpTransport.Builder)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.testing.http.MockHttpTransport.Builder)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.testing.http.MockHttpTransport.Builder)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.testing.http.MockHttpTransport.Builder)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.testing.http.MockHttpTransport.Builder)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.testing.http.MockHttpTransport.Builder)

    public static class MockHttpTransport.Builder

[Beta](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Beta)   

Builder for [MockHttpTransport](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockHttpTransport).

Implementation is not thread-safe.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> MockHttpTransport.Builder

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### Builder()

    public Builder()

Constructs a new Builder. Note that this constructor was `protected` in version
1.17 and its predecessors, and was made `public` in version 1.18.

## Methods

### build()

    public MockHttpTransport build()

Builds a new instance of [MockHttpTransport](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockHttpTransport).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockHttpTransport` |   |

### getLowLevelHttpRequest()

    public final MockLowLevelHttpRequest getLowLevelHttpRequest()

Returns the [MockLowLevelHttpRequest](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpRequest) that is associated with this Builder, or
`null` if no such instance exists.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpRequest` |   |

### getSupportedMethods()

    public final Set<String> getSupportedMethods()

Returns the supported HTTP methods or `null` to specify that all methods are supported.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Set.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### setLowLevelHttpRequest(MockLowLevelHttpRequest lowLevelHttpRequest)

    public final MockHttpTransport.Builder setLowLevelHttpRequest(MockLowLevelHttpRequest lowLevelHttpRequest)

Sets the [MockLowLevelHttpRequest](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpRequest) that will be returned by #buildRequest, if
non-`null`. If `null`, #buildRequest will create a new [MockLowLevelHttpRequest](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpRequest) arguments.

Note that the user can set a low level HTTP Request only if a low level HTTP response has
not been set on this instance.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `lowLevelHttpRequest` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpRequest` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockHttpTransport.Builder` |   |

### setLowLevelHttpResponse(MockLowLevelHttpResponse lowLevelHttpResponse)

    public final MockHttpTransport.Builder setLowLevelHttpResponse(MockLowLevelHttpResponse lowLevelHttpResponse)

Sets the [MockLowLevelHttpResponse](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpResponse) that will be the result when the [MockLowLevelHttpRequest](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpRequest) returned by #buildRequest is executed. Note that the
response can be set only the caller has not provided a [MockLowLevelHttpRequest](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpRequest) via
[#setLowLevelHttpRequest](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockHttpTransport.Builder#com_google_api_client_testing_http_MockHttpTransport_Builder_setLowLevelHttpRequest_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `lowLevelHttpResponse` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockLowLevelHttpResponse` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockHttpTransport.Builder` |   |

### setSupportedMethods(Set\<String\> supportedMethods)

    public final MockHttpTransport.Builder setSupportedMethods(Set<String> supportedMethods)

Sets the supported HTTP methods or `null` to specify that all methods are supported.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `supportedMethods` | `https://docs.oracle.com/javase/8/docs/api/java/util/Set.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.testing.http.MockHttpTransport.Builder` |   |