@Test
public void testExecuteWithExceptionAndGetJobEntityWithSecurityException()
{

    // Mock dependencies.
    CommandConfig config = mock(CommandConfig.class);
    JobEntity jobEntity = mock(JobEntity.class);
    ExecuteAsyncJobCmd command = new ExecuteAsyncJobCmd(jobEntity);
    doThrow(SecurityException.class).when(jobEntity).getId();
    // Try to call the method under test.
    try
    {
        herdCommandInvoker.execute(config, command);
        fail();
    }
    catch (IllegalStateException e)
    {
        assertEquals(SecurityException.class.getName(), e.getMessage());
    }
}