use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class ForeverLoadRuleTest method testSerdeNullTieredReplicants.
@Test
public void testSerdeNullTieredReplicants() throws Exception {
ForeverLoadRule rule = new ForeverLoadRule(null);
ObjectMapper jsonMapper = new DefaultObjectMapper();
Rule reread = jsonMapper.readValue(jsonMapper.writeValueAsString(rule), Rule.class);
Assert.assertEquals(rule.getTieredReplicants(), ((ForeverLoadRule) 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 ForeverLoadRuleTest method testMappingNullTieredReplicants.
@Test
public void testMappingNullTieredReplicants() throws Exception {
String inputJson = "{\n" + " \"type\": \"loadForever\"\n" + "}";
String expectedJson = " {\n" + " \"tieredReplicants\": {\n" + " \"" + DruidServer.DEFAULT_TIER + "\": " + DruidServer.DEFAULT_NUM_REPLICANTS + "\n" + " },\n" + " \"type\": \"loadForever\"\n" + " }";
ObjectMapper jsonMapper = new DefaultObjectMapper();
ForeverLoadRule inputForeverLoadRule = jsonMapper.readValue(inputJson, ForeverLoadRule.class);
ForeverLoadRule expectedForeverLoadRule = jsonMapper.readValue(expectedJson, ForeverLoadRule.class);
Assert.assertEquals(expectedForeverLoadRule.getTieredReplicants(), inputForeverLoadRule.getTieredReplicants());
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class ForeverLoadRuleTest method testEmptyReplicantValue.
@Test(expected = IAE.class)
public void testEmptyReplicantValue() throws Exception {
// Immutable map does not allow null values
Map<String, Integer> tieredReplicants = new HashMap<>();
tieredReplicants.put("tier", null);
ForeverLoadRule rule = new ForeverLoadRule(tieredReplicants);
ObjectMapper jsonMapper = new DefaultObjectMapper();
Rule reread = jsonMapper.readValue(jsonMapper.writeValueAsString(rule), Rule.class);
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class TrueDimFilterTest method testSerde.
@Test
public void testSerde() throws IOException {
final ObjectMapper mapper = new DefaultObjectMapper();
final TrueDimFilter original = TrueDimFilter.instance();
final byte[] bytes = mapper.writeValueAsBytes(original);
final TrueDimFilter fromBytes = (TrueDimFilter) mapper.readValue(bytes, DimFilter.class);
Assert.assertSame(original, fromBytes);
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class FilterTuningTest method testSerde.
@Test
public void testSerde() throws Exception {
final ObjectMapper objectMapper = new DefaultObjectMapper();
final FilterTuning filterTuning1 = new FilterTuning(false, 100, 200);
Assert.assertEquals(filterTuning1, objectMapper.readValue(objectMapper.writeValueAsString(filterTuning1), FilterTuning.class));
final FilterTuning filterTuning2 = new FilterTuning(true, 100, 200);
Assert.assertEquals(filterTuning2, objectMapper.readValue(objectMapper.writeValueAsString(filterTuning2), FilterTuning.class));
}
Aggregations