@Test public void testWrapNamespace() { String topic1 = NamespaceUtil.wrapNamespace(INSTANCE_ID, TOPIC); Assert.assertEquals(topic1, TOPIC_WITH_NAMESPACE); String topicWithNamespaceAgain = NamespaceUtil.wrapNamespace(INSTANCE_ID, topic1); Assert.assertEquals(topicWithNamespaceAgain, TOPIC_WITH_NAMESPACE); String retryTopicWithNamespace = NamespaceUtil.wrapNamespace(INSTANCE_ID, RETRY_TOPIC); Assert.assertEquals(retryTopicWithNamespace, RETRY_TOPIC_WITH_NAMESPACE); String retryTopicWithNamespaceAgain = NamespaceUtil.wrapNamespace(INSTANCE_ID, retryTopicWithNamespace); Assert.assertEquals(retryTopicWithNamespaceAgain, retryTopicWithNamespace); String dlqTopicWithNamespace = NamespaceUtil.wrapNamespace(INSTANCE_ID, DLQ_TOPIC); Assert.assertEquals(dlqTopicWithNamespace, DLQ_TOPIC_WITH_NAMESPACE); String dlqTopicWithNamespaceAgain = NamespaceUtil.wrapNamespace(INSTANCE_ID, dlqTopicWithNamespace); Assert.assertEquals(dlqTopicWithNamespaceAgain, dlqTopicWithNamespace); Assert.assertEquals(dlqTopicWithNamespaceAgain, DLQ_TOPIC_WITH_NAMESPACE ); String systemTopic = NamespaceUtil.wrapNamespace(INSTANCE_ID, SYSTEM_TOPIC); Assert.assertEquals(systemTopic, SYSTEM_TOPIC); }
public static String wrapNamespace(String namespace, String resourceWithOutNamespace) { if (StringUtils.isEmpty(namespace) || StringUtils.isEmpty(resourceWithOutNamespace)) { return resourceWithOutNamespace; } if (isSystemResource(resourceWithOutNamespace) || isAlreadyWithNamespace(resourceWithOutNamespace, namespace)) { return resourceWithOutNamespace; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithOutNamespace); StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } return stringBuilder.append(namespace).append(NAMESPACE_SEPARATOR).append(resourceWithoutRetryAndDLQ).toString(); }
NamespaceUtil { public static String wrapNamespace(String namespace, String resourceWithOutNamespace) { if (StringUtils.isEmpty(namespace) || StringUtils.isEmpty(resourceWithOutNamespace)) { return resourceWithOutNamespace; } if (isSystemResource(resourceWithOutNamespace) || isAlreadyWithNamespace(resourceWithOutNamespace, namespace)) { return resourceWithOutNamespace; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithOutNamespace); StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } return stringBuilder.append(namespace).append(NAMESPACE_SEPARATOR).append(resourceWithoutRetryAndDLQ).toString(); } }
NamespaceUtil { public static String wrapNamespace(String namespace, String resourceWithOutNamespace) { if (StringUtils.isEmpty(namespace) || StringUtils.isEmpty(resourceWithOutNamespace)) { return resourceWithOutNamespace; } if (isSystemResource(resourceWithOutNamespace) || isAlreadyWithNamespace(resourceWithOutNamespace, namespace)) { return resourceWithOutNamespace; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithOutNamespace); StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } return stringBuilder.append(namespace).append(NAMESPACE_SEPARATOR).append(resourceWithoutRetryAndDLQ).toString(); }  }
NamespaceUtil { public static String wrapNamespace(String namespace, String resourceWithOutNamespace) { if (StringUtils.isEmpty(namespace) || StringUtils.isEmpty(resourceWithOutNamespace)) { return resourceWithOutNamespace; } if (isSystemResource(resourceWithOutNamespace) || isAlreadyWithNamespace(resourceWithOutNamespace, namespace)) { return resourceWithOutNamespace; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithOutNamespace); StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } return stringBuilder.append(namespace).append(NAMESPACE_SEPARATOR).append(resourceWithoutRetryAndDLQ).toString(); }  static String withoutNamespace(String resourceWithNamespace); static String withoutNamespace(String resourceWithNamespace, String namespace); static String wrapNamespace(String namespace, String resourceWithOutNamespace); static boolean isAlreadyWithNamespace(String resource, String namespace); static String wrapNamespaceAndRetry(String namespace, String consumerGroup); static String getNamespaceFromResource(String resource); static boolean isRetryTopic(String resource); static boolean isDLQTopic(String resource); }
NamespaceUtil { public static String wrapNamespace(String namespace, String resourceWithOutNamespace) { if (StringUtils.isEmpty(namespace) || StringUtils.isEmpty(resourceWithOutNamespace)) { return resourceWithOutNamespace; } if (isSystemResource(resourceWithOutNamespace) || isAlreadyWithNamespace(resourceWithOutNamespace, namespace)) { return resourceWithOutNamespace; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithOutNamespace); StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithOutNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } return stringBuilder.append(namespace).append(NAMESPACE_SEPARATOR).append(resourceWithoutRetryAndDLQ).toString(); }  static String withoutNamespace(String resourceWithNamespace); static String withoutNamespace(String resourceWithNamespace, String namespace); static String wrapNamespace(String namespace, String resourceWithOutNamespace); static boolean isAlreadyWithNamespace(String resource, String namespace); static String wrapNamespaceAndRetry(String namespace, String consumerGroup); static String getNamespaceFromResource(String resource); static boolean isRetryTopic(String resource); static boolean isDLQTopic(String resource); static final char NAMESPACE_SEPARATOR; static final String STRING_BLANK; static final int RETRY_PREFIX_LENGTH; static final int DLQ_PREFIX_LENGTH; }