@Test
public void testRemoveSshKey() throws Exception
{

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