### Question:
Log4JSegmentListener implements SegmentListener { @Override public void onSetEntity(Entity oldEntity, Entity newEntity) { if (newEntity == null) { ThreadContext.remove(TRACE_ID_KEY); return; } Segment segment = newEntity instanceof Segment ? ((Segment) newEntity) : newEntity.getParentSegment(); if (segment != null && segment.getTraceId() != null && segment.isSampled() && newEntity.getId() != null) { String fullPrefix = StringValidator.isNullOrBlank(this.prefix) ? "" : this.prefix + ": "; ThreadContext.put(TRACE_ID_KEY, fullPrefix + segment.getTraceId() + "@" + newEntity.getId()); } else { ThreadContext.remove(TRACE_ID_KEY); } } Log4JSegmentListener();  Log4JSegmentListener(String prefix); String getPrefix(); void setPrefix(String prefix); @Override void onSetEntity(Entity oldEntity, Entity newEntity); @Override void onClearEntity(Entity entity);  }### Answer:
@Test void testDefaultPrefix() { Log4JSegmentListener listener = (Log4JSegmentListener) AWSXRay.getGlobalRecorder().getSegmentListeners().get(0); Segment seg = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test", TRACE_ID); listener.onSetEntity(null, seg); Assertions.assertEquals(TRACE_ID_KEY + ": " + TRACE_ID.toString() + "@" + seg.getId(), ThreadContext.get(TRACE_ID_KEY)); }