ElasticSearchQueryStoreService extends DefaultService implements QueryStoreService { @VisibleForTesting static ObjectMapper getQueryStoreObjectMapper(JsonSerializer<QueryStoreRecordList> serializer) { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); SimpleModule module = new SimpleModule(); module.addSerializer(QueryStoreRecordList.class, serializer); module.addDeserializer(QueryStoreRecordList.class, new QueryStoreRecordList.Deserializer()); mapper.registerModule(module); return mapper; } @Inject  ElasticSearchQueryStoreService(SystemConfiguration config, MonitorService monitorService); @Override void putArgusWsQueries(List<Metric> metrics); @Override void dispose(); @Override Properties getServiceProperties();  }
@Test public void testQueryStoreRecordListMapper() throws Exception { ObjectMapper mapper = ElasticSearchQueryStoreService.getQueryStoreObjectMapper(new QueryStoreRecordList.IndexSerializer()); QueryStoreRecord record1 = new QueryStoreRecord("scope1", "metric1"); QueryStoreRecordList recordList = new QueryStoreRecordList(new HashSet<>(Arrays.asList(record1)), QueryStoreRecordList.HashAlgorithm.fromString("MD5")); String serialized = mapper.writeValueAsString(recordList); assertTrue("expect the serialized record to have scope", serialized.contains("scope1")); assertTrue("expect the serialized record to have metric", serialized.contains("metric1")); }