### Question:
DefinedAttributeTemplateEngine implements TemplateEngine { @Override public String render(String template, StatementContext ctx) { return RENDER_CACHE.get(template, ctx).apply(ctx); }  @Override String render(String template, StatementContext ctx);  }### Answer:
@Test public void testSubstitutesDefinedAttributes() { Map<String, Object> attributes = ImmutableMap.of( "column", "foo", "table", "bar"); String rendered = render("select <column> from <table> where <column> = :someValue", attributes); assertThat(rendered).isEqualTo("select foo from bar where foo = :someValue"); }
@Test public void testUndefinedAttribute() { assertThatThrownBy(() -> render("select * from <table>", Collections.emptyMap())) .isInstanceOf(UnableToCreateStatementException.class); }
@Test public void testNullAttribute() { assertThatThrownBy(() -> render("select * from something where id=<id>", singletonMap("id", null))) .isInstanceOf(UnableToCreateStatementException.class); }
@Test public void testLeaveEnquotedTokensIntact() { String sql = "select '<foo>' foo, \"<bar>\" bar from something"; assertThat(render(sql, ImmutableMap.of("foo", "no", "bar", "stahp"))).isEqualTo(sql); }
@Test public void testIgnoreAngleBracketsNotPartOfToken() { String sql = "select * from foo where end_date < ? and start_date > ?"; assertThat(render(sql)).isEqualTo(sql); }
@Test public void testCommentQuote() { String sql = "select 1 "; assertThat(render(sql)).isEqualTo(sql); }
@Test public void testColonInComment() { String sql = " select :abc"; assertThat(render(sql)).isEqualTo(sql); }
@Test public void testNonLatinTokenName() { String sql = "select <\u0087\u008e\u0092\u0097\u009c>"; assertThat(render(sql, singletonMap("\u0087\u008e\u0092\u0097\u009c", "foo"))) .isEqualTo("select foo"); }
@Test public void testKoreanTokenName() { String sql = "select <제목>"; assertThat(render(sql, singletonMap("제목", "bar"))) .isEqualTo("select bar"); }
@Test public void testKoreanIdentifiers() { String sql = "SELECT 제목 FROM 업무_게시물"; assertThat(render(sql)).isEqualTo(sql); }
@Test public void testEmojiTokenName() { assertThat(render("select <😱>", singletonMap("😱", "baz"))) .isEqualTo("select baz"); }