use of com.google.api.client.util.Sleeper in project beam by apache.
the class RetryHttpRequestInitializerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
HttpTransport lowLevelTransport = new HttpTransport() {
@Override
protected LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
return mockLowLevelRequest;
}
};
// Retry initializer will pass through to credential, since we can have
// only a single HttpRequestInitializer, and we use multiple Credential
// types in the SDK, not all of which allow for retry configuration.
RetryHttpRequestInitializer initializer = new RetryHttpRequestInitializer(new MockNanoClock(), new Sleeper() {
@Override
public void sleep(long millis) throws InterruptedException {
}
}, Arrays.asList(418), mockHttpResponseInterceptor);
storage = new Storage.Builder(lowLevelTransport, jsonFactory, initializer).setApplicationName("test").build();
}
use of com.google.api.client.util.Sleeper in project beam by apache.
the class BigQueryServicesImplTest method testStartLoadJobSucceedsAlreadyExists.
/**
* Tests that {@link BigQueryServicesImpl.JobServiceImpl#startLoadJob} succeeds
* with an already exist job.
*/
@Test
public void testStartLoadJobSucceedsAlreadyExists() throws IOException, InterruptedException {
Job testJob = new Job();
JobReference jobRef = new JobReference();
jobRef.setJobId("jobId");
jobRef.setProjectId("projectId");
testJob.setJobReference(jobRef);
// 409 means already exists
when(response.getStatusCode()).thenReturn(409);
Sleeper sleeper = new FastNanoClockAndSleeper();
JobServiceImpl.startJob(testJob, new ApiErrorExtractor(), bigquery, sleeper, BackOffAdapter.toGcpBackOff(FluentBackoff.DEFAULT.backoff()));
verify(response, times(1)).getStatusCode();
verify(response, times(1)).getContent();
verify(response, times(1)).getContentType();
expectedLogs.verifyNotLogged("Started BigQuery job");
}
Aggregations