@Test
    public void testVerifyBucketOneNodePreferenceInTenNodeDefaultCluster() {
        int result[] = new int[10];
        setClusterNodes(new int[]{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
        String clusterState = " bits:16 storage:10 distributor:10";
        for (int i=0; i<10; ++i) {
            // Update cached cluster state, to reflect which node we want to find
            RoutingNode target = select();
            target.handleReply(new WrongDistributionReply("version:" + (i + 1) + clusterState));
            Reply reply = frame.getReceptor().getReply(60);
            assertNotNull(reply);
            assertFalse(reply.hasErrors());
            // Find correct target
            target = select();
            Pair<String, Integer> address = getAddress(target);
            result[i] = address.getSecond();
            removeNode(address.getSecond());
            clusterState += " ." + result[i] + ".s:d";
        }
        assertEquals(Arrays.toString(bucketOneNodePreference), Arrays.toString(result));
    }
To be independent of changes in distribution algorithm, we programmatically calculate preferred order of
bucket 1, which we will be using in the tests. To avoid doing this ahead of every test, we still hardcode the
values, though only one place, and have this test to verify they are correct, and make it easy to update the values.
documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/BasicTests.java