### Question:
SequenceDatabase { public TreeSet<FrequentSequenceItem> getGloballyFrequentItems(int minSupport) { Map<SequenceItem, Integer> itemBag = new HashMap<SequenceItem, Integer>(); TreeSet<FrequentSequenceItem> frequentItemSet = new TreeSet<FrequentSequenceItem>(); for (Sequence seq : sequences) { for (int i = 0; i < sequenceLength; ++i) { SequenceItem fItem = new SequenceItem(seq.getSequenceAsString().substring(i, i + 1), i); Integer count = itemBag.get(fItem); if (count == null) { itemBag.put(fItem, new Integer(seq.getCount())); } else { itemBag.put(fItem, count + seq.getCount()); } } } for (Entry<SequenceItem, Integer> itemAndCount : itemBag.entrySet()) { int count = itemAndCount.getValue(); if (count >= minSupport) { frequentItemSet.add(new FrequentSequenceItem(count, itemAndCount.getKey())); } } return frequentItemSet; } SequenceDatabase(List<Sequence> sequencesToMine, int sequenceLength); int getSequenceLength(); List<Sequence> getSequences(); int getTotalNumSeqs(); TreeSet<FrequentSequenceItem> getGloballyFrequentItems(int minSupport);  }### Answer:
@Test public void moreThan75PercentTest() { Set<FrequentSequenceItem> fi = database.getGloballyFrequentItems(12); assertEquals(1, fi.size()); assertTrue(fi.contains(new FrequentSequenceItem(16, new SequenceItem("A", 0)))); }
@Test public void moreThan50PercentTest() { Set<FrequentSequenceItem> fi = database.getGloballyFrequentItems(8); assertEquals(3, fi.size()); assertTrue(fi.contains(new FrequentSequenceItem(16, new SequenceItem("A", 0)))); assertTrue(fi.contains(new FrequentSequenceItem(8, new SequenceItem("A", 1)))); assertTrue(fi.contains(new FrequentSequenceItem(8, new SequenceItem("B", 1)))); }
@Test public void noFrequentItemsTest() { List<Sequence> sequences = new ArrayList<>(); sequences.add(new Sequence("A", 1)); sequences.add(new Sequence("B", 1)); database = new SequenceDatabase(sequences, 1); Set<FrequentSequenceItem> fi = database.getGloballyFrequentItems(12); assertEquals(0, fi.size()); }