ElasticSearchSchemaService extends AbstractSchemaService { @VisibleForTesting static ObjectMapper _getMetadataObjectMapper(JsonSerializer<MetricSchemaRecordList> serializer) { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Include.NON_NULL); SimpleModule module = new SimpleModule(); module.addSerializer(MetricSchemaRecordList.class, serializer); module.addDeserializer(MetricSchemaRecordList.class, new MetricSchemaRecordList.Deserializer()); module.addDeserializer(List.class, new SchemaRecordList.AggDeserializer()); mapper.registerModule(module); return mapper; } @Inject  ElasticSearchSchemaService(SystemConfiguration config, MonitorService monitorService, ElasticSearchUtils esUtils); @Override void dispose(); @Override Properties getServiceProperties(); @Override List<MetricSchemaRecord> get(MetricSchemaRecordQuery query); @Override List<String> browseUnique(MetricSchemaRecordQuery query, RecordType type, int indexLevel); @Override List<MetricSchemaRecord> getUnique(MetricSchemaRecordQuery query, RecordType type); @Override List<MetricSchemaRecord> keywordSearch(KeywordQuery kq);  }
@Test public void testMetriccSchemaRecordListMapper() throws Exception { ObjectMapper mapper = ElasticSearchSchemaService._getMetadataObjectMapper(new MetricSchemaRecordList.IndexSerializer()); MetricSchemaRecord record1 = new MetricSchemaRecord("namespace1", "scope1", "metric1", "tagK1", "tagV1", 10); MetricSchemaRecordList recordList = new MetricSchemaRecordList(new HashSet<>(Arrays.asList(record1)), MetricSchemaRecordList.HashAlgorithm.fromString("MD5")); String serialized = mapper.writeValueAsString(recordList); assertTrue("expect the serialized record to have EXPIRATION_TS", serialized.contains(MetricSchemaRecord.EXPIRATION_TS)); assertTrue("expect the serialized record to have RETENTION_DISCOVERY", serialized.contains(MetricSchemaRecord.RETENTION_DISCOVERY)); }