### Question:
ServicesNamenodeHighAvailabilityCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); final String configType = "hdfs-site"; final Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs(); final DesiredConfig desiredConfig = desiredConfigs.get(configType); final Config config = cluster.getConfig(configType, desiredConfig.getTag()); if (!config.getProperties().containsKey("dfs.internal.nameservices")) { prerequisiteCheck.getFailedOn().add("HDFS"); prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } ServicesNamenodeHighAvailabilityCheck(); @Override Set<String> getApplicableServices(); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }### Answer:
@Test public void testPerform() throws Exception { final Cluster cluster = Mockito.mock(Cluster.class); Mockito.when(cluster.getClusterId()).thenReturn(1L); Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster); final DesiredConfig desiredConfig = Mockito.mock(DesiredConfig.class); Mockito.when(desiredConfig.getTag()).thenReturn("tag"); Mockito.when(cluster.getDesiredConfigs()).thenReturn(Collections.singletonMap("hdfs-site", desiredConfig)); final Config config = Mockito.mock(Config.class); Mockito.when(cluster.getConfig(Mockito.anyString(), Mockito.anyString())).thenReturn(config); final Map<String, String> properties = new HashMap<>(); Mockito.when(config.getProperties()).thenReturn(properties); PrerequisiteCheck check = new PrerequisiteCheck(null, null); servicesNamenodeHighAvailabilityCheck.perform(check, new PrereqCheckRequest("cluster")); Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus()); properties.put("dfs.internal.nameservices", "anything"); check = new PrerequisiteCheck(null, null); servicesNamenodeHighAvailabilityCheck.perform(check, new PrereqCheckRequest("cluster")); Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus()); }