@Test public void testMakeResults() throws IOException { JacksonResultsWriter victim = new JacksonResultsWriter(); String[] queryStrings = new String[] { "avg:laLoadInt1{tag1=*,tag2=*}", "sum:laLoadInt5{tag1=*,tag2=*}" }; List<MetricSpecification> queries = makeTestQueries(queryStrings); long startTs = DATA_START_TIMESTAMP; long endTs = DATA_END_TIMESTAMP; long step = DATA_TIMESTAMP_STEP; Buckets<IHasShortcut> buckets = makeTestBuckets(queries, new ConstantSeriesGenerator(10.0), startTs, endTs, step); BucketTestUtilities.dumpBucketsToStdout(buckets); String id = TESTID; String sourceId = TEST_SOURCE_ID; String startTimeConfig = Long.toString(startTs); String endTimeConfig = Long.toString(endTs); ReturnSet returnset = ReturnSet.ALL; Collection<QueryResult> expectedResults = new ArrayList<>(); String qr1str = "{\"metric\":\"laLoadInt1\",\"tags\":{\"tag1\":[\"*\"],\"tag2\":[\"*\"]},\"datapoints\":[{\"timestamp\":1078033800, \"value\":10.0},{\"timestamp\":1078034400, \"value\":10.0}]}"; String qr2str = "{\"metric\":\"laLoadInt5\",\"tags\":{\"tag1\":[\"*\"],\"tag2\":[\"*\"]},\"datapoints\":[{\"timestamp\":1078033800, \"value\":10.0},{\"timestamp\":1078034400, \"value\":10.0}]}"; ObjectMapper mapper = new ObjectMapper(); QueryResult qr1 = mapper.readValue(qr1str, QueryResult.class); QueryResult qr2 = mapper.readValue(qr2str, QueryResult.class); expectedResults.add(qr1); expectedResults.add(qr2); final SeriesQueryResult seriesQueryResult = victim.makeResults(queries, buckets, id, sourceId, startTs, startTimeConfig, endTs, endTimeConfig, returnset); Assert.assertNotNull(seriesQueryResult); Assert.assertEquals("client ID mismatch in query result", id, seriesQueryResult.getClientId()); Assert.assertEquals("endTime mismatch in query result", endTimeConfig, seriesQueryResult.getEndTime()); Assert.assertEquals("endTimeActual mismatch in query result", endTs, seriesQueryResult.getEndTimeActual()); Assert.assertEquals("returnset mismatch in query result", returnset, seriesQueryResult.getReturnset()); Assert.assertEquals("series mismatch in query result", true, seriesQueryResult.isSeries()); Assert.assertEquals("source mismatch in query result", sourceId, seriesQueryResult.getSource()); Assert.assertEquals("startTime mismatch in query result", startTimeConfig, seriesQueryResult.getStartTime()); Assert.assertEquals("startTimeActual mismatch in query result", startTs, seriesQueryResult.getStartTimeActual()); Collection<QueryResult> ar = seriesQueryResult.getResults(); Assert.assertEquals("result sizes mismatch in query results", expectedResults.size(), ar.size()); Assert.assertEquals("results mismatch in query results", expectedResults, ar); }
public SeriesQueryResult makeResults(List<MetricSpecification> queries, Buckets<IHasShortcut> buckets, String id, String sourceId, long startTs, String startTimeConfig, long endTs, String endTimeConfig, ReturnSet returnset) { SeriesQueryResult result = new SeriesQueryResult(); result.setClientId(id); result.setEndTime(endTimeConfig); result.setEndTimeActual(endTs); result.setReturnset(returnset); result.setSeries(true); result.setSource(sourceId); result.setStartTime(startTimeConfig); result.setStartTimeActual(startTs); result.addResults(makeDataPointResults(queries, buckets, startTs, endTs, returnset)); return result; }
JacksonResultsWriter { public SeriesQueryResult makeResults(List<MetricSpecification> queries, Buckets<IHasShortcut> buckets, String id, String sourceId, long startTs, String startTimeConfig, long endTs, String endTimeConfig, ReturnSet returnset) { SeriesQueryResult result = new SeriesQueryResult(); result.setClientId(id); result.setEndTime(endTimeConfig); result.setEndTimeActual(endTs); result.setReturnset(returnset); result.setSeries(true); result.setSource(sourceId); result.setStartTime(startTimeConfig); result.setStartTimeActual(startTs); result.addResults(makeDataPointResults(queries, buckets, startTs, endTs, returnset)); return result; } }
JacksonResultsWriter { public SeriesQueryResult makeResults(List<MetricSpecification> queries, Buckets<IHasShortcut> buckets, String id, String sourceId, long startTs, String startTimeConfig, long endTs, String endTimeConfig, ReturnSet returnset) { SeriesQueryResult result = new SeriesQueryResult(); result.setClientId(id); result.setEndTime(endTimeConfig); result.setEndTimeActual(endTs); result.setReturnset(returnset); result.setSeries(true); result.setSource(sourceId); result.setStartTime(startTimeConfig); result.setStartTimeActual(startTs); result.addResults(makeDataPointResults(queries, buckets, startTs, endTs, returnset)); return result; }  }
JacksonResultsWriter { public SeriesQueryResult makeResults(List<MetricSpecification> queries, Buckets<IHasShortcut> buckets, String id, String sourceId, long startTs, String startTimeConfig, long endTs, String endTimeConfig, ReturnSet returnset) { SeriesQueryResult result = new SeriesQueryResult(); result.setClientId(id); result.setEndTime(endTimeConfig); result.setEndTimeActual(endTs); result.setReturnset(returnset); result.setSeries(true); result.setSource(sourceId); result.setStartTime(startTimeConfig); result.setStartTimeActual(startTs); result.addResults(makeDataPointResults(queries, buckets, startTs, endTs, returnset)); return result; }  SeriesQueryResult makeResults(List<MetricSpecification> queries, Buckets<IHasShortcut> buckets,
                                          String id, String sourceId, long startTs, String startTimeConfig, long endTs,
                                          String endTimeConfig, ReturnSet returnset); }
JacksonResultsWriter { public SeriesQueryResult makeResults(List<MetricSpecification> queries, Buckets<IHasShortcut> buckets, String id, String sourceId, long startTs, String startTimeConfig, long endTs, String endTimeConfig, ReturnSet returnset) { SeriesQueryResult result = new SeriesQueryResult(); result.setClientId(id); result.setEndTime(endTimeConfig); result.setEndTimeActual(endTs); result.setReturnset(returnset); result.setSeries(true); result.setSource(sourceId); result.setStartTime(startTimeConfig); result.setStartTimeActual(startTs); result.addResults(makeDataPointResults(queries, buckets, startTs, endTs, returnset)); return result; }  SeriesQueryResult makeResults(List<MetricSpecification> queries, Buckets<IHasShortcut> buckets,
                                          String id, String sourceId, long startTs, String startTimeConfig, long endTs,
                                          String endTimeConfig, ReturnSet returnset);  }