### Question:
SimplePipelineProvider extends PipelineProvider { @Override public Pipeline create(ReplicationFactor factor) throws IOException { List<DatanodeDetails> dns = pickNodesNeverUsed(ReplicationType.STAND_ALONE, factor); if (dns.size() < factor.getNumber()) { String e = String .format("Cannot create pipeline of factor %d using %d nodes.", factor.getNumber(), dns.size()); throw new InsufficientDatanodesException(e); } Collections.shuffle(dns); return Pipeline.newBuilder() .setId(PipelineID.randomId()) .setState(PipelineState.OPEN) .setType(ReplicationType.STAND_ALONE) .setFactor(factor) .setNodes(dns.subList(0, factor.getNumber())) .build(); } SimplePipelineProvider(NodeManager nodeManager,
      PipelineStateManager stateManager); @Override Pipeline create(ReplicationFactor factor); @Override Pipeline create(ReplicationFactor factor,
      List<DatanodeDetails> nodes); @Override void close(Pipeline pipeline); @Override void shutdown();  }### Answer:
@Test public void testCreatePipelineWithFactor() throws IOException { HddsProtos.ReplicationFactor factor = HddsProtos.ReplicationFactor.THREE; Pipeline pipeline = provider.create(factor); stateManager.addPipeline(pipeline); Assert.assertEquals(pipeline.getType(), HddsProtos.ReplicationType.STAND_ALONE); Assert.assertEquals(pipeline.getFactor(), factor); Assert.assertEquals(pipeline.getPipelineState(), Pipeline.PipelineState.OPEN); Assert.assertEquals(pipeline.getNodes().size(), factor.getNumber()); factor = HddsProtos.ReplicationFactor.ONE; Pipeline pipeline1 = provider.create(factor); stateManager.addPipeline(pipeline1); Assert.assertEquals(pipeline1.getType(), HddsProtos.ReplicationType.STAND_ALONE); Assert.assertEquals(pipeline1.getFactor(), factor); Assert.assertEquals(pipeline1.getPipelineState(), Pipeline.PipelineState.OPEN); Assert.assertEquals(pipeline1.getNodes().size(), factor.getNumber()); }
@Test public void testCreatePipelineWithNodes() throws IOException { HddsProtos.ReplicationFactor factor = HddsProtos.ReplicationFactor.THREE; Pipeline pipeline = provider.create(factor, createListOfNodes(factor.getNumber())); Assert.assertEquals(pipeline.getType(), HddsProtos.ReplicationType.STAND_ALONE); Assert.assertEquals(pipeline.getFactor(), factor); Assert.assertEquals(pipeline.getPipelineState(), Pipeline.PipelineState.OPEN); Assert.assertEquals(pipeline.getNodes().size(), factor.getNumber()); factor = HddsProtos.ReplicationFactor.ONE; pipeline = provider.create(factor, createListOfNodes(factor.getNumber())); Assert.assertEquals(pipeline.getType(), HddsProtos.ReplicationType.STAND_ALONE); Assert.assertEquals(pipeline.getFactor(), factor); Assert.assertEquals(pipeline.getPipelineState(), Pipeline.PipelineState.OPEN); Assert.assertEquals(pipeline.getNodes().size(), factor.getNumber()); }