Class GoogleJsonResponseExceptionFactoryTesting (2.1.0)

public final class GoogleJsonResponseExceptionFactoryTesting

Beta
Factory class that builds GoogleJsonResponseException instances for testing.

Inheritance

java.lang.Object > GoogleJsonResponseExceptionFactoryTesting

Static Methods

newMock(JsonFactory jsonFactory, int httpCode, String reasonPhrase)

public static GoogleJsonResponseException newMock(JsonFactory jsonFactory, int httpCode, String reasonPhrase)

Convenience factory method that builds a GoogleJsonResponseException from its arguments. The method builds a dummy HttpRequest and HttpResponse, sets the response's status to a user-specified HTTP error code, suppresses exceptions, and executes the request. This forces the underlying framework to create, but not throw, a GoogleJsonResponseException, which the method retrieves and returns to the invoker.

Parameters
NameDescription
jsonFactorycom.google.api.client.json.JsonFactory

the JSON factory that will create all JSON required by the underlying framework

httpCodeint

the desired HTTP error code. Note: do nut specify any codes that indicate successful completion, e.g. 2XX.

reasonPhraseString

the HTTP reason code that explains the error. For example, if httpCode is 404, the reason phrase should be NOT FOUND.

Returns
TypeDescription
GoogleJsonResponseException

the generated GoogleJsonResponseException, as specified.

Exceptions
TypeDescription
IOException

if request transport fails.

Constructors

GoogleJsonResponseExceptionFactoryTesting()

public GoogleJsonResponseExceptionFactoryTesting()