protected boolean isLoadBalancerSheddingBundlesWithPoliciesEnabled(LoadManagerContext context,
                                                                       NamespaceBundle namespaceBundle) {
        if (isolationPoliciesHelper != null
                && isolationPoliciesHelper.hasIsolationPolicy(namespaceBundle.getNamespaceObject())) {
            return context.brokerConfiguration().isLoadBalancerSheddingBundlesWithPoliciesEnabled();
        }

        if (antiAffinityGroupPolicyHelper != null
                && antiAffinityGroupPolicyHelper.hasAntiAffinityGroupPolicy(namespaceBundle.toString())) {
            return context.brokerConfiguration().isLoadBalancerSheddingBundlesWithPoliciesEnabled();
        }

        return true;
    }
@Test
    public void testIsLoadBalancerSheddingBundlesWithPoliciesEnabled() {
        var counter = new UnloadCounter();
        TransferShedder transferShedder = new TransferShedder(pulsar, counter, new ArrayList<>(),
                isolationPoliciesHelper, antiAffinityGroupPolicyHelper);

        var ctx = setupContext();

        NamespaceBundle namespaceBundle = mock(NamespaceBundle.class);
        doReturn("bundle").when(namespaceBundle).toString();

        boolean[][] expects = {
                {true, true, true, true},
                {true, true, false, false},
                {true, false, true, true},
                {true, false, false, false},
                {false, true, true, true},
                {false, true, false, false},
                {false, false, true, true},
                {false, false, false, true}
        };

        for (boolean[] expect : expects) {
            doReturn(expect[0]).when(isolationPoliciesHelper).hasIsolationPolicy(any());
            doReturn(expect[1]).when(antiAffinityGroupPolicyHelper).hasAntiAffinityGroupPolicy(any());
            ctx.brokerConfiguration().setLoadBalancerSheddingBundlesWithPoliciesEnabled(expect[2]);
            assertEquals(transferShedder.isLoadBalancerSheddingBundlesWithPoliciesEnabled(ctx, namespaceBundle),
                    expect[3]);
        }
    }