AbstractSchemaService extends DefaultService implements SchemaService { @Override public void put(Metric metric) { requireNotDisposed(); SystemAssert.requireArgument(metric != null, "Metric cannot be null."); put(Arrays.asList(metric)); } protected  AbstractSchemaService(SystemConfiguration config, MonitorService monitorService); @Override void put(Metric metric); @Override void put(List<Metric> metrics); @Override void dispose(); @Override abstract Properties getServiceProperties(); @Override abstract List<MetricSchemaRecord> get(MetricSchemaRecordQuery query); @Override abstract List<MetricSchemaRecord> getUnique(MetricSchemaRecordQuery query, RecordType type); @Override abstract List<String> browseUnique(MetricSchemaRecordQuery query, RecordType type, int indexLevel); @Override abstract List<MetricSchemaRecord> keywordSearch(KeywordQuery query);  }
@Test public void testPutEverythingCached() { List<Metric> metrics = TestUtils.createRandomMetrics(myClassName, "test-scope", "test-metric", 10); metrics.addAll(TestUtils.createRandomMetrics(myClassName, null, null, 10)); ElasticSearchSchemaService spyService = _initializeSpyService(_esSchemaService); spyService.put(metrics); Set<String> scopeNames = new HashSet<>(); for(Metric m : metrics) { scopeNames.add(m.getScope()); } assertEquals(metricsCreatedCount, metrics.size()); assertEquals(scopesCreatedCount, scopeNames.size()); spyService.put(metrics); initCounters(); assertEquals(metricsCreatedCount, 0); assertEquals(scopesCreatedCount, 0); }
@Test public void testPutPartialCached() { List<Metric> metrics = TestUtils.createRandomMetrics(myClassName, "test-scope", "test-metric", 10); ElasticSearchSchemaService spyService = _initializeSpyService(_esSchemaService); spyService.put(metrics); Set<String> scopeNames = new HashSet<>(); for(Metric m : metrics) { scopeNames.add(m.getScope()); } assertEquals(metricsCreatedCount, metrics.size()); assertEquals(scopesCreatedCount, scopeNames.size()); List<Metric> newMetrics = TestUtils.createRandomMetrics(myClassName, null, null, 10); initCounters(); spyService.put(metrics); spyService.put(newMetrics); scopeNames.clear(); for(Metric m : newMetrics) { scopeNames.add(m.getScope()); } assertEquals(metricsCreatedCount, newMetrics.size()); assertEquals(scopesCreatedCount, scopeNames.size()); }