@Test public void testGetNamespaceFromResource(){ String namespaceExpectBlank = NamespaceUtil.getNamespaceFromResource(TOPIC); Assert.assertEquals(namespaceExpectBlank, NamespaceUtil.STRING_BLANK); String namespace = NamespaceUtil.getNamespaceFromResource(TOPIC_WITH_NAMESPACE); Assert.assertEquals(namespace, INSTANCE_ID); String namespaceFromRetryTopic = NamespaceUtil.getNamespaceFromResource(RETRY_TOPIC_WITH_NAMESPACE); Assert.assertEquals(namespaceFromRetryTopic, INSTANCE_ID); }
public static String getNamespaceFromResource(String resource) { if (StringUtils.isEmpty(resource) || isSystemResource(resource)) { return STRING_BLANK; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resource); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); return index > 0 ? resourceWithoutRetryAndDLQ.substring(0, index) : STRING_BLANK; }
NamespaceUtil { public static String getNamespaceFromResource(String resource) { if (StringUtils.isEmpty(resource) || isSystemResource(resource)) { return STRING_BLANK; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resource); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); return index > 0 ? resourceWithoutRetryAndDLQ.substring(0, index) : STRING_BLANK; } }
NamespaceUtil { public static String getNamespaceFromResource(String resource) { if (StringUtils.isEmpty(resource) || isSystemResource(resource)) { return STRING_BLANK; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resource); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); return index > 0 ? resourceWithoutRetryAndDLQ.substring(0, index) : STRING_BLANK; }  }
NamespaceUtil { public static String getNamespaceFromResource(String resource) { if (StringUtils.isEmpty(resource) || isSystemResource(resource)) { return STRING_BLANK; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resource); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); return index > 0 ? resourceWithoutRetryAndDLQ.substring(0, index) : STRING_BLANK; }  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 getNamespaceFromResource(String resource) { if (StringUtils.isEmpty(resource) || isSystemResource(resource)) { return STRING_BLANK; } String resourceWithoutRetryAndDLQ = withOutRetryAndDLQ(resource); int index = resourceWithoutRetryAndDLQ.indexOf(NAMESPACE_SEPARATOR); return index > 0 ? resourceWithoutRetryAndDLQ.substring(0, index) : STRING_BLANK; }  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; }