### Question:
AnomalyUtils { public static Pattern buildTopicRegex(Set<String> stringsToMatch) { StringJoiner sj = new StringJoiner("|"); stringsToMatch.forEach(sj::add); return Pattern.compile(sj.toString()); } private  AnomalyUtils(); static KafkaCruiseControl extractKafkaCruiseControlObjectFromConfig(Map<String, ?> configs,
                                                                            AnomalyType anomalyType); static boolean isLoadMonitorReady(LoadMonitorTaskRunner.LoadMonitorTaskRunnerState loadMonitorTaskRunnerState); static Pattern buildTopicRegex(Set<String> stringsToMatch); static int parseAndGetConfig(Map<String, Object> config,
                                      String key,
                                      int defaultValue,
                                      Predicate<Integer> illegalValueCheck); static double parseAndGetConfig(Map<String, Object> config,
                                         String key,
                                         double defaultValue,
                                         Predicate<Double> illegalValueCheck);  }### Answer:
@Test public void testBuildTopicRegex() { Set<String> topicsToMatch = new HashSet<>(2); topicsToMatch.add(TOPIC1); topicsToMatch.add(TOPIC2); Pattern pattern = buildTopicRegex(topicsToMatch); assertTrue(pattern.matcher(TOPIC1).matches()); assertTrue(pattern.matcher(TOPIC2).matches()); assertFalse(pattern.matcher(TOPIC3).matches()); }