TraceMongoCommandListener implements CommandListener { @Nullable static String getNonEmptyBsonString(BsonValue bsonValue) { if (bsonValue == null || !bsonValue.isString()) return null; String stringValue = bsonValue.asString().getValue().trim(); return stringValue.isEmpty() ? null : stringValue; } TraceMongoCommandListener(MongoDBTracing mongoDBTracing);   TraceMongoCommandListener(ThreadLocalSpan threadLocalSpan); @Override void commandStarted(CommandStartedEvent event); @Override void commandSucceeded(CommandSucceededEvent event); @Override void commandFailed(CommandFailedEvent event);  }
@Test public void getNonEmptyBsonString_null() { assertThat(getNonEmptyBsonString(null)).isNull(); }
@Test public void getNonEmptyBsonString_notString() { assertThat(getNonEmptyBsonString(BsonBoolean.TRUE)).isNull(); }
@Test public void getNonEmptyBsonString_empty() { assertThat(getNonEmptyBsonString(new BsonString(" "))).isNull(); }
@Test public void getNonEmptyBsonString_normal() { assertThat(getNonEmptyBsonString(new BsonString(" foo "))).isEqualTo("foo"); }