### Question:
SortedReplicas { SortedReplicas(Broker broker, Set<Function<Replica, Boolean>> selectionFuncs, List<Function<Replica, Integer>> priorityFuncs, Function<Replica, Double> scoreFunction) { this(broker, null, selectionFuncs, priorityFuncs, scoreFunction, true); } SortedReplicas(Broker broker,
                 Set<Function<Replica, Boolean>> selectionFuncs,
                 List<Function<Replica, Integer>> priorityFuncs,
                 Function<Replica, Double> scoreFunction);   SortedReplicas(Broker broker,
                 Disk disk,
                 Set<Function<Replica, Boolean>> selectionFuncs,
                 List<Function<Replica, Integer>> priorityFuncs,
                 Function<Replica, Double> scoreFunc,
                 boolean initialize); SortedSet<Replica> sortedReplicas(boolean clone); Set<Function<Replica, Boolean>> selectionFunctions(); List<Function<Replica, Integer>> priorityFunctions(); Function<Replica, Double> scoreFunction(); void add(Replica replica);  }### Answer:
@Test public void testScoreFunctionOnly() { Broker broker = generateBroker(NUM_REPLICAS); broker.trackSortedReplicas(SORT_NAME, null, null, SCORE_FUNC); SortedReplicas sr = broker.trackedSortedReplicas(SORT_NAME); double lastScore = Double.NEGATIVE_INFINITY; for (Replica r : sr.sortedReplicas(false)) { assertTrue(SCORE_FUNC.apply(r) >= lastScore); } }
@Test public void testPriorityFunction() { Broker broker = generateBroker(NUM_REPLICAS); new SortedReplicasHelper().addPriorityFunc(PRIORITY_FUNC) .setScoreFunc(SCORE_FUNC) .trackSortedReplicasFor(SORT_NAME, broker); SortedReplicas sr = broker.trackedSortedReplicas(SORT_NAME); assertEquals(NUM_REPLICAS, sr.sortedReplicas(false).size()); verifySortedReplicas(sr); }
@Test public void testSelectionFunction() { Broker broker = generateBroker(NUM_REPLICAS); new SortedReplicasHelper().addSelectionFunc(SELECTION_FUNC) .addPriorityFunc(PRIORITY_FUNC) .setScoreFunc(SCORE_FUNC) .trackSortedReplicasFor(SORT_NAME, broker); SortedReplicas sr = broker.trackedSortedReplicas(SORT_NAME); assertEquals(broker.leaderReplicas().size(), sr.sortedReplicas(false).size()); verifySortedReplicas(sr); }