@Test
public void testPreUpgradeCheckThrowsException() throws Exception {

  final CheckHelper helper = new CheckHelper();
  List<AbstractCheckDescriptor> updateChecksRegistry = new ArrayList<AbstractCheckDescriptor>();
  AbstractCheckDescriptor descriptor = EasyMock.createNiceMock(AbstractCheckDescriptor.class);
  descriptor.perform(EasyMock.<PrerequisiteCheck> anyObject(), EasyMock.<PrereqCheckRequest> anyObject());
  EasyMock.expectLastCall().andThrow(new AmbariException("error"));
  EasyMock.expect(descriptor.isApplicable(EasyMock.<PrereqCheckRequest> anyObject())).andReturn(true);
  EasyMock.expect(descriptor.getDescription()).andReturn(CheckDescription.HOSTS_HEARTBEAT).anyTimes();
  EasyMock.replay(descriptor);
  updateChecksRegistry.add(descriptor);
  final List<PrerequisiteCheck> upgradeChecks = helper.performChecks(new PrereqCheckRequest("cluster"), updateChecksRegistry);
  EasyMock.verify(descriptor);
  Assert.assertEquals(PrereqCheckStatus.FAIL, upgradeChecks.get(0).getStatus());
}