use of io.druid.client.indexing.ClientAppendQuery in project druid by druid-io.
the class TaskSerdeTest method testAppendTaskSerde.
@Test
public void testAppendTaskSerde() throws Exception {
final List<DataSegment> segments = ImmutableList.of(DataSegment.builder().dataSource("foo").interval(new Interval("2010-01-01/P1D")).version("1234").build(), DataSegment.builder().dataSource("foo").interval(new Interval("2010-01-02/P1D")).version("5678").build());
final AppendTask task = new AppendTask(null, "foo", segments, ImmutableList.<AggregatorFactory>of(new CountAggregatorFactory("cnt")), indexSpec, true, null);
final String json = jsonMapper.writeValueAsString(task);
// Just want to run the clock a bit to make sure the task id doesn't change
Thread.sleep(100);
final AppendTask task2 = (AppendTask) jsonMapper.readValue(json, Task.class);
Assert.assertEquals("foo", task.getDataSource());
Assert.assertEquals(new Interval("2010-01-01/P2D"), task.getInterval());
Assert.assertEquals(task.getId(), task2.getId());
Assert.assertEquals(task.getGroupId(), task2.getGroupId());
Assert.assertEquals(task.getDataSource(), task2.getDataSource());
Assert.assertEquals(task.getInterval(), task2.getInterval());
Assert.assertEquals(task.getSegments(), task2.getSegments());
final AppendTask task3 = (AppendTask) jsonMapper.readValue(jsonMapper.writeValueAsString(new ClientAppendQuery("foo", segments)), Task.class);
Assert.assertEquals("foo", task3.getDataSource());
Assert.assertEquals(new Interval("2010-01-01/P2D"), task3.getInterval());
Assert.assertEquals(task3.getSegments(), segments);
Assert.assertEquals(task.getAggregators(), task2.getAggregators());
}
Aggregations