@Test
public void testAddSshKey() throws Exception
{

    SshKeyAdditionWorkflow sshKeyAdditionWorkflow = mock( SshKeyAdditionWorkflow.class );
    doNothing().when( environmentManager ).registerActiveWorkflow( environment, sshKeyAdditionWorkflow );
    doReturn( sshKeyAdditionWorkflow ).when( environmentManager )
                                      .getSshKeyAdditionWorkflow( environment, TestHelper.SSH_KEY,
                                              trackerOperation );
    environmentManager.addSshKey( TestHelper.ENV_ID, TestHelper.SSH_KEY, false );
    verify( environmentAdapter ).addSshKey( TestHelper.ENV_ID, TestHelper.SSH_KEY );
    //-----
    doReturn( true ).when( sshKeyAdditionWorkflow ).isFailed();
    try
    {
        environmentManager.addSshKey( TestHelper.ENV_ID, TestHelper.SSH_KEY, false );
        fail( "Expected EnvironmentModificationException" );
    }
    catch ( EnvironmentModificationException e )
    {
    }
    //-----
    doReturn( EnvironmentStatus.UNDER_MODIFICATION ).when( environment ).getStatus();
    try
    {
        environmentManager.addSshKey( TestHelper.ENV_ID, TestHelper.SSH_KEY, false );
        fail( "Expected EnvironmentModificationException" );
    }
    catch ( EnvironmentModificationException e )
    {
    }
}