### Question:
DefaultCollectionService extends DefaultJPAService implements CollectionService { @Override public int commitHistograms(int histogramCount, int timeout) { requireNotDisposed(); requireArgument(histogramCount > 0, "Histogram count must be greater than zero."); requireArgument(timeout > 0, "The timeout in milliseconds must be greater than zero."); List<Histogram> dequeued = _mqService.dequeue(HISTOGRAM.getQueueName(), Histogram.class, timeout, histogramCount); if (!dequeued.isEmpty()) { _tsdbService.putHistograms(dequeued); _logger.debug("Committed {} histograms.", dequeued.size()); } return dequeued.size(); } @Inject  DefaultCollectionService(MQService mqService, TSDBService tsdbService, AuditService auditService,
            AnnotationStorageService annotationStorageService, SystemConfiguration configuration, SchemaService schemaService, WardenService wardenService,
            MonitorService monitorService, NamespaceService namespaceService); @Override void submitMetric(PrincipalUser submitter, Metric metric); @Override void submitMetrics(PrincipalUser submitter, List<Metric> metrics); @Override void submitAnnotation(PrincipalUser submitter, Annotation annotation); @Override void submitAnnotations(PrincipalUser submitter, List<Annotation> annotations); @Override List<Metric> commitMetrics(int messageCount, int timeout); @Override int commitMetricSchema(int messageCount, int timeout); @Override int commitAnnotations(int annotationCount, int timeout); @Override int commitHistograms(int histogramCount, int timeout); @Override void submitHistogram(PrincipalUser submitter, Histogram histogram); @Override void submitHistograms(PrincipalUser submitter, List<Histogram> histograms); @Override void dispose();  }### Answer:
@Test public void testCommitHistograms() { List<Histogram> messages = Arrays.asList(TestUtils.createHistogram(4), TestUtils.createHistogram(5)); when(mqService.dequeue(eq(MQService.MQQueue.HISTOGRAM.getQueueName()), eq(Histogram.class), anyInt(), anyInt())).thenReturn(messages); assertEquals(2, collectionService.commitHistograms(2, 60000)); }