Ejemplo n.º 1
0
  @Test
  public void testMoveTaskSerde() throws Exception {
    final MoveTask task =
        new MoveTask(
            null,
            "foo",
            new Interval("2010-01-01/P1D"),
            ImmutableMap.<String, Object>of("bucket", "hey", "baseKey", "what"),
            null,
            null);

    final String json = jsonMapper.writeValueAsString(task);

    Thread.sleep(100); // Just want to run the clock a bit to make sure the task id doesn't change
    final MoveTask task2 = (MoveTask) jsonMapper.readValue(json, Task.class);

    Assert.assertEquals("foo", task.getDataSource());
    Assert.assertEquals(new Interval("2010-01-01/P1D"), task.getInterval());
    Assert.assertEquals(
        ImmutableMap.<String, Object>of("bucket", "hey", "baseKey", "what"),
        task.getTargetLoadSpec());

    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.getTargetLoadSpec(), task2.getTargetLoadSpec());
  }