public NamespaceBundle findBundle(TopicName topicName) {
        checkArgument(nsname.equals(topicName.getNamespaceObject()));
        return factory.getTopicBundleAssignmentStrategy().findBundle(topicName, this);
    }
@Test
    public void testFindBundle() throws Exception {
        SortedSet<Long> partitions = new TreeSet<>();
        partitions.add(0L);
        partitions.add(0x40000000L);
        partitions.add(0xa0000000L);
        partitions.add(0xb0000000L);
        partitions.add(0xc0000000L);
        partitions.add(0xffffffffL);
        NamespaceBundles bundles = new NamespaceBundles(NamespaceName.get("pulsar/global/ns1"),
                factory, Optional.empty(), partitions);
        TopicName topicName = TopicName.get("persistent://pulsar/global/ns1/topic-1");
        NamespaceBundle bundle = bundles.findBundle(topicName);
        assertTrue(bundle.includes(topicName));

        topicName = TopicName.get("persistent://pulsar/use/ns2/topic-2");
        try {
            bundles.findBundle(topicName);
            fail("Should have failed due to mismatched namespace name");
        } catch (IllegalArgumentException iae) {
            // OK, expected
        }

        Long hashKey = factory.getLongHashCode(topicName.toString());
        // The following code guarantees that we have at least two ranges after the hashKey till the end
        SortedSet<Long> tailSet = partitions.tailSet(hashKey);
        tailSet.add(hashKey);
        // Now, remove the first range to ensure the hashKey is not included in <code>newPar</code>
        Iterator<Long> iter = tailSet.iterator();
        iter.next();
        SortedSet<Long> newPar = tailSet.tailSet(iter.next());

        try {
            bundles = new NamespaceBundles(topicName.getNamespaceObject(), factory, Optional.empty(), newPar);
            bundles.findBundle(topicName);
            fail("Should have failed due to out-of-range");
        } catch (IndexOutOfBoundsException iae) {
            // OK, expected
        }
    }