### Question:
BtcNodesSetupPreferences { public List<BtcNodes.BtcNode> selectPreferredNodes(BtcNodes nodes) { List<BtcNodes.BtcNode> result; BtcNodes.BitcoinNodesOption nodesOption = BtcNodes.BitcoinNodesOption.values()[preferences.getBitcoinNodesOptionOrdinal()]; switch (nodesOption) { case CUSTOM: String bitcoinNodes = preferences.getBitcoinNodes(); Set<String> distinctNodes = Utilities.commaSeparatedListToSet(bitcoinNodes, false); result = BtcNodes.toBtcNodesList(distinctNodes); if (result.isEmpty()) { log.warn("Custom nodes is set but no valid nodes are provided. " + "We fall back to provided nodes option."); preferences.setBitcoinNodesOptionOrdinal(BtcNodes.BitcoinNodesOption.PROVIDED.ordinal()); result = nodes.getProvidedBtcNodes(); } break; case PUBLIC: result = Collections.emptyList(); break; case PROVIDED: default: result = nodes.getProvidedBtcNodes(); break; } return result; } BtcNodesSetupPreferences(Preferences preferences); List<BtcNodes.BtcNode> selectPreferredNodes(BtcNodes nodes); boolean isUseCustomNodes(); int calculateMinBroadcastConnections(List<BtcNodes.BtcNode> nodes);  }### Answer:
@Test public void testSelectPreferredNodesWhenPublicOption() { Preferences delegate = mock(Preferences.class); when(delegate.getBitcoinNodesOptionOrdinal()).thenReturn(PUBLIC.ordinal()); BtcNodesSetupPreferences preferences = new BtcNodesSetupPreferences(delegate); List<BtcNode> nodes = preferences.selectPreferredNodes(mock(BtcNodes.class)); assertTrue(nodes.isEmpty()); }
@Test public void testSelectPreferredNodesWhenCustomOption() { Preferences delegate = mock(Preferences.class); when(delegate.getBitcoinNodesOptionOrdinal()).thenReturn(CUSTOM.ordinal()); when(delegate.getBitcoinNodes()).thenReturn("aaa.onion,bbb.onion"); BtcNodesSetupPreferences preferences = new BtcNodesSetupPreferences(delegate); List<BtcNode> nodes = preferences.selectPreferredNodes(mock(BtcNodes.class)); assertEquals(2, nodes.size()); }