@Test
public void testLoadEnvironment() throws Exception
{

    ReservedNetworkResources networkResource = mock( ReservedNetworkResources.class );
    doReturn( networkResource ).when( localPeer ).getReservedNetworkResources();
    doCallRealMethod().when( environmentManager ).loadEnvironment( TestHelper.ENV_ID );
    assertNotNull( environmentManager.loadEnvironment( TestHelper.ENV_ID ) );
    //-----
    doReturn( null ).when( environmentService ).find( TestHelper.ENV_ID );
    doReturn( null ).when( environmentManager ).findRemoteEnvironment( TestHelper.ENV_ID );
    try
    {
        environmentManager.loadEnvironment( TestHelper.ENV_ID );
        fail( "Expected EnvironmentNotFoundException" );
    }
    catch ( EnvironmentNotFoundException e )
    {
    }
    doReturn( bzrEnvironment ).when( environmentAdapter ).get( TestHelper.ENV_ID );
    reset( environmentService );
    environmentManager.loadEnvironment( TestHelper.ENV_ID );
    verify( environmentService, never() ).find( TestHelper.ENV_ID );
}