@Test
void record() throws Exception
{

    ExtensionRequest request = mock(ExtensionRequest.class);
    when(request.getId()).thenReturn(Arrays.asList("job", "id"));
    DefaultJobStatus<ExtensionRequest> status = mock(DefaultJobStatus.class);
    when(status.getRequest()).thenReturn(request);
    when(status.getStartDate()).thenReturn(new Date());
    when(status.getQuestion()).thenReturn("What's up?");
    Job job = mock(Job.class);
    when(job.getType()).thenReturn("jobType");
    when(job.getRequest()).thenReturn(request);
    when(job.getStatus()).thenReturn(status);
    ParameterizedType questionRecorderType =
        new DefaultParameterizedType(null, QuestionRecorder.class, String.class);
    QuestionRecorder<String> questionRecorder = this.componentManager.registerMockComponent(questionRecorderType);
    this.recorder.onEvent(new JobStartedEvent(), job, null);
    this.recorder.onEvent(new QuestionAnsweredEvent(), job.getStatus(), null);
    this.recorder.onEvent(new JobFinishedEvent(), job, null);
    verify(questionRecorder).record((String) status.getQuestion());
    ArgumentCaptor<ExtensionJobHistoryRecord> recordCaptor =
        ArgumentCaptor.forClass(ExtensionJobHistoryRecord.class);
    verify(this.history).addRecord(recordCaptor.capture());
    ExtensionJobHistoryRecord record = recordCaptor.getValue();
    assertEquals(job.getType(), record.getJobType());
    assertSame(job.getRequest(), record.getRequest());
    assertEquals(Collections.singletonMap(String.class.getName(), questionRecorder), record.getAnswers());
    assertEquals(job.getStatus().getStartDate(), record.getStartDate());
}