SequenceInformationCollector { public Map<String, Object> collectInformation() { Map<String, Object> result = new HashMap<>(); Map<String, Integer> countOfGroups = new HashMap<>(); Map<String, SequenceDescriptor> descriptors = sequenceManager.getDescriptors(); int sumSequenceCount = 0; for (String seqDescriptorKey : descriptors.keySet()) { int countOfSequences = descriptors.get(seqDescriptorKey).getSequences().size(); sumSequenceCount += countOfSequences; countOfGroups.put(seqDescriptorKey, countOfSequences); } result.put(SUM_KEY, sumSequenceCount); result.put(GROUPS_KEY, countOfGroups); return result; }  Map<String, Object> collectInformation();  }
@Test public void testCollectInformationsWhenThereIsNoDescriptor() { given(sequenceManager.getDescriptors()).willReturn(new HashMap<String, SequenceDescriptor>()); Map<String, Object> result = underTest.collectInformation(); int sum = (int) result.get(SequenceInformationCollector.SUM_KEY); Assert.assertEquals(sum, 0); Map<String, Integer> groups = (Map<String, Integer>) result.get(SequenceInformationCollector.GROUPS_KEY); Assert.assertEquals(groups.size(), 0); }
@Test public void testCollectInformationsWhenThereAreDescriptors() { Map<String, SequenceDescriptor> descriptors = new HashMap<>(); descriptors.put("test", descriptor); Map<String, WilmaSequence> sequences = new HashMap<>(); sequences.put("testKey", sequence); given(descriptor.getSequences()).willReturn(sequences); given(sequenceManager.getDescriptors()).willReturn(descriptors); Map<String, Object> result = underTest.collectInformation(); int sum = (int) result.get(SequenceInformationCollector.SUM_KEY); Assert.assertEquals(sum, 1); Map<String, Integer> groups = (Map<String, Integer>) result.get(SequenceInformationCollector.GROUPS_KEY); Assert.assertEquals(groups.size(), 1); }