use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class IntervalLoadRuleTest method testSerdeNullTieredReplicants.
@Test
public void testSerdeNullTieredReplicants() throws Exception {
IntervalLoadRule rule = new IntervalLoadRule(Intervals.of("0/3000"), null);
ObjectMapper jsonMapper = new DefaultObjectMapper();
Rule reread = jsonMapper.readValue(jsonMapper.writeValueAsString(rule), Rule.class);
Assert.assertEquals(rule, reread);
Assert.assertEquals(ImmutableMap.of(DruidServer.DEFAULT_TIER, DruidServer.DEFAULT_NUM_REPLICANTS), rule.getTieredReplicants());
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class IntervalLoadRuleTest method testMappingNullTieredReplicants.
@Test
public void testMappingNullTieredReplicants() throws Exception {
String inputJson = " {\n" + " \"interval\": \"0000-01-01T00:00:00.000-05:50:36/3000-01-01T00:00:00.000-06:00\",\n" + " \"type\": \"loadByInterval\"\n" + " }";
String expectedJson = "{\n" + " \"interval\": \"0000-01-01T00:00:00.000-05:50:36/3000-01-01T00:00:00.000-06:00\",\n" + " \"tieredReplicants\": {\n" + " \"" + DruidServer.DEFAULT_TIER + "\": " + DruidServer.DEFAULT_NUM_REPLICANTS + "\n" + " },\n" + " \"type\": \"loadByInterval\"\n" + " }";
ObjectMapper jsonMapper = new DefaultObjectMapper();
IntervalLoadRule inputIntervalLoadRule = jsonMapper.readValue(inputJson, IntervalLoadRule.class);
IntervalLoadRule expectedIntervalLoadRule = jsonMapper.readValue(expectedJson, IntervalLoadRule.class);
Assert.assertEquals(expectedIntervalLoadRule, inputIntervalLoadRule);
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class PeriodLoadRuleTest method testSerdeNull.
/**
* test serialize/deserilize null values of {@link PeriodLoadRule#tieredReplicants} and {@link PeriodLoadRule#includeFuture}
*/
@Test
public void testSerdeNull() throws Exception {
PeriodLoadRule rule = new PeriodLoadRule(new Period("P1D"), null, null);
ObjectMapper jsonMapper = new DefaultObjectMapper();
Rule reread = jsonMapper.readValue(jsonMapper.writeValueAsString(rule), Rule.class);
Assert.assertEquals(rule.getPeriod(), ((PeriodLoadRule) reread).getPeriod());
Assert.assertEquals(rule.isIncludeFuture(), ((PeriodLoadRule) reread).isIncludeFuture());
Assert.assertEquals(PeriodLoadRule.DEFAULT_INCLUDE_FUTURE, rule.isIncludeFuture());
Assert.assertEquals(rule.getTieredReplicants(), ((PeriodLoadRule) reread).getTieredReplicants());
Assert.assertEquals(ImmutableMap.of(DruidServer.DEFAULT_TIER, DruidServer.DEFAULT_NUM_REPLICANTS), rule.getTieredReplicants());
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class UserCompactionTaskTransformConfigTest method testSerde.
@Test
public void testSerde() throws IOException {
NullHandling.initializeForTests();
final UserCompactionTaskTransformConfig expected = new UserCompactionTaskTransformConfig(new SelectorDimFilter("dim1", "foo", null));
final ObjectMapper mapper = new DefaultObjectMapper();
final byte[] json = mapper.writeValueAsBytes(expected);
final UserCompactionTaskTransformConfig fromJson = (UserCompactionTaskTransformConfig) mapper.readValue(json, UserCompactionTaskTransformConfig.class);
Assert.assertEquals(expected, fromJson);
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class LookupExtractorFactoryContainerTest method testSerde.
@Test
public void testSerde() throws Exception {
String jsonStr = "{\n" + "\"version\": \"v1\",\n" + "\"lookupExtractorFactory\": {\n" + " \"type\": \"test\"\n" + " }\n" + "}\n";
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.registerSubtypes(TestLookupExtractorFactory.class);
LookupExtractorFactoryContainer actual = mapper.readValue(mapper.writeValueAsString(mapper.readValue(jsonStr, LookupExtractorFactoryContainer.class)), LookupExtractorFactoryContainer.class);
Assert.assertEquals(new LookupExtractorFactoryContainer("v1", new TestLookupExtractorFactory()), actual);
}
Aggregations