@Test public void testWithoutNamespace() { String topic = NamespaceUtil.withoutNamespace(TOPIC_WITH_NAMESPACE, INSTANCE_ID); Assert.assertEquals(topic, TOPIC); String topic1 = NamespaceUtil.withoutNamespace(TOPIC_WITH_NAMESPACE); Assert.assertEquals(topic1, TOPIC); String groupId = NamespaceUtil.withoutNamespace(GROUP_ID_WITH_NAMESPACE, INSTANCE_ID); Assert.assertEquals(groupId, GROUP_ID); String groupId1 = NamespaceUtil.withoutNamespace(GROUP_ID_WITH_NAMESPACE); Assert.assertEquals(groupId1, GROUP_ID); String consumerId = NamespaceUtil.withoutNamespace(RETRY_TOPIC_WITH_NAMESPACE, INSTANCE_ID); Assert.assertEquals(consumerId, RETRY_TOPIC); String consumerId1 = NamespaceUtil.withoutNamespace(RETRY_TOPIC_WITH_NAMESPACE); Assert.assertEquals(consumerId1, RETRY_TOPIC); String consumerId2 = NamespaceUtil.withoutNamespace(RETRY_TOPIC_WITH_NAMESPACE, INSTANCE_ID_WRONG); Assert.assertEquals(consumerId2, RETRY_TOPIC_WITH_NAMESPACE); Assert.assertNotEquals(consumerId2, RETRY_TOPIC); }
public static String withoutNamespace(String resourceWithNamespace) { if (StringUtils.isEmpty(resourceWithNamespace) || isSystemResource(resourceWithNamespace)) { return resourceWithNamespace; } StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithNamespace); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); if (index > 0) { String resourceWithoutNamespace = resourceWithoutRetryAndDLQ.substring(index + 1); return stringBuilder.append(resourceWithoutNamespace).toString(); } return resourceWithNamespace; }
NamespaceUtil { public static String withoutNamespace(String resourceWithNamespace) { if (StringUtils.isEmpty(resourceWithNamespace) || isSystemResource(resourceWithNamespace)) { return resourceWithNamespace; } StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithNamespace); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); if (index > 0) { String resourceWithoutNamespace = resourceWithoutRetryAndDLQ.substring(index + 1); return stringBuilder.append(resourceWithoutNamespace).toString(); } return resourceWithNamespace; } }
NamespaceUtil { public static String withoutNamespace(String resourceWithNamespace) { if (StringUtils.isEmpty(resourceWithNamespace) || isSystemResource(resourceWithNamespace)) { return resourceWithNamespace; } StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithNamespace); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); if (index > 0) { String resourceWithoutNamespace = resourceWithoutRetryAndDLQ.substring(index + 1); return stringBuilder.append(resourceWithoutNamespace).toString(); } return resourceWithNamespace; }  }
NamespaceUtil { public static String withoutNamespace(String resourceWithNamespace) { if (StringUtils.isEmpty(resourceWithNamespace) || isSystemResource(resourceWithNamespace)) { return resourceWithNamespace; } StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithNamespace); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); if (index > 0) { String resourceWithoutNamespace = resourceWithoutRetryAndDLQ.substring(index + 1); return stringBuilder.append(resourceWithoutNamespace).toString(); } return resourceWithNamespace; }  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 withoutNamespace(String resourceWithNamespace) { if (StringUtils.isEmpty(resourceWithNamespace) || isSystemResource(resourceWithNamespace)) { return resourceWithNamespace; } StringBuilder stringBuilder = new StringBuilder(); if (isRetryTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.RETRY_GROUP_TOPIC_PREFIX); } if (isDLQTopic(resourceWithNamespace)) { stringBuilder.append(MixAll.DLQ_GROUP_TOPIC_PREFIX); } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resourceWithNamespace); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); if (index > 0) { String resourceWithoutNamespace = resourceWithoutRetryAndDLQ.substring(index + 1); return stringBuilder.append(resourceWithoutNamespace).toString(); } return resourceWithNamespace; }  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; }