@Test
public void testResetP2PSecretKey() throws Exception
{

    P2PSecretKeyModificationWorkflow p2PSecretKeyModificationWorkflow =
            mock( P2PSecretKeyModificationWorkflow.class );
    doNothing().when( environmentManager ).registerActiveWorkflow( environment, p2PSecretKeyModificationWorkflow );
    doReturn( p2PSecretKeyModificationWorkflow ).when( environmentManager )
                                                .getP2PSecretKeyModificationWorkflow( environment, "SECRET", 123L,
                                                        trackerOperation );
    environmentManager.resetP2PSecretKey( TestHelper.ENV_ID, "SECRET", 123L, false );
    verify( p2PSecretKeyModificationWorkflow ).join();
    //-----
    doReturn( true ).when( p2PSecretKeyModificationWorkflow ).isFailed();
    try
    {
        environmentManager.resetP2PSecretKey( TestHelper.ENV_ID, "SECRET", 123L, false );
        fail( "Expected EnvironmentModificationException" );
    }
    catch ( EnvironmentModificationException e )
    {
    }
    //-----
    doReturn( EnvironmentStatus.UNDER_MODIFICATION ).when( environment ).getStatus();
    try
    {
        environmentManager.resetP2PSecretKey( TestHelper.ENV_ID, "SECRET", 123L, false );
        fail( "Expected EnvironmentModificationException" );
    }
    catch ( EnvironmentModificationException e )
    {
    }
}