PackageNameToken implements Token { @Override public void render(final LogEntry logEntry, final StringBuilder builder) { String packageName = getPackage(logEntry.getClassName()); if (packageName != null) { builder.append(packageName); } } PackageNameToken(); @Override Collection<LogEntryValue> getRequiredLogEntryValues(); @Override void render(final LogEntry logEntry, final StringBuilder builder); @Override void apply(final LogEntry logEntry, final PreparedStatement statement, final int index);  }
@Test public void renderClassWithPackage() { PackageNameToken token = new PackageNameToken(); assertThat(render(token, "my.package.TestClass")).isEqualTo("my.package"); }
@Test public void renderClassWithoutPackage() { PackageNameToken token = new PackageNameToken(); assertThat(render(token, "AnotherClass")).isEmpty(); }
@Test public void renderClassWithoutPackageIfClassnameIsNull() { PackageNameToken token = new PackageNameToken(); assertThat(render(token, null)).isEmpty(); }