Util { public static List<SchemaPath> expandQname(final List<SchemaPath> list, final Pattern pattern) { final List<SchemaPath> matchingQnames = new ArrayList<>(); for (final SchemaPath notification : list) { final String namespace = notification.getLastComponent().getNamespace().toString(); if (pattern.matcher(namespace).matches()) { matchingQnames.add(notification); } } return matchingQnames; } private  Util(); static ListenableFuture<RpcResult<T>> resultRpcSuccessFor(final T output); static List<SchemaPath> expandQname(final List<SchemaPath> list, final Pattern pattern); static String wildcardToRegex(final String wildcard);  }
@Test public void testExpandQname() { { final List<SchemaPath> paths = new ArrayList<>(); final Pattern regexPattern = Pattern.compile(".*"); final List<SchemaPath> matchingPaths = Util.expandQname(paths, regexPattern); assertTrue(matchingPaths.isEmpty()); } { final List<SchemaPath> paths = createSchemaPathList(); final Pattern regexPattern = Pattern.compile("^@.*"); final List<SchemaPath> matchingPaths = Util.expandQname(paths, regexPattern); assertTrue(matchingPaths.isEmpty()); } { final List<SchemaPath> paths = createSchemaPathList(); final Pattern regexPattern = Pattern.compile(".*"); final List<SchemaPath> matchingPaths = Util.expandQname(paths, regexPattern); assertTrue(matchingPaths.contains(paths.get(0))); assertTrue(matchingPaths.contains(paths.get(1))); assertEquals(paths.size(), matchingPaths.size()); } { final List<SchemaPath> paths = createSchemaPathList(); final Pattern regexPattern = Pattern.compile(".*yyy$"); final List<SchemaPath> matchingPaths = Util.expandQname(paths, regexPattern); assertTrue(matchingPaths.contains(paths.get(1))); assertEquals(1, matchingPaths.size()); } }