### Question:
OneReplicaPipelineSafeModeRule extends
    SafeModeExitRule<Pipeline> { @Override protected boolean validate() { return currentReportedPipelineCount >= thresholdCount; } OneReplicaPipelineSafeModeRule(String ruleName, EventQueue eventQueue,
      PipelineManager pipelineManager,
      SCMSafeModeManager safeModeManager, ConfigurationSource configuration); @VisibleForTesting int getThresholdCount(); @VisibleForTesting int getCurrentReportedPipelineCount(); @Override String getStatusText();  }### Answer:
@Test public void testOneReplicaPipelineRule() throws Exception { int nodes = 30; int pipelineFactorThreeCount = 7; int pipelineCountOne = 0; setup(nodes, pipelineFactorThreeCount, pipelineCountOne); GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs( LoggerFactory.getLogger(SCMSafeModeManager.class)); List<Pipeline> pipelines = pipelineManager.getPipelines(); for (int i = 0; i < pipelineFactorThreeCount -1; i++) { firePipelineEvent(pipelines.get(i)); } GenericTestUtils.waitFor(() -> logCapturer.getOutput().contains( "reported count is 6"), 1000, 5000); Assert.assertFalse(rule.validate()); firePipelineEvent(pipelines.get(pipelineFactorThreeCount - 1)); GenericTestUtils.waitFor(() -> rule.validate(), 1000, 5000); }
@Test public void testOneReplicaPipelineRuleMixedPipelines() throws Exception { int nodes = 30; int pipelineCountThree = 7; int pipelineCountOne = 21; setup(nodes, pipelineCountThree, pipelineCountOne); GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs( LoggerFactory.getLogger(SCMSafeModeManager.class)); List<Pipeline> pipelines = pipelineManager.getPipelines(HddsProtos.ReplicationType.RATIS, HddsProtos.ReplicationFactor.ONE); for (int i = 0; i < pipelineCountOne; i++) { firePipelineEvent(pipelines.get(i)); } GenericTestUtils.waitFor(() -> logCapturer.getOutput().contains( "reported count is 0"), 1000, 5000); Assert.assertFalse(rule.validate()); pipelines = pipelineManager.getPipelines(HddsProtos.ReplicationType.RATIS, HddsProtos.ReplicationFactor.THREE); for (int i = 0; i < pipelineCountThree - 1; i++) { firePipelineEvent(pipelines.get(i)); } GenericTestUtils.waitFor(() -> logCapturer.getOutput().contains( "reported count is 6"), 1000, 5000); firePipelineEvent(pipelines.get(pipelineCountThree - 1)); GenericTestUtils.waitFor(() -> rule.validate(), 1000, 5000); }