BigQueryIOMetadata { public static boolean isValidCloudLabel(String value) { Matcher m = VALID_CLOUD_LABEL_PATTERN.matcher(value); return m.find(); } private  BigQueryIOMetadata(String beamJobId); static BigQueryIOMetadata create(); Map<String, String> addAdditionalJobLabels(Map<String, String> jobLabels); static boolean isValidCloudLabel(String value);  }
@Test public void testIsValidCloudLabel() { String testStr = "2020-06-29_15_26_09-12838749047888422749"; assertTrue(BigQueryIOMetadata.isValidCloudLabel(testStr)); testStr = "0"; assertTrue(BigQueryIOMetadata.isValidCloudLabel(testStr)); testStr = "0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij012"; assertTrue(BigQueryIOMetadata.isValidCloudLabel(testStr)); testStr = "abcdefghijklmnopqrstuvwxyz"; for (char testChar : testStr.toCharArray()) { assertTrue(BigQueryIOMetadata.isValidCloudLabel(String.valueOf(testChar))); } testStr = ""; assertFalse(BigQueryIOMetadata.isValidCloudLabel(testStr)); testStr = "0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123"; assertFalse(BigQueryIOMetadata.isValidCloudLabel(testStr)); testStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (char testChar : testStr.toCharArray()) { assertFalse(BigQueryIOMetadata.isValidCloudLabel(String.valueOf(testChar))); } testStr = "!@#$%^&*()+=[{]};:\'\"\\|,<.>?/`~"; for (char testChar : testStr.toCharArray()) { assertFalse(BigQueryIOMetadata.isValidCloudLabel(String.valueOf(testChar))); } }