ConfigUtils { public static Tuple2<String, String> getNameAndNamespaceFromString(String nameDotNamespace) { if (!nameDotNamespace.contains(".")) { return new Tuple2<>(nameDotNamespace, ""); } String name = nameDotNamespace.substring(nameDotNamespace.lastIndexOf(".") + 1); String namespace = nameDotNamespace.substring(0, nameDotNamespace.lastIndexOf(".")); return new Tuple2<>(name, namespace); }  static String getMd5(ConfigPayload payload); static String getMd5(String input); static String getMd5(Utf8Array input); static String getMd5(byte[] input); static String stripSpaces(String str); static String getDefMd5(List<String> lines); static String getDefNamespace(Reader in); static Tuple2<String, String> getNameAndNamespaceFromString(String nameDotNamespace); static ConfigDefinitionKey createConfigDefinitionKeyFromZKString(String nodeName); static ConfigDefinitionKey createConfigDefinitionKeyFromDefFile(File file); static String escapeConfigFormatValue(String input); static String getDefMd5FromRequest(String defMd5, List<String> defContent); static String getCanonicalHostName(); static String getEnvValue(String defaultValue, String... envVars); static boolean isGenerationNewer(long newGen, long oldGen);  }
@Test public void testNamespaceDotNames() { String namespaceDotName = "foo.bar"; Tuple2<String, String> tuple = ConfigUtils.getNameAndNamespaceFromString(namespaceDotName); assertThat(tuple.first, is("bar")); assertThat(tuple.second, is("foo")); namespaceDotName = "foo.baz.bar"; tuple = ConfigUtils.getNameAndNamespaceFromString(namespaceDotName); assertThat(tuple.first, is("bar")); assertThat(tuple.second, is("foo.baz")); namespaceDotName = "bar"; tuple = ConfigUtils.getNameAndNamespaceFromString(namespaceDotName); assertThat(tuple.first, is("bar")); assertThat(tuple.second, is("")); namespaceDotName = "foo."; tuple = ConfigUtils.getNameAndNamespaceFromString(namespaceDotName); assertThat(tuple.first, is("")); assertThat(tuple.second, is("foo")); namespaceDotName = ".bar"; tuple = ConfigUtils.getNameAndNamespaceFromString(namespaceDotName); assertThat(tuple.first, is("bar")); assertThat(tuple.second, is("")); }