Search in sources :

Example 31 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.

the class TaskLogAutoCleanerConfigTest method testSerde.

@Test
public void testSerde() throws Exception {
    String json = "{\n" + "  \"enabled\": true,\n" + "  \"initialDelay\": 10,\n" + "  \"delay\": 40,\n" + "  \"durationToRetain\": 30\n" + "}";
    ObjectMapper mapper = TestUtil.MAPPER;
    TaskLogAutoCleanerConfig config = mapper.readValue(mapper.writeValueAsString(mapper.readValue(json, TaskLogAutoCleanerConfig.class)), TaskLogAutoCleanerConfig.class);
    Assert.assertTrue(config.isEnabled());
    Assert.assertEquals(10, config.getInitialDelay());
    Assert.assertEquals(40, config.getDelay());
    Assert.assertEquals(30, config.getDurationToRetain());
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 32 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.

the class TaskLogAutoCleanerConfigTest method testSerdeWithDefaults.

@Test
public void testSerdeWithDefaults() throws Exception {
    String json = "{}";
    ObjectMapper mapper = TestUtil.MAPPER;
    TaskLogAutoCleanerConfig config = mapper.readValue(mapper.writeValueAsString(mapper.readValue(json, TaskLogAutoCleanerConfig.class)), TaskLogAutoCleanerConfig.class);
    Assert.assertFalse(config.isEnabled());
    Assert.assertTrue(config.getInitialDelay() >= 60000 && config.getInitialDelay() <= 300000);
    Assert.assertEquals(6 * 60 * 60 * 1000, config.getDelay());
    Assert.assertEquals(Long.MAX_VALUE, config.getDurationToRetain());
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 33 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.

the class JSONParserTest method testSimpleWithFields.

@Test
public void testSimpleWithFields() {
    final Parser<String, Object> jsonParser = new JSONParser(new ObjectMapper(), Lists.newArrayList("two"));
    final Map<String, Object> jsonMap = jsonParser.parse(json);
    Assert.assertEquals("jsonMap", ImmutableMap.of("two", ImmutableList.of("bar", "baz")), jsonMap);
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 34 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.

the class QueryGranularityTest method testSerializeSimple.

@Test
public void testSerializeSimple() throws Exception {
    ObjectMapper mapper = new DefaultObjectMapper();
    Assert.assertEquals(Granularities.ALL, mapper.readValue(mapper.writeValueAsString(Granularities.ALL), Granularity.class));
    Assert.assertEquals(Granularities.NONE, mapper.readValue(mapper.writeValueAsString(Granularities.NONE), Granularity.class));
}
Also used : DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Granularity(io.druid.java.util.common.granularity.Granularity) DurationGranularity(io.druid.java.util.common.granularity.DurationGranularity) PeriodGranularity(io.druid.java.util.common.granularity.PeriodGranularity) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 35 with ObjectMapper

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.

the class ExtensionsConfigTest method testSerdeWithNonDefaults.

@Test
public void testSerdeWithNonDefaults() throws Exception {
    String json = "{\n" + "  \"searchCurrentClassloader\": false,\n" + "  \"directory\": \"testExtensions\",\n" + "  \"hadoopDependenciesDir\": \"testHadoopDependenciesDir\",\n" + "  \"hadoopContainerDruidClasspath\": \"testHadoopContainerClasspath\",\n" + "  \"loadList\": [\"a\",\"b\"]\n" + "}";
    ObjectMapper mapper = TestHelper.getObjectMapper();
    ExtensionsConfig config = mapper.readValue(mapper.writeValueAsString(mapper.readValue(json, ExtensionsConfig.class)), ExtensionsConfig.class);
    Assert.assertFalse(config.searchCurrentClassloader());
    Assert.assertEquals("testExtensions", config.getDirectory());
    Assert.assertEquals("testHadoopDependenciesDir", config.getHadoopDependenciesDir());
    Assert.assertEquals("testHadoopContainerClasspath", config.getHadoopContainerDruidClasspath());
    Assert.assertEquals(ImmutableList.of("a", "b"), config.getLoadList());
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5262 Test (org.junit.Test)1989 IOException (java.io.IOException)837 JsonNode (com.fasterxml.jackson.databind.JsonNode)724 HashMap (java.util.HashMap)375 Map (java.util.Map)367 ArrayList (java.util.ArrayList)346 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)318 File (java.io.File)282 List (java.util.List)222 Test (org.junit.jupiter.api.Test)205 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)202 Before (org.junit.Before)202 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)197 InputStream (java.io.InputStream)143 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)137 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)127 Matchers.containsString (org.hamcrest.Matchers.containsString)127 TypeReference (com.fasterxml.jackson.core.type.TypeReference)108 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)99