DefaultCollectionService extends DefaultJPAService implements CollectionService { @Override public int commitAnnotations(int annotationCount, int timeout) { requireNotDisposed(); requireArgument(annotationCount > 0, "Annotation count must be greater than zero."); requireArgument(timeout > 0, "The timeout in milliseconds must be greater than zero."); List<Annotation> dequeued = _mqService.dequeue(ANNOTATION.getQueueName(), Annotation.class, timeout, annotationCount); if (!dequeued.isEmpty()) { _annotationStorageService.putAnnotations(dequeued); _logger.debug("Committed {} annotations.", 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();  }
@Test public void testCommitAnnotations() { List<Annotation> messages = Arrays.asList(TestUtils.createAnnotation(), TestUtils.createAnnotation()); when(mqService.dequeue(eq(MQService.MQQueue.ANNOTATION.getQueueName()), eq(Annotation.class), anyInt(), anyInt())).thenReturn(messages); assertEquals(2, collectionService.commitAnnotations(2, 60000)); }