### Question:
IntakeV2ReportingEventHandler extends AbstractIntakeApiHandler implements ReportingEventHandler { @Override public void endRequest() { cancelTimeout(); super.endRequest(); } IntakeV2ReportingEventHandler(ReporterConfiguration reporterConfiguration, ProcessorEventHandler processorEventHandler,
                                         PayloadSerializer payloadSerializer, MetaData metaData, ApmServerClient apmServerClient); @Override void init(ApmServerReporter reporter); @Override void onEvent(ReportingEvent event, long sequence, boolean endOfBatch); @Override void endRequest(); @Override void close(); static final String INTAKE_V2_URL; }### Answer:
@Test void testShutDown() { reportTransaction(reportingEventHandler); sendShutdownEvent(); reportSpan(); reportingEventHandler.endRequest(); final List<JsonNode> ndJsonNodes = getNdJsonNodes(); assertThat(ndJsonNodes).hasSize(2); assertThat(ndJsonNodes.get(0).get("metadata")).isNotNull(); assertThat(ndJsonNodes.get(1).get("transaction")).isNotNull(); }
@Test void testReportRoundRobinOnServerError() { mockApmServer1.stubFor(post(INTAKE_V2_URL).willReturn(serviceUnavailable())); reportTransaction(reportingEventHandler); reportingEventHandler.endRequest(); mockApmServer1.verify(postRequestedFor(urlEqualTo(INTAKE_V2_URL))); mockApmServer2.verify(0, postRequestedFor(urlEqualTo(INTAKE_V2_URL))); mockApmServer1.resetRequests(); mockApmServer2.resetRequests(); reportTransaction(reportingEventHandler); reportingEventHandler.endRequest(); mockApmServer1.verify(0, postRequestedFor(urlEqualTo(INTAKE_V2_URL))); mockApmServer2.verify(postRequestedFor(urlEqualTo(APM_SERVER_PATH + INTAKE_V2_URL))); }