@Test
public void testOnHeartbeat() throws Exception
{

    when( resourceHostInfo.getHostname() ).thenReturn( Common.MANAGEMENT_HOSTNAME );
    when( resourceHostInfo.getId() ).thenReturn( MANAGEMENT_HOST_ID );
    doReturn( IP ).when( resourceHostInfo ).getAddress();
    doReturn( managementHost ).when( localPeer ).getManagementHost();
    localPeer.initialized = true;
    localPeer.onHeartbeat( resourceHostInfo, Sets.newHashSet( quotaAlertValue ) );
    localPeer.onHeartbeat( resourceHostInfo, Sets.newHashSet( quotaAlertValue ) );
    when( resourceHostInfo.getHostname() ).thenReturn( RESOURCE_HOST_NAME );
    when( resourceHostInfo.getId() ).thenReturn( RESOURCE_HOST_ID );
    localPeer.onHeartbeat( resourceHostInfo, Sets.newHashSet( quotaAlertValue ) );
    verify( resourceHost ).updateHostInfo( resourceHostInfo );
    doThrow( new HostNotFoundException( "" ) ).when( localPeer ).getResourceHostById( anyString() );
}