CommonUtil { public static boolean validateVcDataStoreNames(List<String> names) { if (names == null || names.isEmpty()) { return false; } for (String name : names) { if (!validateVcDataStoreName(name)) { return false; } } return true; }  static void setOwnerOnlyReadWrite(String filename); static String getConfDir(); static File getConfigurationFile(final String filename, final String typeName); static String readJsonFile(URL fileURL); static String readJsonFile(final String fileName); static String dataFromFile(String filePath); static void gracefulRackTopologyOutput(
         Map<String, String> racksTopology, String filename, String delimeter); static void prettyOutputStrings(List<Object> objs, String fileName, String delimeter); static List<String> inputsConvert(String inputs); static Set<String> inputsConvertSet(String inputs); static String inputsConvert(Set<String> words); static String inputsConvert(Map<K, V> wordsMap); static boolean isBlank(final String str); static String notNull(final String str, final String desStr); static boolean validateVcResourceName(final String input); static boolean validateResourceName(final String input); static boolean validateDistroName(final String input); static boolean validateClusterName(final String input); static boolean validateNodeGroupName(final String input); static boolean validataPathInfo(final String input); static boolean validateVcDataStoreNames(List<String> names); static boolean matchDatastorePattern(Set<String> patterns, Set<String> datastores); static String escapePattern(String pattern); static String getDatastoreJavaPattern(String pattern); static String getUUID(); static long makeVmMemoryDivisibleBy4(long memory); static boolean validateClusterPassword(String password); static boolean passwordContainInvalidCharacter(String password); static String randomString(int count); static String getClusterName(String vmName); static long getVmIndex(String vmName); static Process execCommand(String cmd); static String decode(final String paramName); static String encode(final String paramName); static String getCurrentTimestamp(); static String toHexString(byte[] bytes); static KeyStore loadAppMgrKeyStore(String keystorePath); static boolean validateUrl(String url, List<String> errorMsgs); static String mergeErrorMsgList(List<String> errorMsgs); static String formatWarningMsg(String warningMsg); static boolean checkServerConnection(final String host, final int port, int waitTime); static Object waitForThreadResult(Future<?> result, int waitTime); static boolean validateDnsType(NetworkDnsType dnsType); static void writeFile(File file, String content); static void writeFile(File file, String content, boolean append); static boolean getBooleanFromString(String booleanString, boolean defaultValue); static String getCustomizedSudoCmd(); static StorageRead.DiskScsiControllerType getSystemAndSwapControllerType(); static StorageRead.DiskScsiControllerType getDataDiskControllerType(); static char[] allChars; }
@Test public void testValidateVcDataStoreNames() { List<String> vcDataStoreNames = new ArrayList<String>(); vcDataStoreNames.add("vcDataStore_Name1"); vcDataStoreNames.add("vcDataStore_Nam*"); vcDataStoreNames.add("vcDataStore_Nam?"); vcDataStoreNames.add("vcData Store_Name2"); vcDataStoreNames.add("vcDataStoreName3-"); vcDataStoreNames.add("vcDataStoreName192.168.0.1"); vcDataStoreNames.add("vcDataStoreName(192.168.0.1)"); vcDataStoreNames.add("vc本地存储(192.168.0.1)"); assertEquals(CommonUtil.validateVcDataStoreNames(vcDataStoreNames), true); List<String> errorVcDataStoreNames1 = new ArrayList<String>(); errorVcDataStoreNames1.add("vcDataStoreName!"); assertEquals(CommonUtil.validateVcDataStoreNames(errorVcDataStoreNames1), false); List<String> errorVcDataStoreNames2 = new ArrayList<String>(); errorVcDataStoreNames2.add("vcDataStoreName#"); assertEquals(CommonUtil.validateVcDataStoreNames(errorVcDataStoreNames2), false); }