TableRenderer { public String render(String rawTableName, TableDefinition table, SortedSet<IndexMetadata> indices) { return new ClassRenderer(rawTableName, table, indices).render(); } TableRenderer(String packageName, Namespace namespace, OptionalType optionalType); String getClassName(String rawTableName, TableDefinition table); String render(String rawTableName, TableDefinition table, SortedSet<IndexMetadata> indices);  }
@Test public void testCanRenderGuavaOptionals() { TableRenderer renderer = new TableRenderer("package", Namespace.DEFAULT_NAMESPACE, OptionalType.GUAVA); assertThat(renderer.render("table", getSimpleTableDefinition(TABLE_REF), NO_INDICES)) .contains("import com.google.common.base.Optional") .doesNotContain("import java.util.Optional") .contains("{@link Optional}") .contains("Optional<TestTableRowResult> getRow(") .contains("Optional.absent") .doesNotContain("Optional.empty"); }
@Test public void testCanRenderJava8Optionals() { TableRenderer renderer = new TableRenderer("package", Namespace.DEFAULT_NAMESPACE, OptionalType.JAVA8); assertThat(renderer.render("table", getSimpleTableDefinition(TABLE_REF), NO_INDICES)) .doesNotContain("import com.google.common.base.Optional") .contains("import java.util.Optional") .contains("{@link Optional}") .contains("Optional<TestTableRowResult> getRow(") .doesNotContain("Optional.absent") .contains("Optional.empty"); }
@Test public void testReusablePersisters() { TableRenderer renderer = new TableRenderer("package", Namespace.DEFAULT_NAMESPACE, OptionalType.JAVA8); String renderedTableDefinition = renderer.render("table", getTableWithUserSpecifiedPersister(TABLE_REF), NO_INDICES); assertThat(renderedTableDefinition).contains("REUSABLE_PERSISTER.hydrateFromBytes") .contains("private final com.palantir.atlasdb.persister.JsonNodePersister REUSABLE_PERSISTER ="); }