@Test void testReportSpan() throws ExecutionException, InterruptedException { reporter.report(new Span(MockTracer.create())); reporter.flush().get(); assertThat(reporter.getDropped()).isEqualTo(0); assertThat(receivedHttpRequests.get()).isEqualTo(1); }
@Test void testReportErrorCapture() throws ExecutionException, InterruptedException { reporter.report(new ErrorCapture(MockTracer.create())); reporter.flush().get(); assertThat(reporter.getDropped()).isEqualTo(0); assertThat(receivedHttpRequests.get()).isEqualTo(1); }
@Test void testReportTransaction() throws ExecutionException, InterruptedException { reporter.report(new Transaction(MockTracer.create())); reporter.flush().get(); assertThat(reporter.getDropped()).isEqualTo(0); assertThat(receivedHttpRequests.get()).isEqualTo(1); }
@Test void testTransactionProcessor() throws Exception { reporter.report(new Transaction(mock(ElasticApmTracer.class))); reporter.flush().get(); assertThat(reporter.getDropped()).isEqualTo(0); verify(reportingEventHandler).onEvent(notNull(ReportingEvent::getTransaction), anyLong(), anyBoolean()); }
@Test void testErrorProcessor() throws Exception { reporter.report(new ErrorCapture(MockTracer.create())); reporter.flush().get(); assertThat(reporter.getDropped()).isEqualTo(0); verify(reportingEventHandler).onEvent(notNull(ReportingEvent::getError), anyLong(), anyBoolean()); }
@Test void testSecretToken() throws ExecutionException, InterruptedException { when(reporterConfiguration.getSecretToken()).thenReturn("token"); handler = exchange -> { assertThat(exchange.getRequestHeaders().get("Authorization").getFirst()).isEqualTo("Bearer token"); receivedHttpRequests.incrementAndGet(); exchange.setStatusCode(200).endExchange(); }; reporter.report(new Transaction(MockTracer.create())); reporter.flush().get(); assertThat(reporter.getDropped()).isEqualTo(0); assertThat(receivedHttpRequests.get()).isEqualTo(1); }