InfinispanSpanCache implements SpanCache, ServiceLifecycle { @Override public Set<Span> getTrace(String tenant, String id) { if (id == null) { throw new NullPointerException("Id should not be null!"); } Set<Span> trace = traceCache.get(id); return trace == null ? null : Collections.unmodifiableSet(trace); } InfinispanSpanCache();  InfinispanSpanCache(CacheContainer cacheContainer); @Override @PostConstruct void init(); @Override Span get(String tenantId, String id); @Override void store(String tenantId, List<Span> spans); @Override void store(String tenantId, List<Span> spans, Function<Span, String> cacheKeyEntrySupplier); @Override Set<Span> getChildren(String tenant, String id); @Override Set<Span> getTrace(String tenant, String id);  }
@Test public void testGetTrace() throws CacheException { Span rootSpan = new Span(); rootSpan.setId("trace"); rootSpan.setTraceId("trace"); Span descSpan = new Span(); descSpan.setId("desc1"); descSpan.setTraceId("trace"); descSpan.setParentId("trace"); Span descSpan2 = new Span(); descSpan2.setId("desc2"); descSpan2.setTraceId("trace"); descSpan2.setParentId("desc1"); Span orphanSpan = new Span(); orphanSpan.setId("orphan"); orphanSpan.setTraceId("orphan"); orphanSpan.setParentId("orphan"); spanCache.store(null, Arrays.asList(rootSpan, descSpan, descSpan2, orphanSpan)); Assert.assertEquals(new HashSet<>(Arrays.asList(rootSpan, descSpan, descSpan2)), new HashSet<>(spanCache.getTrace(null, "trace"))); }
@Test public void testGetTraceEmpty() { Assert.assertNull(spanCache.getTrace(null, "id")); }