@Test
  public void testPassWhenSimilarlyNamedServiceIsOutdated() throws AmbariException {
    ServiceComponent serviceComponent = mock(ServiceComponent.class);
    when(serviceComponent.isVersionAdvertised()).thenReturn(true);

    when(service.getMaintenanceState()).thenReturn(MaintenanceState.OFF);
    when(service.getServiceComponents()).thenReturn(ImmutableMap.of(SERVICE_COMPONENT_NAME, serviceComponent));

    ServiceConfigEntity serviceConfigEntity = new ServiceConfigEntity();
    serviceConfigEntity.setServiceName(SERVICE_NAME);
    serviceConfigEntity.setCreateTimestamp(CONFIG_CREATE_TIMESTAMP);

    String hdfsRole = Role.HDFS_SERVICE_CHECK.name();
    String hdfs2Role = hdfsRole.replace("HDFS", "HDFS2");

    LastServiceCheckDTO lastServiceCheckDTO1 = new LastServiceCheckDTO(hdfsRole, SERVICE_CHECK_START_TIME);
    LastServiceCheckDTO lastServiceCheckDTO2 = new LastServiceCheckDTO(hdfs2Role, CONFIG_CREATE_TIMESTAMP - 1L);

    when(serviceConfigDAO.getLastServiceConfig(eq(CLUSTER_ID), eq(SERVICE_NAME))).thenReturn(serviceConfigEntity);
    when(hostRoleCommandDAO.getLatestServiceChecksByRole(any(Long.class))).thenReturn(asList(lastServiceCheckDTO1, lastServiceCheckDTO2));

    ClusterInformation clusterInformation = new ClusterInformation(CLUSTER_NAME, false, null, null, null);
    UpgradeCheckRequest request = new UpgradeCheckRequest(clusterInformation, UpgradeType.ROLLING, null, null, null);

    UpgradeCheckResult result =  serviceCheckValidityCheck.perform(request);
    Assert.assertEquals(UpgradeCheckStatus.FAIL, result.getStatus());  }
Tests that old, oudated service checks for the FOO2 service doesn't cause
problems when checking values for the FOO service.
<p/>
The specific test case here is that the FOO2 service was added a long time
ago and then removed. We don't want old service checks for FOO2 to match
when querying for FOO.

@throws AmbariException
ambari-server/src/test/java/org/apache/ambari/server/checks/ServiceCheckValidityCheckTest.java