use of org.apache.beam.sdk.util.RetryHttpRequestInitializer in project beam by apache.
the class BigQueryServicesImplTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
// A mock transport that lets us mock the API responses.
MockHttpTransport transport = new MockHttpTransport.Builder().setLowLevelHttpRequest(new MockLowLevelHttpRequest() {
@Override
public LowLevelHttpResponse execute() throws IOException {
return response;
}
}).build();
// A sample BigQuery API client that uses default JsonFactory and RetryHttpInitializer.
bigquery = new Bigquery.Builder(transport, Transport.getJsonFactory(), new RetryHttpRequestInitializer()).build();
}
use of org.apache.beam.sdk.util.RetryHttpRequestInitializer in project beam by apache.
the class V1TestUtil method getDatastore.
/**
* Build a new datastore client.
*/
static Datastore getDatastore(PipelineOptions pipelineOptions, String projectId) {
Credentials credential = pipelineOptions.as(GcpOptions.class).getGcpCredential();
HttpRequestInitializer initializer;
if (credential != null) {
initializer = new ChainingHttpRequestInitializer(new HttpCredentialsAdapter(credential), new RetryHttpRequestInitializer());
} else {
initializer = new RetryHttpRequestInitializer();
}
DatastoreOptions.Builder builder = new DatastoreOptions.Builder().projectId(projectId).initializer(initializer);
return DatastoreFactory.get().create(builder.build());
}
Aggregations