@SuppressWarnings("deprecation")
    @VisibleForTesting
    public String getWebSocketConsumeUri(String topic) {
        String serviceURLWithoutTrailingSlash = serviceURL.substring(0,
                serviceURL.endsWith("/") ? serviceURL.length() - 1 : serviceURL.length());

        TopicName topicName = TopicName.get(topic);
        String wsTopic;
        if (topicName.isV2()) {
            wsTopic = String.format("%s/%s/%s/%s", topicName.getDomain(), topicName.getTenant(),
                    topicName.getNamespacePortion(), topicName.getLocalName());
        } else {
            wsTopic = String.format("%s/%s/%s/%s/%s", topicName.getDomain(), topicName.getTenant(),
                    topicName.getCluster(), topicName.getNamespacePortion(), topicName.getLocalName());
        }

        String uriFormat = "%s/ws" + (topicName.isV2() ? "/v2/" : "/")
                + "consumer/%s/%s?subscriptionType=%s&subscriptionMode=%s";
        return String.format(uriFormat, serviceURLWithoutTrailingSlash, wsTopic, subscriptionName,
                subscriptionType.toString(), subscriptionMode.toString());
    }
@Test
    public void testGetWebSocketConsumeUri() {
        String topicNameV1 = "persistent://public/cluster/default/issue-11067";
        assertEquals(cmdConsume.getWebSocketConsumeUri(topicNameV1),
                "ws://localhost:8080/ws/consumer/persistent/public/cluster/default/issue-11067/my-sub"
                        + "?subscriptionType=Exclusive&subscriptionMode=Durable");
        String topicNameV2 = "persistent://public/default/issue-11067";
        assertEquals(cmdConsume.getWebSocketConsumeUri(topicNameV2),
                "ws://localhost:8080/ws/v2/consumer/persistent/public/default/issue-11067/my-sub"
                        + "?subscriptionType=Exclusive&subscriptionMode=Durable");
    }