### Question:
AWSHandler extends XRayHandler { @Override public void handleRequest(Event event) { ServiceRequestEvent requestEvent = (ServiceRequestEvent) event; Request awsRequest = (Request) requestEvent.getRequest(); if (awsRequest.getServiceName() == null) { return; } tracingHandler.beforeRequest(awsRequest); } AWSHandler();  AWSHandler(URL serviceHandlerManifest); @Override void handleRequest(Event event); @Override void handleResponse(Event event);  }### Answer:
@Test public void testHandleAWSRequest() { ServiceDownstreamRequestEvent awsRequestEvent = new ServiceDownstreamRequestEvent(ORIGIN, SERVICE, OPERATION); awsRequestEvent.withRequest(awsRequest); awsHandler.handleRequest(awsRequestEvent); Subsegment awsSubsegment = AWSXRay.getCurrentSubsegment(); Assert.assertEquals("aws", awsSubsegment.getNamespace()); Assert.assertEquals(SERVICE, awsSubsegment.getName()); Assert.assertTrue(awsSubsegment.isInProgress()); Map<String, Object> awsMap = awsSubsegment.getAws(); Assert.assertEquals("Scan", awsMap.get("operation")); Assert.assertEquals(TABLE_NAME, awsMap.get("table_name")); Assert.assertEquals(parentSegment, awsSubsegment.getParentSegment()); Assert.assertEquals(1, parentSegment.getSubsegments().size()); }
@Test public void testPopulateTraceHeaderToHttpHeader() { ServiceDownstreamRequestEvent awsRequestEvent = new ServiceDownstreamRequestEvent(ORIGIN, SERVICE, OPERATION); awsRequestEvent.withRequest(awsRequest); awsHandler.handleRequest(awsRequestEvent); TraceID traceID = parentSegment.getTraceId(); String parentID = AWSXRay.getCurrentSubsegment().getId(); TraceHeader.SampleDecision sampleDecision = parentSegment.isSampled() ? TraceHeader.SampleDecision.SAMPLED : TraceHeader.SampleDecision.NOT_SAMPLED; TraceHeader theTraceHeader = new TraceHeader(traceID, parentID, sampleDecision); verify(awsRequest).addHeader(TraceHeader.HEADER_KEY, theTraceHeader.toString()); }