### Question:
FrequencyCachingDeterminerDecorator extends AbstractSlidingWindowFrequencyDeterminerDecorator { @Override public CountedSubsets[] determineCounts(String[][] wordsets, SegmentationDefinition[] definitions) { CountedSubsets countedSubsets[] = new CountedSubsets[definitions.length]; CachedWordSet cacheObj; int counts[]; String singleWordSet[][] = new String[1][]; SegmentationDefinition singleDefinition[] = new SegmentationDefinition[1]; for (int i = 0; i < definitions.length; ++i) { cacheObj = new CachedWordSet(wordsets[i]); counts = cache.getIfPresent(cacheObj); if (counts != null) { countedSubsets[i] = new CountedSubsets(definitions[i].segments, definitions[i].conditions, counts); } else { singleWordSet[0] = wordsets[i]; singleDefinition[0] = definitions[i]; countedSubsets[i] = this.determiner.determineCounts(singleWordSet, singleDefinition)[0]; cache.put(cacheObj, countedSubsets[i].counts); } } return countedSubsets; } FrequencyCachingDeterminerDecorator(FrequencyDeterminer determiner);  FrequencyCachingDeterminerDecorator(FrequencyDeterminer determiner, int cacheSize); @Override CountedSubsets[] determineCounts(String[][] wordsets, SegmentationDefinition[] definitions);  }### Answer:
@Test public void test() { LOGGER.info("Testing cache..."); String wordsets[][]; SegmentationDefinition[] definitions; SegmentationDefinition definition = new SegmentationDefinition(new int[0], new int[0][0], new BitSet(0)); CountedSubsets result[]; for (int i = 0; i < NUMBER_OF_REQUESTS; ++i) { wordsets = new String[rand.nextInt(5) + 1][]; definitions = new SegmentationDefinition[wordsets.length]; for (int j = 0; j < wordsets.length; ++j) { wordsets[j] = chooseWordSet(); definitions[j] = definition; } result = cache.determineCounts(wordsets, definitions); Assert.assertEquals(wordsets.length, result.length); for (int j = 0; j < result.length; ++j) { Assert.assertArrayEquals(values.get(new WordSet(wordsets[j])), result[j].counts); } } }