MustacheResolver { public static List<String> getMustacheKeys(final String template) { final Set<String> keys = new HashSet<>(); if (StringUtils.isNotEmpty(template)) { final Matcher matcher = MUSTACHE_PATTERN.matcher(template); while(matcher.find()) { keys.add(matcher.group(1)); } } return new ArrayList<>(keys); }  static List<String> getMustacheKeys(final String template); static List<String> getMustacheKeysForTreeNode(final String template); static final Pattern MUSTACHE_PATTERN; }
@Test void testGetMustacheKeysWithEmptyText() { assertThat(MustacheResolver.getMustacheKeys(null)).isEmpty(); assertThat(MustacheResolver.getMustacheKeys("")).isEmpty(); }
@Test void testGetMustacheKeysWithNoMatch() { assertThat(MustacheResolver.getMustacheKeys("test")).isEmpty(); assertThat(MustacheResolver.getMustacheKeys("{test}")).isEmpty(); assertThat(MustacheResolver.getMustacheKeys("{{test}")).isEmpty(); assertThat(MustacheResolver.getMustacheKeys("{test}}")).isEmpty(); }
@Test void testGetMustacheKeysWithSingleMatch() { assertThat(MustacheResolver.getMustacheKeys("{{test}}")).containsExactly("test"); assertThat(MustacheResolver.getMustacheKeys("{{test}}and{{test}}")).containsExactly("test"); }
@Test void testGetMustacheKeysWithSingleMatchSurroundedByText() { assertThat(MustacheResolver.getMustacheKeys("aa{{test}}bb")).containsExactly("test"); }
@Test void testGetMustacheKeysWithMultipleMatch() { assertThat(MustacheResolver.getMustacheKeys("{{foo}}and{{bar}}")).contains("foo", "bar"); }
@Test void testGetMustacheKeysWithDotNotation() { assertThat(MustacheResolver.getMustacheKeys("{{foo.bar}}")).containsExactly("foo.bar"); }