TraceJsonService { @GET(path = "/backend/trace/header", permission = "agent:trace") String getHeader(@BindAgentId String agentId, @BindRequest HeaderRequest request) throws Exception { String headerJson = traceCommonService.getHeaderJson(agentId, request.traceId(), request.checkLiveTraces()); if (headerJson == null) { logger.debug("no trace found for agent id '{}' and trace id '{}'", agentId, request.traceId()); return "{\"expired\":true}"; } else { return headerJson; } } TraceJsonService(TraceCommonService traceCommonService);   }
@Test public void test() throws Exception { TraceCommonService traceCommonService = mock(TraceCommonService.class); TraceJsonService traceJsonService = new TraceJsonService(traceCommonService); String json = traceJsonService.getHeader("", ImmutableHeaderRequest.builder() .traceId("1234") .build()); assertThat(json).isEqualTo("{\"expired\":true}"); }