### Question:
FeeReceiverSelector { public static String getAddress(DaoFacade daoFacade, FilterManager filterManager) { return getAddress(daoFacade, filterManager, new Random()); }  static String getAddress(DaoFacade daoFacade, FilterManager filterManager);  }### Answer:
@Test public void testGetAddress() { Random rnd = new Random(123); when(filterManager.getFilter()).thenReturn(filterWithReceivers( List.of("", "foo#0.001", "ill-formed", "bar#0.002", "baz#0.001", "partial#bad"))); Map<String, Integer> selectionCounts = new HashMap<>(); for (int i = 0; i < 400; i++) { String address = FeeReceiverSelector.getAddress(daoFacade, filterManager, rnd); selectionCounts.compute(address, (k, n) -> n != null ? n + 1 : 1); } assertEquals(3, selectionCounts.size()); assertEquals(100.0, selectionCounts.get("foo"), 18); assertEquals(200.0, selectionCounts.get("bar"), 20); assertEquals(100.0, selectionCounts.get("baz"), 18); }
@Test public void testGetAddress_noValidReceivers() { when(daoFacade.getParamValue(Param.RECIPIENT_BTC_ADDRESS)).thenReturn("default"); when(filterManager.getFilter()).thenReturn(null); assertEquals("default", FeeReceiverSelector.getAddress(daoFacade, filterManager)); when(filterManager.getFilter()).thenReturn(filterWithReceivers(null)); assertEquals("default", FeeReceiverSelector.getAddress(daoFacade, filterManager)); when(filterManager.getFilter()).thenReturn(filterWithReceivers(List.of())); assertEquals("default", FeeReceiverSelector.getAddress(daoFacade, filterManager)); when(filterManager.getFilter()).thenReturn(filterWithReceivers(List.of("ill-formed"))); assertEquals("default", FeeReceiverSelector.getAddress(daoFacade, filterManager)); }