Class MockHttpTransport.Builder
- java.lang.Object
-
- com.google.api.client.testing.http.MockHttpTransport.Builder
-
- Enclosing class:
- MockHttpTransport
@Beta public static class MockHttpTransport.Builder extends java.lang.Object
- Since:
- 1.5
-
-
Field Summary
Fields Modifier and Type Field Description (package private) MockLowLevelHttpRequest
lowLevelHttpRequest
TheMockLowLevelHttpRequest
to be returned byMockHttpTransport.buildRequest(java.lang.String, java.lang.String)
.(package private) MockLowLevelHttpResponse
lowLevelHttpResponse
TheMockLowLevelHttpResponse
that should be the result of theMockLowLevelHttpRequest
to be returned byMockHttpTransport.buildRequest(java.lang.String, java.lang.String)
.(package private) java.util.Set<java.lang.String>
supportedMethods
Supported HTTP methods ornull
to specify that all methods are supported.
-
Constructor Summary
Constructors Constructor Description Builder()
Constructs a newMockHttpTransport.Builder
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MockHttpTransport
build()
Builds a new instance ofMockHttpTransport
.MockLowLevelHttpRequest
getLowLevelHttpRequest()
Returns theMockLowLevelHttpRequest
that is associated with thisMockHttpTransport.Builder
, ornull
if no such instance exists.(package private) MockLowLevelHttpResponse
getLowLevelHttpResponse()
Returns theMockLowLevelHttpResponse
that is associated with thisMockHttpTransport.Builder
, ornull
if no such instance exists.java.util.Set<java.lang.String>
getSupportedMethods()
Returns the supported HTTP methods ornull
to specify that all methods are supported.MockHttpTransport.Builder
setLowLevelHttpRequest(MockLowLevelHttpRequest lowLevelHttpRequest)
Sets theMockLowLevelHttpRequest
that will be returned byMockHttpTransport.buildRequest(java.lang.String, java.lang.String)
, if non-null
.MockHttpTransport.Builder
setLowLevelHttpResponse(MockLowLevelHttpResponse lowLevelHttpResponse)
Sets theMockLowLevelHttpResponse
that will be the result when theMockLowLevelHttpRequest
returned byMockHttpTransport.buildRequest(java.lang.String, java.lang.String)
is executed.MockHttpTransport.Builder
setSupportedMethods(java.util.Set<java.lang.String> supportedMethods)
Sets the supported HTTP methods ornull
to specify that all methods are supported.
-
-
-
Field Detail
-
supportedMethods
java.util.Set<java.lang.String> supportedMethods
Supported HTTP methods ornull
to specify that all methods are supported.
-
lowLevelHttpRequest
MockLowLevelHttpRequest lowLevelHttpRequest
TheMockLowLevelHttpRequest
to be returned byMockHttpTransport.buildRequest(java.lang.String, java.lang.String)
. If this field isnull
,MockHttpTransport.buildRequest(java.lang.String, java.lang.String)
will create a new instance from its arguments.
-
lowLevelHttpResponse
MockLowLevelHttpResponse lowLevelHttpResponse
TheMockLowLevelHttpResponse
that should be the result of theMockLowLevelHttpRequest
to be returned byMockHttpTransport.buildRequest(java.lang.String, java.lang.String)
. Note that this field is ignored if the caller provides aMockLowLevelHttpRequest
viasetLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest)
.
-
-
Constructor Detail
-
Builder
public Builder()
Constructs a newMockHttpTransport.Builder
. Note that this constructor wasprotected
in version 1.17 and its predecessors, and was madepublic
in version 1.18.
-
-
Method Detail
-
build
public MockHttpTransport build()
Builds a new instance ofMockHttpTransport
.
-
getSupportedMethods
public final java.util.Set<java.lang.String> getSupportedMethods()
Returns the supported HTTP methods ornull
to specify that all methods are supported.
-
setSupportedMethods
public final MockHttpTransport.Builder setSupportedMethods(java.util.Set<java.lang.String> supportedMethods)
Sets the supported HTTP methods ornull
to specify that all methods are supported.
-
setLowLevelHttpRequest
public final MockHttpTransport.Builder setLowLevelHttpRequest(MockLowLevelHttpRequest lowLevelHttpRequest)
Sets theMockLowLevelHttpRequest
that will be returned byMockHttpTransport.buildRequest(java.lang.String, java.lang.String)
, if non-null
. Ifnull
,MockHttpTransport.buildRequest(java.lang.String, java.lang.String)
will create a newMockLowLevelHttpRequest
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.
- Since:
- 1.18
-
getLowLevelHttpRequest
public final MockLowLevelHttpRequest getLowLevelHttpRequest()
Returns theMockLowLevelHttpRequest
that is associated with thisMockHttpTransport.Builder
, ornull
if no such instance exists.- Since:
- 1.18
-
setLowLevelHttpResponse
public final MockHttpTransport.Builder setLowLevelHttpResponse(MockLowLevelHttpResponse lowLevelHttpResponse)
Sets theMockLowLevelHttpResponse
that will be the result when theMockLowLevelHttpRequest
returned byMockHttpTransport.buildRequest(java.lang.String, java.lang.String)
is executed. Note that the response can be set only the caller has not provided aMockLowLevelHttpRequest
viasetLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest)
.- Throws:
java.lang.IllegalStateException
- if the caller has already set aLowLevelHttpRequest
in this instance- Since:
- 1.18
-
getLowLevelHttpResponse
MockLowLevelHttpResponse getLowLevelHttpResponse()
Returns theMockLowLevelHttpResponse
that is associated with thisMockHttpTransport.Builder
, ornull
if no such instance exists.- Since:
- 1.18
-
-