### Question:
ServicesNamenodeTruncateCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); Config config = cluster.getDesiredConfigByType("hdfs-site"); String truncateEnabled = config.getProperties().get("dfs.allow.truncate"); if (Boolean.valueOf(truncateEnabled)) { prerequisiteCheck.getFailedOn().add("HDFS"); PrereqCheckStatus checkStatus = PrereqCheckStatus.FAIL; prerequisiteCheck.setStatus(checkStatus); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } ServicesNamenodeTruncateCheck(); @Override Set<String> getApplicableServices(); @Override List<CheckQualification> getQualifications(); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }### Answer:
@Test public void testPerform() throws Exception { PrerequisiteCheck check = new PrerequisiteCheck(null, null); PrereqCheckRequest request = new PrereqCheckRequest("c1"); m_check.perform(check, request); assertEquals(PrereqCheckStatus.PASS, check.getStatus()); m_configMap.put("dfs.allow.truncate", "true"); request.setSourceStackId(new StackId("HDP-2.2.4.2")); Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.2.8.4"); Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new StackId("HDP", "2.2.8.4")); request.setTargetRepositoryVersion(m_repositoryVersion); check = new PrerequisiteCheck(null, null); m_check.perform(check, request); assertEquals(PrereqCheckStatus.FAIL, check.getStatus()); m_configMap.put("dfs.allow.truncate", "false"); check = new PrerequisiteCheck(null, null); m_check.perform(check, request); assertEquals(PrereqCheckStatus.PASS, check.getStatus()); m_configMap.put("dfs.allow.truncate", "true"); request.setSourceStackId(new StackId("HDP-2.2.4.2")); Mockito.when(m_repositoryVersion.getVersion()).thenReturn("2.3.8.4"); Mockito.when(m_repositoryVersion.getStackId()).thenReturn(new StackId("HDP", "2.3.8.4")); request.setTargetRepositoryVersion(m_repositoryVersion); check = new PrerequisiteCheck(null, null); m_check.perform(check, request); assertEquals(PrereqCheckStatus.FAIL, check.getStatus()); m_configMap.put("dfs.allow.truncate", "false"); check = new PrerequisiteCheck(null, null); m_check.perform(check, request); assertEquals(PrereqCheckStatus.PASS, check.getStatus()); }