### Question:
ZipkinManager { public ZipkinRequestUUID createNewZipkinRequestUUID(@Nonnull RequestUUID cougarUuid, @Nullable String traceId, @Nullable String spanId, @Nullable String parentSpanId, @Nullable String sampled, @Nullable String flags, int port) { Objects.requireNonNull(cougarUuid); if (Boolean.FALSE.equals(ZipkinKeys.sampledToBoolean(sampled))) { return new ZipkinRequestUUIDImpl(cougarUuid, null); } ZipkinDataBuilder zipkinDataBuilder; if (traceId != null && spanId != null) { zipkinDataBuilder = new ZipkinDataImpl.Builder() .traceId(hexUnsignedStringToLong(traceId)) .spanId(hexUnsignedStringToLong(spanId)) .parentSpanId(parentSpanId == null ? null : hexUnsignedStringToLong(parentSpanId)) .flags(flags == null ? null : Long.valueOf(flags)) .port((short) port); } else { if (shouldTrace()) { zipkinDataBuilder = new ZipkinDataImpl.Builder() .traceId(getRandomLong()) .spanId(getRandomLong()) .parentSpanId(null) .flags(flags == null ? null : Long.valueOf(flags)) .port((short) port); } else { zipkinDataBuilder = null; } } return new ZipkinRequestUUIDImpl(cougarUuid, zipkinDataBuilder); }  boolean shouldTrace(); @ManagedAttribute int getSamplingLevel(); @ManagedAttribute void setSamplingLevel(int samplingLevel); ZipkinRequestUUID createNewZipkinRequestUUID(@Nonnull RequestUUID cougarUuid, @Nullable String traceId,
                                                        @Nullable String spanId, @Nullable String parentSpanId,
                                                        @Nullable String sampled, @Nullable String flags, int port); static long getRandomLong(); static long hexUnsignedStringToLong(@Nonnull String hexValue);  }### Answer:
@Test(expected = NullPointerException.class) public void createNewZipkinRequestUUID_WhenCougarUUIDIsNull_ShouldThrowNPE() { victim.createNewZipkinRequestUUID(null, traceId, spanId, parentSpanId, sampled, flags, port); }
@Test public void createNewZipkinRequestUUID_WhenRequestIsMarkedAsNotSampled_ShouldNotFillZipkinData() { String notSampledHeader = "0"; ZipkinRequestUUID result = victim.createNewZipkinRequestUUID(cougarUuid, traceId, spanId, parentSpanId, notSampledHeader, flags, port); assertNotNull(result); assertFalse(result.isZipkinTracingEnabled()); }
@Test public void createNewZipkinRequestUUID_WhenRequestIsAlreadyBeingTraced_ShouldContinueTracing() { ZipkinRequestUUID result = victim.createNewZipkinRequestUUID(cougarUuid, traceId, spanId, parentSpanId, sampled, flags, port); ZipkinData resultingData = result.buildZipkinData(""); assertNotNull(result); assertTrue(result.isZipkinTracingEnabled()); assertEquals(new BigInteger(traceId, 16).longValue(), resultingData.getTraceId()); assertEquals(new BigInteger(spanId, 16).longValue(), resultingData.getSpanId()); assertEquals(new BigInteger(parentSpanId, 16).longValue(), resultingData.getParentSpanId().longValue()); assertEquals(Long.valueOf(flags), resultingData.getFlags()); assertEquals(port, resultingData.getPort()); }