TraceServiceElasticsearch implements TraceService { @Override public List<Trace> searchFragments(String tenantId, Criteria criteria) { return internalQuery(client, tenantId, criteria); } TraceServiceElasticsearch(); @Inject  TraceServiceElasticsearch(SpanService spanService); ElasticsearchClient getElasticsearchClient(); void setElasticsearchClient(ElasticsearchClient client); @Override Trace getFragment(String tenantId, String id); @Override Trace getTrace(String tenantId, String id); @Override List<Trace> searchFragments(String tenantId, Criteria criteria); @Override void storeFragments(String tenantId, List<Trace> traces); @Override void clear(String tenantId); static final String TRACE_TYPE; }
@Test public void testSearchFragments() throws StoreException { Trace trace1 = new Trace(); trace1.setFragmentId("id1"); trace1.setTimestamp(1000); Consumer consumer1 = new Consumer(); consumer1.getProperties().add(new Property("prop1a", "value1a")); consumer1.getProperties().add(new Property("prop1b", "value1b")); trace1.getNodes().add(consumer1); Component component1 = new Component(); component1.getProperties().add(new Property("prop2", "value2")); consumer1.getNodes().add(component1); Producer producer1 = new Producer(); producer1.getProperties().add(new Property("prop3", "value3")); consumer1.getNodes().add(producer1); ts.storeFragments(null, Arrays.asList(trace1)); Criteria criteria = new Criteria(); criteria.setStartTime(1); Wait.until(() -> ts.searchFragments(null, criteria).size() == 1); List<Trace> result1 = ts.searchFragments(null, criteria); assertNotNull(result1); assertEquals(1, result1.size()); assertEquals(trace1, result1.get(0)); }