GlobStringsMatcher { public boolean isMatch(String value) { return patterns.stream().anyMatch(pattern -> value.matches(pattern)); } GlobStringsMatcher(String systemProperty); boolean isEmptyPatternsList(); boolean isMatch(String value);  }
@Test public void testGlobStringMatcher() { String globStrings = "aaa.bbb.ccc.ddd, " + "???.ddd, " + "*.bbb.*.ddd, " + "aaa.??, "; String systemProperty = "athenz.zts.notification_cert_fail_ignored_services_list"; System.setProperty(systemProperty, globStrings); GlobStringsMatcher globStringsMatcher = new GlobStringsMatcher(systemProperty); assertTrue(globStringsMatcher.isMatch("aaa.bbb.ccc.ddd")); assertTrue(globStringsMatcher.isMatch("ccc.ddd")); assertTrue(globStringsMatcher.isMatch("aaa.yy")); assertTrue(globStringsMatcher.isMatch("1.2.bbb.444.555.ddd")); assertFalse(globStringsMatcher.isMatch("1.2.3.ddd")); assertFalse(globStringsMatcher.isMatch("ddd")); assertFalse(globStringsMatcher.isMatch("ccc")); assertFalse(globStringsMatcher.isMatch("bbb")); assertFalse(globStringsMatcher.isMatch("bbb.ccc")); assertFalse(globStringsMatcher.isMatch("1.2.ddd.3")); assertFalse(globStringsMatcher.isMatch("something.else")); System.clearProperty(systemProperty); }