@Test
 public void testDataExtractor() throws Exception {
   BasicSampleExtractor extractor = new BasicSampleExtractor();
   Optional<SampleData> sampleData = extractor.extractSample(new JsonObject(buildMessage()));
   assertTrue(sampleData.isPresent());
   assertEquals(sampleData.get().getPublishId(), "norbert");
   assertEquals(sampleData.get().getTime(), NOW);
   assertEquals(sampleData.get().getMedian(), 10.5);
   assertTrue(sampleData.get().getReadings().length > 0);
 }
  @Test
  public void testDataJsonConsumption() throws Exception {
    JsonArray ginzburg = createJson("ginzburg", 1, 10);
    assertEquals(ginzburg.size(), 1);

    BasicSampleExtractor extractor = new BasicSampleExtractor();
    JsonObject jsonObject = ginzburg.getJsonObject(0);

    Optional<SampleData> sampleData = extractor.extractSample(jsonObject);
    assertTrue(sampleData.isPresent());
    assertEquals(sampleData.get().getPublishId(), "ginzburg");
    assertFalse(sampleData.get().getTime().isEmpty());

    double[] readings = extractor.extractReadings(jsonObject.getString(READINGS));
    assertEquals(readings.length, 10);

    DescriptiveStatistics stats = new DescriptiveStatistics(readings);
    double median = stats.getPercentile(50);
    assertEquals(sampleData.get().getMedian(), median);
  }
 @Test
 public void testDataReadingsExtractor() throws Exception {
   BasicSampleExtractor extractor = new BasicSampleExtractor();
   double[] readings = extractor.extractReadings(SAMPLE_READINGS);
   assertEquals(readings.length, 8);
 }