  @Test
  public void testRun() {

    final Identity identity = Identity.of("a", "b", "c");

    WorkerOptions workerOptions = new WorkerOptions();

    RunJobRequest request = new RunJobRequest();
    request.setWorkerOptions(workerOptions);

    final Job job = new CommandLineJob();

    request.setIdentity(identity);

    request.setJob(job);

    final CreateInstanceOptions options = new CreateInstanceOptions();
    options.setWorkerOptions(workerOptions);
    options.setInstanceProfileName("dm-profile-test");
    options.setUserData("test-data");

    final JobResult result = new JobResult();
    result.setStandardOutput("something");
    result.setElapsedMillis(1000);
    context.checking(
        new Expectations() {
          {
            one(controlActivities)
                .createAgentControllerRole("dm-master-role-test", "dm-agent-tl-test", identity);
            will(returnValue("aws:test:arn"));

            one(ec2Activities)
                .createAgentInstanceProfile("dm-profile-test", "aws:test:arn", identity);

            one(controlActivities).createAgentUserData("aws:test:arn", "dm-agent-tl-test");
            will(returnValue("test-data"));

            one(ec2Activities).launchInstance(options, identity);
            will(returnValue("dmw-test"));

            one(ec2Activities).describeInstance("dmw-test", identity);
            will(returnValue(new WorkerInstance().withInstanceStatus("running")));

            one(controlActivities)
                .notifyActionStarted("AgentActivities.runJob", "Start running command on instance");
            will(returnValue("action-id"));

            one(agentActivities).runJob(job);
            will(returnValue(result));

            one(controlActivities)
                .notifyActionCompleted(
                    with(equal("action-id")), with(aNonNull(String.class)), with(equal(1000L)));

            one(ec2Activities).terminateInstance("dmw-test", identity);
            one(ec2Activities).deleteInstanceProfile("dm-profile-test", identity);
            one(controlActivities).deleteRole("dm-master-role-test");
          }
        });

    new JobWorkflowClientFactoryImpl().getClient("test").executeCommand(request);
  }