### Question:
TextTruncator implements TextProcessor { @Override public List<String> preprocess(List<String> tokens) { if (tokens.size() <= maxSize) { return tokens; } return tokens.subList(0, maxSize); } TextTruncator(int maxSize); @Override List<String> preprocess(List<String> tokens);  }### Answer:
@Test public void preprocessTruncates() { String sentence = "DJL is a great library!"; String expected = "DJL is"; SimpleTokenizer tokenizer = new SimpleTokenizer(); List<String> tokens = tokenizer.tokenize(sentence); TextTruncator truncator = new TextTruncator(2); List<String> processedTokens = truncator.preprocess(tokens); Assert.assertEquals(tokenizer.buildSentence(processedTokens), expected); }
@Test public void preprocessFitting() { String sentence = "DJL is a great library!"; String expected = "DJL is a great library!"; SimpleTokenizer tokenizer = new SimpleTokenizer(); List<String> tokens = tokenizer.tokenize(sentence); TextTruncator truncator = new TextTruncator(10); List<String> processedTokens = truncator.preprocess(tokens); Assert.assertEquals(tokenizer.buildSentence(processedTokens), expected); }