}
@Test
public void testLimit() {
// Given
Vocabulary vocabulary = new Vocabulary();
for (int i = 1; i < 6; i++) {
for (int j = 0; j < i; j++) {
vocabulary.add("we are " + i);
}
}
// When
vocabulary.limitWords(3);
// Then
assertEquals(3, vocabulary.wordCount().intValue());
assertEquals(0, vocabulary.count("we are 1").intValue());
assertEquals(0, vocabulary.count("we are 2").intValue());
assertEquals(3, vocabulary.count("we are 3").intValue());
assertEquals(4, vocabulary.count("we are 4").intValue());
assertEquals(5, vocabulary.count("we are 5").intValue());
}