### Question:
VersionMismatchCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); Map<String, Service> services = cluster.getServices(); List<String> errorMessages = new ArrayList<>(); for (Service service : services.values()) { validateService(service, prerequisiteCheck, errorMessages); } if (!prerequisiteCheck.getFailedOn().isEmpty()) { prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); String failReason = getFailReason(prerequisiteCheck, request); prerequisiteCheck.setFailReason(String.format(failReason, StringUtils.join(errorMessages, "\n"))); prerequisiteCheck.setFailReason(StringUtils.join(errorMessages, "\n")); } } VersionMismatchCheck(); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }### Answer:
@Test public void testWarningWhenHostWithVersionMismatchExists() throws Exception { when(firstServiceComponentHosts.get(FIRST_SERVICE_COMPONENT_HOST_NAME).getUpgradeState()).thenReturn(VERSION_MISMATCH); PrerequisiteCheck check = new PrerequisiteCheck(null, CLUSTER_NAME); versionMismatchCheck.perform(check, new PrereqCheckRequest(CLUSTER_NAME)); Assert.assertEquals(PrereqCheckStatus.WARNING, check.getStatus()); }
@Test public void testWarningWhenHostWithVersionMismatchDoesNotExist() throws Exception { when(firstServiceComponentHosts.get(FIRST_SERVICE_COMPONENT_HOST_NAME).getUpgradeState()).thenReturn(IN_PROGRESS); PrerequisiteCheck check = new PrerequisiteCheck(null, CLUSTER_NAME); versionMismatchCheck.perform(check, new PrereqCheckRequest(CLUSTER_NAME)); Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus()); }