DefaultCollectionService extends DefaultJPAService implements CollectionService { @Override public void submitMetric(PrincipalUser submitter, Metric metric) { submitMetrics(submitter, Arrays.asList(new Metric[] { metric })); } @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 testSubmitMetric() { when(namespaceService.isPermitted(any(), any())).thenReturn(true); int metricCount = 60; List<Metric> metrics = new ArrayList<>(metricCount); for (int i = 0; i < metricCount; i++) { metrics.add(createMetricWithIncreasingResolution(1000, 2)); } collectionService.submitMetrics(user, metrics); verify(monitorService).modifyCounter(MonitorService.Counter.DATAPOINT_WRITES, metricCount * 2, null); verify(wardenService).modifyPolicyCounter(user, WardenService.PolicyCounter.METRICS_PER_HOUR, metricCount); verify(wardenService).modifyPolicyCounter(user, WardenService.PolicyCounter.DATAPOINTS_PER_HOUR, metricCount * 2); }