@Test
  public void testHandleFire() throws Exception {
    expect(rootJobSettings.getJobClass()).andReturn(TestRootJob.class.getName());

    Capture<String> capturedPath = newCapture();
    Capture<Msg> capturedMsg = newCapture();
    Capture<ActorRef> capturedSrcRef = newCapture();
    workerMock.sendMsg(
        EasyMock.capture(capturedPath),
        EasyMock.capture(capturedMsg),
        EasyMock.capture(capturedSrcRef));
    expectLastCall();

    workerMock.doSnapshot();
    expectLastCall();

    replayAll();

    RootJobFireHandler handler = new RootJobFireHandler(workerMock);

    handler.handleFire();

    verifyAll();

    assertThat(capturedPath.getValue(), is("/user/supervisor"));
    assertEquals(
        ((NewMsg) capturedMsg.getValue()).getJob().getJobProducerClass(),
        TestRootJobProducer.class);
    assertThat(capturedSrcRef.getValue(), is(self));
  }
  @Test
  public void testHandleFire_AlreadyProcessingRootJob() throws Exception {
    TestRootJob job = new TestRootJob();

    ExecJobState jobState = new ExecJobState(job, Id.nextValue(), sender);
    jobState.setStatus(JobState.Status.PROCESSING);
    workerState.addJobState(jobState);

    replayAll();

    RootJobFireHandler handler = new RootJobFireHandler(workerMock);

    handler.handleFire();

    verifyAll();
  }
  @Test
  public void testHandleFire_InvalidRootJob() throws Exception {
    expect(rootJobSettings.getJobClass()).andReturn("Invalid" + System.currentTimeMillis());

    replayAll();

    RootJobFireHandler handler = new RootJobFireHandler(workerMock);

    try {
      handler.handleFire();
      fail("Should throw ReflectiveOperationException");
    } catch (RuntimeException e) {
      assertThat(e.getCause(), instanceOf(ReflectiveOperationException.class));
    }

    verifyAll();
  }