use of com.azure.core.test.http.MockHttpResponse in project ApplicationInsights-Java by microsoft.
the class IntegrationTests method setup.
@BeforeEach
public void setup() throws Exception {
HttpClient mockedClient = mock(HttpClient.class);
if (testWithException) {
when(mockedClient.send(any(HttpRequest.class), any(Context.class))).then(invocation -> Mono.error(() -> new Exception("this is expected to be logged by the operation logger")));
} else {
// 401, 403, 408, 429, 500, and 503 response codes result in storing to disk
when(mockedClient.send(any(HttpRequest.class), any(Context.class))).then(invocation -> Mono.just(new MockHttpResponse(invocation.getArgument(0, HttpRequest.class), 500)));
}
HttpPipelineBuilder pipelineBuilder = new HttpPipelineBuilder().httpClient(mockedClient);
localFileCache = new LocalFileCache(tempFolder);
localFileLoader = new LocalFileLoader(localFileCache, tempFolder, null);
StatsbeatModule statsbeatModule = Mockito.mock(StatsbeatModule.class);
when(statsbeatModule.getNetworkStatsbeat()).thenReturn(Mockito.mock(NetworkStatsbeat.class));
telemetryChannel = new TelemetryChannel(pipelineBuilder.build(), new URL("http://foo.bar"), new LocalFileWriter(localFileCache, tempFolder, null), statsbeatModule, false);
}
Aggregations