@Test
  public void testPreUpgradeCheckClusterMissing() throws Exception {
    final Cluster cluster = Mockito.mock(Cluster.class);
    final Service service = Mockito.mock(Service.class);

    m_services.add("KAFKA");

    Mockito.when(clusters.getCluster(Mockito.anyString())).thenReturn(cluster);

    final MockCheckHelper helper = new MockCheckHelper();
    helper.m_clusters = clusters;
    helper.m_repositoryVersionDAO = repositoryVersionDao;
    helper.clustersProvider = () -> clusters;

    final AmbariMetaInfo metaInfo = Mockito.mock(AmbariMetaInfo.class);
    helper.metaInfoProvider = new Provider<AmbariMetaInfo>() {
      @Override
      public AmbariMetaInfo get() {
        return metaInfo;
      }
    };

    Configuration configuration = EasyMock.createNiceMock(Configuration.class);
    List<UpgradeCheck> updateChecksRegistry = new ArrayList<>();

    EasyMock.expect(configuration.isUpgradePrecheckBypass()).andReturn(false);
    EasyMock.replay(configuration);
    updateChecksRegistry.add(m_mockCheck);

    // this will cause an exception, triggering the fail
    Mockito.when(m_mockPerform.toString()).thenThrow(new RuntimeException());

    ClusterInformation clusterInformation = new ClusterInformation("cluster", false, null, null, null);
    UpgradeCheckRequest request = new UpgradeCheckRequest(clusterInformation, UpgradeType.ROLLING, m_repositoryVersion, null, null);

    helper.performChecks(request, updateChecksRegistry, configuration);

    Assert.assertEquals(UpgradeCheckStatus.FAIL, request.getResult(m_mockUpgradeCheckDescription));
  }
Test that applicable tests that fail when configured to bypass failures results in a status of {@see UpgradeCheckStatus.BYPASS}
ambari-server/src/test/java/org/apache/ambari/server/state/CheckHelperTest.java