Package io.druid.jackson

Examples of io.druid.jackson.DefaultObjectMapper.readValue()


    Assert.assertEquals(QueryGranularity.MINUTE, mapper.readValue("\"minute\"", QueryGranularity.class));

    QueryGranularity gran = mapper.readValue("\"thirty_minute\"", QueryGranularity.class);
    Assert.assertEquals(new DurationGranularity(30 * 60 * 1000, null), gran);

    gran = mapper.readValue("\"fifteen_minute\"", QueryGranularity.class);
    Assert.assertEquals(new DurationGranularity(15 * 60 * 1000, null), gran);
  }

  private void assertSame(List<DateTime> expected, Iterable<Long> actual)
  {
View Full Code Here


  @Test
  public void testSerdeBackwardsCompatible() throws Exception
  {
    DefaultObjectMapper mapper = new DefaultObjectMapper();
    ConstantPostAggregator aggregator = mapper.readValue(
        "{\"type\":\"constant\",\"name\":\"thistestbasicallydoesnothing unhappyface\",\"constantValue\":1}\n",
        ConstantPostAggregator.class
    );
    Assert.assertEquals(new Integer(1), aggregator.getConstantValue());
  }
View Full Code Here

  @Test
  public void testSerde() throws Exception
  {
    DefaultObjectMapper mapper = new DefaultObjectMapper();
    ConstantPostAggregator aggregator = new ConstantPostAggregator("aggregator", 2, null);
    ConstantPostAggregator aggregator1 = mapper.readValue(
        mapper.writeValueAsString(aggregator),
        ConstantPostAggregator.class
    );
    Assert.assertEquals(aggregator, aggregator1);
  }
View Full Code Here

    Map<String,Object> expectedObj = Maps.newLinkedHashMap();
    expectedObj.put("breaks", Arrays.asList(visualBreaks));
    expectedObj.put("counts", Arrays.asList(visualCounts));
    expectedObj.put("quantiles", Arrays.asList(new Double[]{-1.0, 1.0}));

    Map<String,Object> obj = (Map<String, Object>)objectMapper.readValue(json, Object.class);
    Assert.assertEquals(expectedObj, obj);
  }
}
View Full Code Here

         null,
         null
     );
     ObjectMapper jsonMapper = new DefaultObjectMapper();
     Rule reread = jsonMapper.readValue(jsonMapper.writeValueAsString(rule), Rule.class);
     Assert.assertEquals(rule, reread);
   }
}
View Full Code Here

  public void testSerializePeriod() throws Exception
  {
    ObjectMapper mapper = new DefaultObjectMapper();

    String json = "{ \"type\": \"period\", \"period\": \"P1D\" }";
    QueryGranularity gran = mapper.readValue(json, QueryGranularity.class);
    Assert.assertEquals(new PeriodGranularity(new Period("P1D"), null, null), gran);

    json =   "{ \"type\": \"period\", \"period\": \"P1D\","
           + "\"timeZone\": \"America/Los_Angeles\", \"origin\": \"1970-01-01T00:00:00Z\"}";
    gran = mapper.readValue(json, QueryGranularity.class);
View Full Code Here

    QueryGranularity gran = mapper.readValue(json, QueryGranularity.class);
    Assert.assertEquals(new PeriodGranularity(new Period("P1D"), null, null), gran);

    json =   "{ \"type\": \"period\", \"period\": \"P1D\","
           + "\"timeZone\": \"America/Los_Angeles\", \"origin\": \"1970-01-01T00:00:00Z\"}";
    gran = mapper.readValue(json, QueryGranularity.class);
    Assert.assertEquals(new PeriodGranularity(new Period("P1D"), new DateTime(0l), DateTimeZone.forID("America/Los_Angeles")), gran);

    QueryGranularity expected = new PeriodGranularity(
        new Period("P1D"),
        new DateTime("2012-01-01"),
View Full Code Here

        new DateTime("2012-01-01"),
        DateTimeZone.forID("America/Los_Angeles")
    );

    String jsonOut = mapper.writeValueAsString(expected);
    Assert.assertEquals(expected, mapper.readValue(jsonOut, QueryGranularity.class));

  }

  @Test
  public void testSerializeDuration() throws Exception
View Full Code Here

  public void testSerializeDuration() throws Exception
  {
    ObjectMapper mapper = new DefaultObjectMapper();

    String json = "{ \"type\": \"duration\", \"duration\": \"3600000\" }";
    QueryGranularity gran = mapper.readValue(json, QueryGranularity.class);
    Assert.assertEquals(new DurationGranularity(3600000, null), gran);

    json = "{ \"type\": \"duration\", \"duration\": \"5\", \"origin\": \"2012-09-01T00:00:00.002Z\" }";
    gran = mapper.readValue(json, QueryGranularity.class);
    Assert.assertEquals(new DurationGranularity(5, 2), gran);
View Full Code Here

    String json = "{ \"type\": \"duration\", \"duration\": \"3600000\" }";
    QueryGranularity gran = mapper.readValue(json, QueryGranularity.class);
    Assert.assertEquals(new DurationGranularity(3600000, null), gran);

    json = "{ \"type\": \"duration\", \"duration\": \"5\", \"origin\": \"2012-09-01T00:00:00.002Z\" }";
    gran = mapper.readValue(json, QueryGranularity.class);
    Assert.assertEquals(new DurationGranularity(5, 2), gran);

    DurationGranularity expected = new DurationGranularity(5, 2);
    Assert.assertEquals(expected, mapper.readValue(mapper.writeValueAsString(expected), QueryGranularity.class));
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.