QGramTokenizer implements Serializable { public final List<String> tokenizeToArrayList(final String input, int q) { if (input == null) { return new ArrayList<String>(); } String toTokenize = pad(input, q); List<String> tokens = new ArrayList<String>(); for (int i = 0; i < toTokenize.length() - q + 1; i++) { tokens.add(toTokenize.substring(i, i + q)); } return tokens; }  final List<String> tokenizeToArrayList(final String input, int q);  }
@Test public void testTokenizeToArrayList() { HashSet<String> expect = new HashSet<String>(); expect.addAll(Arrays.asList(expected)); QGramTokenizer tokenizer = new QGramTokenizer(); List<String> tokenized = tokenizer.tokenizeToArrayList(INPUT, 3); for (String token : tokenized) { Assert.assertEquals("token not found:" + token, true, expect.contains(token)); } }