public Uuid directory(int replica) {
        for (int i = 0; i < replicas.length; i++) {
            if (replicas[i] == replica) {
                return directories[i];
            }
        }
        throw new IllegalArgumentException("Replica " + replica + " is not assigned to this partition.");
    }
@Test
    public void testDirectories() {
        PartitionRegistration partitionRegistration = new PartitionRegistration.Builder().
                setReplicas(new int[] {3, 2, 1}).
                setDirectories(new Uuid[]{
                        Uuid.fromString("FbRuu7CeQtq5YFreEzg16g"),
                        Uuid.fromString("4rtHTelWSSStAFMODOg3cQ"),
                        Uuid.fromString("Id1WXzHURROilVxZWJNZlw")
                }).
                setIsr(new int[] {1, 2, 3}).setLeader(1).setLeaderRecoveryState(LeaderRecoveryState.RECOVERED).
                setLeaderEpoch(100).setPartitionEpoch(200).build();
        assertEquals(Uuid.fromString("Id1WXzHURROilVxZWJNZlw"), partitionRegistration.directory(1));
        assertEquals(Uuid.fromString("4rtHTelWSSStAFMODOg3cQ"), partitionRegistration.directory(2));
        assertEquals(Uuid.fromString("FbRuu7CeQtq5YFreEzg16g"), partitionRegistration.directory(3));
        assertThrows(IllegalArgumentException.class, () -> partitionRegistration.directory(4));
    }